npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

homebridge-gpio-services

v1.0.6

Published

Raspberry Pi GPIO plugin for valve accessories for Homebridge: https://github.com/nfarina/homebridge

Downloads

24

Readme

homebridge-gpio-services

Use config.json for examples. There are some Services in BETA status, they may have bugs. You should only use BETA services for testing! BETA services are not finished, API may change! When you find a bug in a service or BETA-service, please let me know by creating github issues.

Thanks for using this plugin.

Installation

You need to install gcc 4.9 and g++ 4.9 as your default gcc and g++:

sudo apt-get install gcc-4.9 g++-4.9
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 60 --slave /usr/bin/g++ g++ /usr/bin/g++-4.9

Install nodejs and npm:

curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs

Install Homebridge:

sudo npm install homebridge -g --unsafe-perm

Install this plugin:

sudo npm install homebridge-gpio-services -g --unsafe-perm

GPIO-ContactSensor-Service

Use this accessory for contact sensor. You can change the type of contact sensor in iOS (Window|ContactSensor|Garagedoor|Covering|Door).

| Attribute | Type | Optional | Default | Description |--------------|--------|----------|---------|------------- |name | string | [ ] | - | Name of Accessory |pin | int | [ ] | - | GPIO pin number. |invertHighLow | bool | [x] | false | Set to true if outlet has to be inverted.

GPIO-PushButton-Service

Use this accessory for push button. Switch will turn off automatically after invokeTimeout.

| Attribute | Type | Optional | Default | Description |--------------|--------|----------|---------|------------- |name | string | [ ] | - | Name of Accessory |pin | int | [ ] | - | GPIO pin number. |invertHighLow | bool | [x] | false | Set to true if outlet has to be inverted. |invokeTimeout | int | [x] | 500 | Timeout for push event in ms.

GPIO-Switch-Service

Use this accessory for wall switch.

| Attribute | Optional | Type | Default | Description |--------------|----------|--------|---------|------------- |name | [ ] | string | - | Name of Accessory |pin | [ ] | int | - | GPIO pin number. |invertHighLow | [x] | bool | false | Set to true if outlet has to be inverted.

GPIO-Valve-Service

Use this accessory for Valve outlets. For example sprinklers.

| Attribute | Optional | Type | Default | Description |------------------|----------|--------|----------------|------------- |name | [ ] | string | - | Name of Accessory |pin | [ ] | int | - | GPIO pin number. |invertHighLow | [x] | bool | false | Set to true if outlet has to be inverted. |valveType | [x] | string | "GenericValve" | Sets type of Accessory. ("Faucet"|"ShowerHead"|"Sprinkler"|"GenericValve") |manualDuration | [x] | int | 300 | Time in Seconds. Default: 300 => 5min (300|600|900|1200|1500|1800|2100|2400|2700|3000|3300|3600) |automationDateTime| [x] | string | - | DateTime for automated irrigation. Format: "HH:MM" Example: 0:00 -> "00:00" not specified -> no automation |automationDuration| [x] | int | 300 | Time in Seconds for automated irrigation. Default: 300 => 5min |isAutomationActive| [x] | bool | false | Activates automatic irrigation.

HomeKit shows different icons for faucet and sprinkler in iOS 11.4. Shower head and generic valve will be shown as faucet in home app. Perhaps there will be different icons in future.

GPIO

To activate GPIO configuration at startup you have to add a script like the following: (You will need this to avoid wrong default values at boot time.)

sudo nano /etc/init.d/gpio

Script content :

#!/bin/sh
### BEGIN INIT INFO
# Provides:          gpio
# Required-Start:    $remote_fs dbus
# Required-Stop:     $remote_fs dbus
# Should-Start:      $syslog
# Should-Stop:       $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Enable GPIO
# Description:       Enable GPIO
### END INIT INFO

PATH=/sbin:/bin:/usr/sbin:/usr/bin
DESC="Enable GPIO for the Module"
NAME="gpio"
SCRIPTNAME=/etc/init.d/$NAME

. /lib/lsb/init-functions

case "$1" in
    start)
        log_daemon_msg "Enabling GPIO"
        success=0

    #Relais 1 Switch example at GPIO26
    if [ ! -e /sys/class/gpio/gpio26 ] ; then
        echo 26 > /sys/class/gpio/export
        success=$?
        echo out > /sys/class/gpio/gpio26/direction
        echo 1 > /sys/class/gpio/gpio26/value
    fi
    
    #Relais 2 Switch example at GPIO19
    if [ ! -e /sys/class/gpio/gpio19 ] ; then
        echo 19 > /sys/class/gpio/export
        success=$?
        echo out > /sys/class/gpio/gpio19/direction
        echo 1 > /sys/class/gpio/gpio19/value
    fi
    
    #Sensor 1 GPIO17
    if [ ! -e /sys/class/gpio/gpio17 ] ; then
         echo 17 > /sys/class/gpio/export
         success=$?
         echo in > /sys/class/gpio/gpio17/direction
    fi
    
    #Sensor 2 GPIO27
    if [ ! -e /sys/class/gpio/gpio27 ] ; then
        echo 27 > /sys/class/gpio/export
        success=$?
        echo in > /sys/class/gpio/gpio27/direction
    fi
    
    log_end_msg $success
    ;;
    *)
    echo "Usage: $SCRIPTNAME {start}" >&2
    exit 1
    ;;
esac

exit 0

Add script to startup:

sudo chmod +x /etc/init.d/gpio
sudo chown root:root /etc/init.d/gpio

sudo update-rc.d gpio defaults
sudo update-rc.d gpio enable

Changelog

[1.0.6]

  • fixing dependencies

[1.0.5]

  • Readme.md: added installation Guide
  • Readme.md: added GPIO startup Guide
  • fixing bugs in Valve
  • added GPIO Debugger for development
  • refactoring accessories and gpio actuators

Next Features

  • GPIO-GarageDoorOpener-Service: new Service