1.0.6 • Published 6 years ago

homebridge-gpio-services v1.0.6

Weekly downloads
2
License
ISC
Repository
github
Last release
6 years ago

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).

AttributeTypeOptionalDefaultDescription
namestring -Name of Accessory
pinint -GPIO pin number.
invertHighLowboolxfalseSet to true if outlet has to be inverted.

GPIO-PushButton-Service

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

AttributeTypeOptionalDefaultDescription
namestring -Name of Accessory
pinint -GPIO pin number.
invertHighLowboolxfalseSet to true if outlet has to be inverted.
invokeTimeoutintx500Timeout for push event in ms.

GPIO-Switch-Service

Use this accessory for wall switch.

AttributeOptionalTypeDefaultDescription
name string-Name of Accessory
pin int-GPIO pin number.
invertHighLowxboolfalseSet to true if outlet has to be inverted.

GPIO-Valve-Service

Use this accessory for Valve outlets. For example sprinklers.

AttributeOptionalTypeDefaultDescription
name string-Name of Accessory
pin int-GPIO pin number.
invertHighLowxboolfalseSet to true if outlet has to be inverted.
valveTypexstring"GenericValve"Sets type of Accessory. ("Faucet"|"ShowerHead"|"Sprinkler"|"GenericValve")
manualDurationxint300Time in Seconds. Default: 300 => 5min (300|600|900|1200|1500|1800|2100|2400|2700|3000|3300|3600)
automationDateTimexstring-DateTime for automated irrigation. Format: "HH:MM" Example: 0:00 -> "00:00" not specified -> no automation
automationDurationxint300Time in Seconds for automated irrigation. Default: 300 => 5min
isAutomationActivexboolfalseActivates 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
1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago

0.0.1

6 years ago