Coder Social home page Coder Social logo

homebridge-rasppi-gpio-garagedoor's Introduction

homebridge-rasppi-gpio-garagedoor

Raspberry Pi GPIO GarageDoor plugin for HomeBridge

Circuit

This plugin assumes that you are using a Raspberry Pi to directly control your garage door. Garage Door openers usually have a switch on the wall that you can push to open the garage door. On my model, this is just a very simple switch that completes a 24vdc circuit. The button must be pressed for about a second before the door will open. In order for this to be an effective garage door opener, you need two parts, a relay that will perform the duty of the button, and a reed switch that will detect when your garage door is closed.

Installation

IMPORTANT NOTE ON PIN SELECTION

When the Raspberry Pi reboots GPIO pins are reset to their default state. This can cause your garage door to open without you issuing a command. Please make sure you pick the correct pins so that you don't accidentally have your garage door opening after a power loss.

The following pins are pulled HIGH (they output a 3.3 volt signal) on reboot:

  • GPIO0/2
  • GPIO1/3
  • GPIO4
  • GPIO7
  • GPIO8

GPIO14 is configured as a Serial Transmit line, so avoid choosing that pin.

All other pins are pulled LOW (they have a 0 volt signal, same as GND).

If your relay triggers when the GPIO pin goes LOW, then pick a pin that starts out HIGH on reboot. If your relay triggers with the GPIO PIN goes HIGH then pick a GPIO pin that starts out LOW on reboot.

(information comes from https://www.raspberrypi.org/forums/viewtopic.php?f=44&t=24491)


  1. Install the following software: (assuming you are using debian stretch or later)
    1. sudo apt-get install libavahi-client-dev nodejs-legacy nodejs npm
    2. sudo npm install -g --unsafe-perf homebridge
    3. sudo npm install homebridge-rasppi-gpio-garagedoor -g
  2. Choose the GPIO pins that you are going to use, following the above information
  3. Configure the system:
    1. Create the /var/lib/homebridge directory
    2. Copy the files from the scripts/var/lib/homebridge directory into appropriate locations;
      • scripts/etc/default/homebridge => /etc/default/homebridge
      • scripts/etc/systemd/system/homebridge.service => /etc/systemd/system/homebridge.service
      • scripts/etc/var/lib/homebridge/garage-door-gpio => /var/lib/homebridge/garage-door-gpio
    3. Create the config.json to control homebridge at /var/lib/homebridge/config.json. Here is a sample of a config for two garage doors.
  4. Run the following commands to enable homebridge
    1. sudo systemctl daemon-reload
    2. sudo systemctl enable homebridge
    3. sudo systemctl start homebridge

Configuration

You will need to add the following accessory configuration to the Homebridge config.json

Configuration sample:

   "accessories": [
       {
           "accessory": "RaspPiGPIOGarageDoor",
           "name": "Garage Door",
           "doorSwitchPin": 23,
           "doorSwitchPressTimeInMs": 1000,
           "doorSwitchValue": 1,
           "closedDoorSensorPin": 24,
           "closedDoorSensorValue": 1,
           "openDoorSensorPin": 25,
           "openDoorSensorValue": 1,
           "doorPollInMs": 4000,
           "doorOpensInSeconds": 14
       }
   ],

Fields:

  • name - Can be anything (required)
  • doorSwitchPin - The physical GPIO pin number that controls the relay to trigger the garage door
  • doorSwitchPressTimeInMs - number of milliseconds to trigger the garage door button. defaults to 1000 millseconds (1 second) if not specified
  • doorSwitchValue - 1 = ACTIVE_HIGH, 0 = ACTIVE_LOW, defaults to 1 if not specified. Set to 0 if you have a relay that requires the signal to be 0v to trigger.
  • closedDoorSensorPin - The physical GPIO pin that senses if the door is closed, do not specify if no sensor present
  • closedDoorSensorValue - 1 = ACTIVE_HIGH, 0 = ACTIVE_LOW, defaults to 1 if not specified
  • openDoorSensorPin - OPTIONAL Omit line if you don't have an open sensor. The physical GPIO pin that senses if the door is open, do not specify if no sensor present
  • openDoorSensorValue - OPTIONAL Omit line if you don't have an open sensor. 1 = ACTIVE_HIGH, 0 = ACTIVE_LOW, defaults to 1 if not specified
  • doorPollInMs - Number of milliseconds to wait before polling the doorSensorPin to report if the door is open or closed
  • doorOpensInSeconds - Number of seconds it takes your garage door to open or close (err on the side of being longer than it actually takes)

homebridge-rasppi-gpio-garagedoor's People

Contributors

benlamonica avatar daviderie avatar virgilm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

homebridge-rasppi-gpio-garagedoor's Issues

Garage door opens when raspberry pi boots, plus wall button stops working

So for my very first raspberry pi project awhile back, I followed a cool YouTube video to allow me to control the garage door via Homekit. Works great, but... I really want to switch to a Homebridge based solution.

Can I use the current wiring with no issues?

Relay module (wired to the same wires that connect to the garage door opener on the garage wall):
pin 26, gpio 7

Magnetic reed switch (to determine if door is closed/not closed):
pin 12, gpio 18

Relay locking in on position upon first boot

Weird issues here after updating to the new 1.0.5 code.

1 thing i notice is that "doorSwitchValue" in the config.json is not referenced in the index.js file, i believe this should replace "relayOnValue" on line 38.

My relay values are flipped, so i had to add that config parameter to the config.json, which leads me to my next issue of the relay being "stuck" in the on position upon boot.

When i fire up homebridge, the relay triggers to on and my garage opens, and the relay stays jammed in the on position. (this prevents me from using the button on the wall)

Once i press the button to close the garage, it then does the proper cycle of "press button for 1 sec" then shut the relay back off. (or whatever time you defined in "doorSwitchPressTimeInMs"). After i press the button once in the app it seems to THEN set the relay to off in its default state.

Is there a way to force the relay to be in the off position in it's default state, as specified by the "relayOnValue" on the config.json?

Status stays Opening/Closing at Home.app in IOC 10.3.2

I am new to homebridge platform and intend to use it to control the garage door.I basically used the same config as in the example. PIN 18 for trigger, PIN 24 and 25 for Close/Open input.

I simulate the close/open sensor by connecting them to 3.3V. On the console log, it reports correctly the state changes.
[2017-6-10 18:46:31] [Garage Door] GarageDoor is OPEN (0)
[2017-6-10 18:46:38] [Garage Door] Setting state to CLOSE
[2017-6-10 18:46:38] [Garage Door] Triggering GarageDoor Relay
[2017-6-10 18:46:38] [Garage Door] Turning on GarageDoor Relay, pin 18 = 1
[2017-6-10 18:46:40] [Garage Door] Turning off GarageDoor Relay, pin 18 = 0
[2017-6-10 18:46:53] [Garage Door] Set current state to CLOSED

But the Home app stuck in showing "Closing". Any observation of such issue?

Adding a physical push button switch

Is it possible to add a momentry push button/switch that will also open/close the garage door? Like the old push button that would have been in place but it triggers through Homebridge to open/close the garage door? Good work BTW!

Question on doorOpensInSeconds

Hello,
Thanks for this great plugin.

I have not understood what is the purpose of following parameter:

doorOpensInSeconds - Number of seconds it takes your garage door to open or close (err on the side of being longer than it actually takes)

Can you please clarify?
Thanks,
Dan

GPIO pin number - clarification for readme

Might be an idea to note in the readme that the pin numbers are the BCM pin numbers as shown in https://pinout.xyz. I got all confused thinking that "physical" pin number was based on the pins I could see on the board of my Pi. Nothing worked (of course) and I had to dig around using pigpio before that face palm moment.

Opening/Closing

This is more of an enhancement, to open/close the garage door its a simple toggle relay. However your plugin/homekit/bridge is clever enough to know if its open and you say open the door it doesn't toggle. Same as asking it to close when close, it won't open it which is great.

I was wondering when its closing (HomeKit says closing) could an open command be sent and it actually sends two toggle commands. The first stops it, then it toggles again to open it. So basically the plugin knows if its in an opening or closing state and a command is issued then it will send two toggle commands..

If its really complicated then I wouldn't worry, just a though I had lol

start script is empty

the downloaded start file is empty. I think it is necessary to make these steps 1-2. Because otherwise there is a error : Enoent: no such file or directory, open'\sys/class/gpio/gpio/value'

Please upload the code or tell me my mistake.

Error when initializing home bridge

fs.js:646
return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
^

Error: ENOENT: no such file or directory, open '/sys/class/gpio/gpio22/value'
at Object.fs.openSync (fs.js:646:18)
at Object.fs.readFileSync (fs.js:551:33)
at RaspPiGPIOGarageDoorAccessory.readPin (/usr/local/lib/node_modules/homebridge-rasppi-gpio-garagedoor/index.js:149:26)
at RaspPiGPIOGarageDoorAccessory.isClosed (/usr/local/lib/node_modules/homebridge-rasppi-gpio-garagedoor/index.js:158:21)
at RaspPiGPIOGarageDoorAccessory.initService (/usr/local/lib/node_modules/homebridge-rasppi-gpio-garagedoor/index.js:124:25)
at new RaspPiGPIOGarageDoorAccessory (/usr/local/lib/node_modules/homebridge-rasppi-gpio-garagedoor/index.js:66:8)
at Server._loadAccessories (/usr/local/lib/node_modules/homebridge/lib/server.js:297:29)
at Server.run (/usr/local/lib/node_modules/homebridge/lib/server.js:87:38)
at module.exports (/usr/local/lib/node_modules/homebridge/lib/cli.js:45:10)
at Object. (/usr/local/lib/node_modules/homebridge/bin/homebridge:17:22)

Node v8.11.1
Linux garage 4.14.62+ #1134 Tue Aug 14 16:58:07 BST 2018 armv6l GNU/Linux
Distributor ID: Raspbian
Description: Raspbian GNU/Linux 9.4 (stretch)
Release: 9.4
Codename: stretch

DoorOpenSensor

Hi all,

I got the idea of adding a reed switch to detect the door when it is open from your readme. I have installed it and it works fine on the raspberry pi and gpio user has access to the pin. 1 is when its open and 0 is when its closed.

I have added the required line to the config and homebridge starts fine. The issue I am getting is when the garage door is opened from the wall switch or from any means other than homekit then homekit comes up with no response when its open. So I can't close it. Normal situation is pulling up in the car and opening the garage using the opener in the car, then once car is in the garage I use Siri to close it (don't have to carry an opener with me that way).

Possible polling the switch too early? Any ideas?

This is a snippet of config

"accessories": [{
	"accessory": "RaspPiGPIOGarageDoor",
	"name": "Garage Door",
	"doorSwitchPin": 4,
	"closedDoorSensorPin": 17,
            "openDoorSensorPin": 27,
            "openDoorSensorValue": 1,
	"doorPollInMs": 4000,
	"doorOpensInSeconds": 20

Permissions on gpio not set by default. Add to instructions note do a gpio export?

By default on the raspberry pi (at least it was on mine) none of the pins are exported. This means that without the user updating their system configuration your plugin fails as the gpio pins haven't been exported.

For me I needed to add the following to /etc/rc.local file. My homebridge runs as the pi user. Need to replace pi with the user being used to run homebridge.
sudo -u pi /usr/local/bin/gpio export 26 out
sudo -u pi /usr/local/bin/gpio export 24 in

(Pin 26 was my output pin, 24 was my input pin).

I am happily opening my garage door now -- thank you.

Is it possible to simulate a closedDoorSensor?

Hello,
at first I want to thank you for the great plugin. It works very good!

I'm using the openDoorSensor and not the closedDoorSensor. Therefore Siri does not give me a promptly feedback when I ask "her" to open my front garage door. This is logical, since Siri (and accordingly homebridge) is waiting for the response from my openDoorSensor (the reed closes the circuitry when the door is fully opened). I could switch the sensor setup to a closed door sensor, but then I would have the same experience when I want to close the door. Just for the info: my Door needs 20 sec to open/close.

So I want to have a fast feedback from Siri (without waiting times) and without the need to install closed AND opend sensors. And here is my question:
Would it be possible to add a function to simulate a missing doorsensor? For example:
I ask Siri to open the garage door, your plugin/homebridge will open my door and right after this it will tell Siri, that the door is opened (without to wait for the openDoorSensor). So it will simulate a missing closedDoorSensor. If my openDoorSensor would not trigger after ~25 sec, your plugin could revoke the open status and correct it to closed.

I dont know if this would be possible, but I think with such an option, all my openings and closings will get a nice and fast response in homekit/siri.
Best regards!

getting error when starting homebridge

[Sat Dec 31 2016 14:26:04 GMT-0800 (PST)] ERROR LOADING PLUGIN homebridge-rasppi-gpio-garagedoor:
[Sat Dec 31 2016 14:26:04 GMT-0800 (PST)] Error: must run homebridge as root to control gpio pins
at Object. (/usr/local/lib/node_modules/homebridge-rasppi-gpio-garagedoor/index.js:6:11)
at Module._compile (module.js:435:26)
at Object.Module._extensions..js (module.js:442:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:311:12)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at Plugin.load (/usr/local/lib/node_modules/homebridge/lib/plugin.js:65:22)
at Server. (/usr/local/lib/node_modules/homebridge/lib/server.js:128:14)
at Array.forEach (native)
at Server._loadPlugins (/usr/local/lib/node_modules/homebridge/lib/server.js:124:22)
at new Server (/usr/local/lib/node_modules/homebridge/lib/server.js:48:24)
at module.exports (/usr/local/lib/node_modules/homebridge/lib/cli.js:26:16)
at Object. (/usr/local/lib/node_modules/homebridge/bin/homebridge:17:22)
at Module._compile (module.js:435:26)
at Object.Module._extensions..js (module.js:442:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:311:12)
at Function.Module.runMain (module.js:467:10)
at startup (node.js:134:18)
at node.js:961:3

open door sensor error

Hi, sorry for my bad english.
I set up 2 garage doors with these GPIO:
DOOR1: switch 23 - sensor 18
DOOR2: switch 22 - sensor 24
I have a problem: when I open the door, status switches from "closed" to opening and, 14 seconds later, to "open". Now, if I close Home app and reopen, status of the door is "No

response" (see screenshot below) and the button doesn't work anymore... If I ask "Siri close garage door", all works again...
What's wrong?

Here my config.json:

{
        "bridge": {
                "name": "piGarage",
                "username": "BD:52:5D:E3:CE:30",
                "port": 51826,
                "pin": "031-45-154"
        },

        "description": "This is an example configuration file with one fake acc$

        "accessories": [{
                "accessory": "RaspPiGPIOGarageDoor",
                "name": "Garage Stefano",
                "doorSwitchPin": 23,
                "doorSwitchPressTimeInMs": 500,
                "doorSwitchValue": 0,
                "closedDoorSensorPin": 18,
                "closedDoorSensorValue": 0,
                "openDoorSensorPin": 18,
                "openDoorSensorValue": 1,
                "doorPollInMs": 1000,
                "doorOpensInSeconds": 14
        }, {
                "accessory": "RaspPiGPIOGarageDoor",
                "name": "Garage Norino",
                "doorSwitchPin": 22,
                "doorSwitchPressTimeInMs": 500,
                "doorSwitchValue": 0,
                "closedDoorSensorPin": 24,
                "closedDoorSensorValue": 0,
                "openDoorSensorPin": 24,
                "openDoorSensorValue": 1,
                "doorPollInMs": 1000,
                "doorOpensInSeconds": 14
        }],

        "platforms": []
}

And here my garage-door-gpio:

#!/bin/sh
### BEGIN INIT INFO
# Provides:          garage-door-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 Garage Door GPIO
# Description:       Enable Garage Door GPIO
### END INIT INFO

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

. /lib/lsb/init-functions

case "$1" in
    start)
        log_daemon_msg "Enabling Garage Door GPIO"
        success=0
        if [ ! -e /sys/class/gpio/gpio23 ] ; then
                echo 23 > /sys/class/gpio/export
                success=$?
                echo out > /sys/class/gpio/gpio23/direction     
                echo 1 > /sys/class/gpio/gpio23/value
        fi

        if [ ! -e /sys/class/gpio/gpio18 ] ; then
                echo 18 > /sys/class/gpio/export
                success=$?
                echo in > /sys/class/gpio/gpio18/direction
        fi

        if [ ! -e /sys/class/gpio/gpio24 ] ; then
                echo 24 > /sys/class/gpio/export
                success=$?
                echo in > /sys/class/gpio/gpio24/direction
        fi

        if [ ! -e /sys/class/gpio/gpio22 ] ; then
                echo 22 > /sys/class/gpio/export
                success=$?
                echo out > /sys/class/gpio/gpio22/direction
                echo 1 > /sys/class/gpio/gpio22/value
        fi
 

Can anyone help me?
Thank you
Stefano

Help with issue

Hi
Thank you for providing this platform, I'm having issues with the installation of it but that could be just me with very limited coding knowledge. I have homebridge running on Rpi 3 and using the wemo platform with nil issues but ive been trying to follow your instructions on this garage door but just when think i have it right i now have this error. Any assistance would be great

Cheers Aaron

pi@raspberrypi:~ $ homebridge
*** WARNING *** The program 'node' uses the Apple Bonjour compatibility layer of Avahi.
*** WARNING *** Please fix your application to use the native API of Avahi!
*** WARNING *** For more information see http://0pointer.de/avahi-compat?s=libdns_sd&e=node
*** WARNING *** The program 'node' called 'DNSServiceRegister()' which is not supported (or only supported partially) in the Apple Bonjour compatibility layer of Avahi.
*** WARNING *** Please fix your application to use the native API of Avahi!
*** WARNING *** For more information see http://0pointer.de/avahi-compat?s=libdns_sd&e=node&f=DNSServiceRegister
[5/19/2016, 9:48:57 PM] Loaded plugin: homebridge-platform-wemo
[5/19/2016, 9:48:57 PM] Registering platform 'homebridge-platform-wemo.BelkinWeMo'
[5/19/2016, 9:48:57 PM] ---
[5/19/2016, 9:48:57 PM] Loaded plugin: homebridge-rasppi-gpio-garagedoor
[5/19/2016, 9:48:57 PM] Registering accessory 'homebridge-rasppi-gpio-garagedoor.RaspPiGPIOGarageDoor'
[5/19/2016, 9:48:57 PM] ---
[5/19/2016, 9:48:57 PM] Loaded config.json with 1 accessories and 1 platforms.
[5/19/2016, 9:48:57 PM] ---
[5/19/2016, 9:48:57 PM] Loading 1 platforms...
[5/19/2016, 9:48:57 PM] [WeMo Platform] Initializing BelkinWeMo platform...
[5/19/2016, 9:48:57 PM] [WeMo Platform] Wemo Platform Plugin Loaded
[5/19/2016, 9:48:57 PM] [WeMo Platform] Fetching the Wemo Accessories, expecting 20 and will wait 25 seconds to find them.
[5/19/2016, 9:48:57 PM] Loading 1 accessories...
[5/19/2016, 9:48:57 PM] [Front Garage Door] Initializing RaspPiGPIOGarageDoor accessory...
[5/19/2016, 9:48:57 PM] [Front Garage Door] Door Switch Pin: 17
[5/19/2016, 9:48:57 PM] [Front Garage Door] Door Sensor Pin: 27
[5/19/2016, 9:48:57 PM] [Front Garage Door] Door Poll in ms: 4000
[5/19/2016, 9:48:57 PM] [Front Garage Door] Door Opens in seconds: 14
fs.js:585
return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
^

Error: ENOENT: no such file or directory, open '/sys/class/gpio/gpio27/value'
at Error (native)
at Object.fs.openSync (fs.js:585:18)
at Object.fs.readFileSync (fs.js:432:33)
at Object.RaspPiGPIOGarageDoorAccessory.isClosed (/usr/local/lib/node_modules/homebridge-rasppi-gpio-garagedoor/index.js:70:15)
at Object.RaspPiGPIOGarageDoorAccessory.initService (/usr/local/lib/node_modules/homebridge-rasppi-gpio-garagedoor/index.js:51:25)
at Object.RaspPiGPIOGarageDoorAccessory (/usr/local/lib/node_modules/homebridge-rasppi-gpio-garagedoor/index.js:23:8)
at Server._loadAccessories (/usr/local/lib/node_modules/homebridge/lib/server.js:244:29)
at Server.run (/usr/local/lib/node_modules/homebridge/lib/server.js:72:38)
at module.exports (/usr/local/lib/node_modules/homebridge/lib/cli.js:40:10)
at Object. (/usr/local/lib/node_modules/homebridge/bin/homebridge:17:22)
pi@raspberrypi:~ $

Code for HAP-NodeJS

Hello Everyone,
Your code is very usefull thank you.
I'm using HAP-NodeJS. Can you can your code to use in accessory for HAP-NodeJS?
Actually I tried but I cannot.
Thank You.

cant find GPIO directory?

hi,
currently trying to get this plugin to work but give's me this error. i am fairly new to raspberry's so i must be doing something wrong here. anybody any idea's
Error: ENOENT: no such file or directory, open '/sys/class/gpio/gpio24/value'
at Object.openSync (fs.js:443:3)
at Object.readFileSync (fs.js:343:35)
at RaspPiGPIOGarageDoorAccessory.readPin (/usr/local/lib/node_modules/homebridge-rasppi-gpio-garagedoor/index.js:149:26)
at RaspPiGPIOGarageDoorAccessory.isClosed (/usr/local/lib/node_modules/homebridge-rasppi-gpio-garagedoor/index.js:158:21)
at RaspPiGPIOGarageDoorAccessory.initService (/usr/local/lib/node_modules/homebridge-rasppi-gpio-garagedoor/index.js:124:25)
at new RaspPiGPIOGarageDoorAccessory (/usr/local/lib/node_modules/homebridge-rasppi-gpio-garagedoor/index.js:66:8)
at config.accessories.forEach (/usr/local/lib/node_modules/homebridge/src/server.ts:357:50)
at Array.forEach ()
at Server._loadAccessories (/usr/local/lib/node_modules/homebridge/src/server.ts:330:29)
at Server.start (/usr/local/lib/node_modules/homebridge/src/server.ts:156:12)

i use
node.js v10.19.0
NPM v6.14.5
if that helps

Thanks,
Michel

Plugin and Eve Door/Window Sensor communication

Hi

I'm using an Elgato Eve Door and Window Sensor (which is HomeKit capable) to determine if my garage is open or closed.
Any idea how to implement the state of the Eve Sensor into the plugin. So that the plugin switch knows from the Eve sensor when my garage is opened or closed?

I thought about something like a second switch from the plugin which is just there to tell the plugin if the door is opened or closed. The second switch would be triggered by the eve door sensor via automation. Is this possible?

Thanks in advance

Help with GPIO Pin Permissions

Hi all, I think I know what the problem is but can't seem to find a way to fix it.

I don't think I have permissions and I don't think I run Homebridge as root. When I try to the accessories don't show up. So when I try to open my garage door I get this error

[2/12/2017, 8:32:50 PM] Homebridge is running on port 51929.
[2/12/2017, 8:32:54 PM] [Garage Door] GarageDoor is CLOSED (1)
[2/12/2017, 8:33:02 PM] [Garage Door] GarageDoor is CLOSED (1)
[2/12/2017, 8:33:02 PM] [Garage Door] Setting state to 0
[2/12/2017, 8:33:02 PM] [Garage Door] Triggering GarageDoor Relay
fs.js:549
  return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
                 ^

Error: EACCES: permission denied, open '/sys/class/gpio/gpio4/value'
    at Error (native)
    at Object.fs.openSync (fs.js:549:18)
    at Object.fs.writeFileSync (fs.js:1155:15)
    at Object.RaspPiGPIOGarageDoorAccessory.setState (/usr/local/lib/node_modules/homebridge-rasppi-gpio-garagedoor/index.js:103:12)
    at emitMany (events.js:108:13)
    at emit (events.js:182:7)
    at Characteristic.setValue (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Characteristic.js:155:10)
    at Bridge.<anonymous> (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Accessory.js:727:22)
    at Array.forEach (native)
    at Bridge.Accessory._handleSetCharacteristics (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Accessory.js:672:8)
    at emitMany (events.js:108:13)
    at HAPServer.emit (events.js:182:7)
    at HAPServer._handleCharacteristics (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/HAPServer.js:967:10)
    at HAPServer.<anonymous> (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/HAPServer.js:204:39)
    at emitNone (events.js:67:13)
    at IncomingMessage.emit (events.js:166:7)
    at endReadableNT (_stream_readable.js:893:12)
    at doNTCallback2 (node.js:429:9)
    at process._tickCallback (node.js:343:17)

If I run these commands at terminal gpio export 14 in & gpio export 4 out BEFORE I try to open the garage then all works as expected. Unfortunately sometimes my Pi restarts then when someone tries to open the garage door the above error happens. I have made a script with the above commands in and if I run that from terminal then it all works. I just can't find a way to run said script automatically at boot up. I have tried various ways, including the crontab. Any ideas?

Cheers!!!

Opening and Closing with the same value

My approach to opening my garage is a little different.
I'm not using a relay but a simple remote which has one key that opens or closes my garage.
(at the moment, my remote in combination with this plugin only triggers when I open the garage via homekit)

What changes to the code would be necessary that the plugin uses doorswitchvalue 1 when opening and also closing?
Resetting the GPIO value from 1 to 0 after each trigger is not a problem as I am doing this via automation.

thanks in advance.

edit: nevermind, got it.

suggestion

would it not be better to use wiring pi so homebridge can be run as any user, and no need for root?
the sensor pins appears to be left floating if I read your script correctly, using either pullup or pulldown will avoids false signals.

door lock

hi @benlamonica i have a big request!!!!!
if possible you can make homebridge for door lock using servo. instead relay will use servo or stepped motor and little limit switches for know lock or unlock. plus one button to open and close manually and led green and red for know status.
thanks

Just GPIO controls..

Hi,
This is not an issue. But would you be making a plugin for a very basic GPIO controls alone? Like switching them ON and OFF from HomeKit app.

Other usage: burglar alarm system

Hi all, this is not an issue but more a request:

I would like to use exactly the way this plugin works for my security system. Arm/disarm it with a relay (pulse or toggle the relay, doesn't matter) and having a feedback to a GPIO pin to monitor if the system is armed or disarmed (my alarmsystem has relays also). So basicaly like a garagedoor. The only thing I would like that Homekit sees it as an alarmsystem instead of a door and say arm/disarm instead of open/close. It this something I could change myself? I.e. change the name and function somewhere in the code? Thanks in advance to anyone who can help me.

Further developing the script

Hi,

I would like to develop to script more completely with two relays & two relay sensors for garage door, and add one relay for the gate.

I have two relays for garage door and would like to mange the door more specifically through them:

  1. Action (1 second high duration) - Close door
  2. Action (1 second high duration) - Open door

I have two relay sensors giving status from the garage door, and would like to sense the door status specifically through them:

  1. Status - Door is closed
  2. Status - Door is open

Also I have relay to manage the gate:

  1. Action (1 second high duration) - Open the gate
    The gate is closing after few minutes automatically, if not blocked permanently with 2. Action
  2. Action (keep high) - Block the gate open

Would highly appreciate your advise how to develop and complete the script to manage this more granular set-up.

Janis

Triggering Relay but Garage Door Doesn't Open

First of all thank you for creating this plugin! I've followed your readme and have gotten to the point where when I press the garage door button in HomeKit the relay fires but my garage door doesn't open. I have my relay module wired for NO and the light goes on for 1 second. Am I missing something in the wiring process? I've seen so many different wiring diagrams on how to do this. Any help would be much appreciated. I've also included pictures and config for reference.

https://imgur.com/a/SV2aM

"accessories": [
   {
       "accessory": "RaspPiGPIOGarageDoor",
       "name": "Garage",
       "doorSwitchPin": 23,
       "doorSwitchPressTimeInMs": 1000,
       "doorSwitchValue": 1,
       "closedDoorSensorPin": 24,
       "closedDoorSensorValue": 1,
       "openDoorSensorPin": 25,
       "openDoorSensorValue": 1,
       "doorPollInMs": 4000,
       "doorOpensInSeconds": 14
   }

Controller with separate switches

Can somebody advice me what i can do if my garage have two switches - one for open, and other for close? i ask manufacturer and only that mode is work - two buttons only.

Trouble with closed and open sensor

Hello, i recently tried to add a second sensor to my config i cannot seem to get it to work i belive its only using one sensor and not 2. this was my original config.

"accessories": [{
"accessory": "RaspPiGPIOGarageDoor",
"name": "Garage Door",
"doorSwitchPin": 5,
"doorSwitchPressTimeInMs": 1000,
"doorSwitchValue": 1,
"closedDoorSensorPin": 20,
"closedDoorSensorValue": 1,
"doorPollInMs": 4000,
"doorOpensInSeconds": 12
}],

i have now switched it over too

"accessories": [{
"accessory": "RaspPiGPIOGarageDoor",
"name": "Garage Door",
"doorSwitchPin": 5,
"doorSwitchPressTimeInMs": 1000,
"doorSwitchValue": 1,
"closedDoorSensorPin": 24,
"closedDoorSensorValue": 1,
"openDoorSensorPin": 25,
"openDoorSensorValue": 1,
"doorPollInMs": 4000,
"doorOpensInSeconds": 12
}],

the service runs fine but i feel like its only working on the closed door sensor only. when there is contact it says its closed but when i remove the contact it says its open regardless of the open door sensor.

Having trouble with sensor

I am having an issue with the plugin not reading my door state correctly. When it is closed it is fine, when I open it, it sets to open, then immediately sets to closed again. I have tried toggling the closedDoorSensorValue with no effect. Any thoughts?

When the door is open:
pi@raspberrypi ~ $ gpio read 12
1

When closed:
pi@raspberrypi ~ $ gpio read 12
0

My config:
{
"bridge": {
"name": "Homebridge",
"username": "CC:22:3D:E3:CE:30",
"port": 51826,
"pin": "053-73-874"
},

"accessories": [{
    "accessory": "RaspPiGPIOGarageDoor",
    "doorSwitchPin": 7,
    "closedDoorSensorPin": 12,
    "closedDoorSensorValue": 0,
    "doorPollInMs": 4000,
    "doorOpensInSeconds": 18,
    "name": "Garage Door"
}],

"platforms": [
    {
        "platform" : "LifxLan",
        "name" : "LIFX"
    }
]

}

[Sun Jan 15 2017 00:23:09 GMT+0000 (UTC)] Homebridge is running on port 51826.
[Sun Jan 15 2017 00:23:10 GMT+0000 (UTC)] [LIFX] Online: Entrance 3 [d073d5208bfc]
[Sun Jan 15 2017 00:23:10 GMT+0000 (UTC)] [LIFX] Online: Entrance 1 [d073d5206f76]
[Sun Jan 15 2017 00:23:15 GMT+0000 (UTC)] [LIFX] Online: Entrance 2 [d073d5208bf3]
[Sun Jan 15 2017 00:23:32 GMT+0000 (UTC)] [Garage Door] GarageDoor is CLOSED (1)
[Sun Jan 15 2017 00:23:33 GMT+0000 (UTC)] [Garage Door] Setting state to 0
[Sun Jan 15 2017 00:23:33 GMT+0000 (UTC)] [Garage Door] Triggering GarageDoor Relay
[Sun Jan 15 2017 00:23:33 GMT+0000 (UTC)] [Garage Door] Turning on GarageDoor Relay, pin 7 = 1
[Sun Jan 15 2017 00:23:34 GMT+0000 (UTC)] [Garage Door] Turning off GarageDoor Relay, pin 7 = 0

** Right here **
[Sun Jan 15 2017 00:23:51 GMT+0000 (UTC)] [Garage Door] Set current state to OPEN
[Sun Jan 15 2017 00:23:53 GMT+0000 (UTC)] [Garage Door] Door state changed to CLOSED
[Sun Jan 15 2017 00:24:19 GMT+0000 (UTC)] [Garage Door] Setting state to 1
[Sun Jan 15 2017 00:24:34 GMT+0000 (UTC)] [Garage Door] GarageDoor is CLOSED (1)
[Sun Jan 15 2017 00:24:35 GMT+0000 (UTC)] [Garage Door] Setting state to 0
[Sun Jan 15 2017 00:24:35 GMT+0000 (UTC)] [Garage Door] Triggering GarageDoor Relay
[Sun Jan 15 2017 00:24:35 GMT+0000 (UTC)] [Garage Door] Turning on GarageDoor Relay, pin 7 = 1
[Sun Jan 15 2017 00:24:36 GMT+0000 (UTC)] [Garage Door] Turning off GarageDoor Relay, pin 7 = 0

** Right here **
[Sun Jan 15 2017 00:24:53 GMT+0000 (UTC)] [Garage Door] Set current state to OPEN
[Sun Jan 15 2017 00:24:57 GMT+0000 (UTC)] [Garage Door] Door state changed to CLOSED
[Sun Jan 15 2017 00:25:07 GMT+0000 (UTC)] [Garage Door] Setting state to 1
[Sun Jan 15 2017 00:26:25 GMT+0000 (UTC)] [Garage Door] GarageDoor is CLOSED (1)
[Sun Jan 15 2017 00:31:26 GMT+0000 (UTC)] [Garage Door] GarageDoor is CLOSED (1)
[Sun Jan 15 2017 00:31:28 GMT+0000 (UTC)] [Garage Door] Setting state to 0
[Sun Jan 15 2017 00:31:28 GMT+0000 (UTC)] [Garage Door] Triggering GarageDoor Relay
[Sun Jan 15 2017 00:31:28 GMT+0000 (UTC)] [Garage Door] Turning on GarageDoor Relay, pin 7 = 1
[Sun Jan 15 2017 00:31:29 GMT+0000 (UTC)] [Garage Door] Turning off GarageDoor Relay, pin 7 = 0

** Right here **
[Sun Jan 15 2017 00:31:46 GMT+0000 (UTC)] [Garage Door] Set current state to OPEN
[Sun Jan 15 2017 00:31:46 GMT+0000 (UTC)] [Garage Door] Door state changed to CLOSED
[Sun Jan 15 2017 00:32:51 GMT+0000 (UTC)] [Garage Door] GarageDoor is CLOSED (1)

Homebridge not starting

Anyone having issues with Geek Slant Smart Garage since updating to iOS 13? My setup was working fine until 13 then iPhone would respond by stating “you have more than one garage door. Ask me again with a specific room or device name”. This is after I’ve asked for Siri to open/close right garage door. I’ve rebooted rpi and deleted the bridge from my phone and now can’t find it again. Now I get this error.

Screenshot 2019-11-09 at 19 23 40

doorSensorPin-less

My current setup doesn't have a doorSensorPin and it appears that the script isn't happy with me because of it. Do I run a magnetic switch to overcome this or is there a better way around.

Secondly, running into what I think is a 'root' issue with the GPIO. The relay I've confirmed works when I

pi@homebridge:~ $ gpio write 7 1
pi@homebridge:~ $ gpio mode 7 out 
pi@homebridge:~ $ gpio mode 7 in

Any suggestions to what I'm doing wrong? Cheers

Enhancement: Gate Control

First off- thanks for the great plugin. I have it working on my garage and it is flawless.

My question for you is how hard would it be to have a version that didn't look for open/close sensors and just automatically defaulted to "closed" after a few seconds?

The reason I ask is because I have both a perimeter access gate and a garage door. The gate is too far away to wire up an open/closed sensor and it really doesn't matter since the gate automatically closes after about 30 seconds. It would be great if I could use the plugin to open the gate and have it just default back to closed after a set amount of time.

GPIO output goes to high on startup

When the garage-door-gpio script runs at startup it turns the pins to High which keeps the closed. When I initiate an open or close the door it initiates the one second pulse but still keeps the circuit closed. This is problematic due to the fact that if there is a power failure and the Pi restarts it automatically will open my garage and my multifunction control panel is not working as it is not expecting the line to be always on.

Help!

Crash when triggering relay

Hi

Bit of a noob but I am getting the following error when trying to operate the relay. Any idea as to what is wrong?

[Mon Oct 10 2016 12:38:00 GMT+0000 (UTC)] Homebridge is running on port 51826.
[Mon Oct 10 2016 12:38:26 GMT+0000 (UTC)] [Garage Door] GarageDoor is CLOSED (1)
[Mon Oct 10 2016 12:38:32 GMT+0000 (UTC)] [Garage Door] Setting state to 0
[Mon Oct 10 2016 12:38:32 GMT+0000 (UTC)] [Garage Door] Triggering GarageDoor Relay
fs.js:663
return binding.writeBuffer(fd, buffer, offset, length, position);
^

Error: EPERM: operation not permitted, write
at Error (native)
at Object.fs.writeSync (fs.js:663:20)
at Object.fs.writeFileSync (fs.js:1170:24)
at Object.RaspPiGPIOGarageDoorAccessory.setState (/usr/local/lib/node_modules/homebridge-rasppi-gpio-garagedoor/index.js:103:12)
at emitMany (events.js:108:13)
at emit (events.js:182:7)
at Characteristic.setValue (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Characteristic.js:155:10)
at Bridge. (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Accessory.js:727:22)
at Array.forEach (native)
at Bridge.Accessory._handleSetCharacteristics (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Accessory.js:672:8)

HOOBS not starting

After configuring the accessory, HOOBS could not start. This plugin alone would be a great selling point for home owners if it worked.

echo [pin#] /sys/class/GPIO/export no longer works

I've been happily using homebridge-rasppi-gpio-garagedoor for a few years now, to monitor and control my two garage doors. Thanks for the really useful plug-in.

Unfortunately it looks like the latest update to Raspi OS has finally broken the /sys/class/gpio/ method for setting & getting GPIO pin states.
$ uname -a
$ Linux raspi 6.6.20+rpt-rpi-v8 #1 SMP PREEMPT Debian 1:6.6.20-1+rpt1 (2024-03-07) aarch64 GNU/Linux
$ sudo echo 17 > /sys/class/gpio/export
echo: write error: Invalid argument

I think the OS kernel change to 6.6.20 is what's broken things. My research suggests that there's a need to change to using pinctrl or to replace RPi.GPIO with rpi-lgpio. The second is a bit of a guess, based on the assumption that the sys/class/gpio method relies on RPi.GPIO. But I'm a rank amateur so I may well be wrong on both fronts.

Hope you're still watching over this!

clarification on in/out, low/high gpio

I have 2 garage doors
using normally closed relays
I chose pins that don't activate on raspberry pi boot.
also using magnetic reed switch to detect if doors are closed

I'm having trouble configuring the pins correctly in the garage-door-gpio script in /var/lib/homebridge/garage-door-gpio

can anyone explain what needs to be done here?

function export_pin {
if [ ! -e /sys/class/gpio/gpio${1} ] ; then
echo $1 > /sys/class/gpio/export
if [ "$3" == "low" ] ; then
echo 1 > /sys/class/gpio/gpio${1}/active_low
else
echo 0 > /sys/class/gpio/gpio${1}/active_low
fi
echo $2 &gt; /sys/class/gpio/gpio${1}/direction
if [ "$2" == "out" ] ; then
echo $4 &gt; /sys/class/gpio/gpio${1}/value
fi
fi
}

function unexport_pin {
if [ -e /sys/class/gpio/gpio${1} ] ; then
echo $1 > /sys/class/gpio/unexport
fi
}

if [ "$1" == "start" ] ; then
log_daemon_msg "Enabling Garage Door GPIO pins for door 0"
export_pin 24 out low 0
export_pin 22 in high 0
log_end_msg 0

log_daemon_msg "Enabling Garage Door GPIO pins for door 1"
export_pin 23 out low 0
export_pin 27 in high 0
log_end_msg 0
else [ "$1" == "stop" ]
log_daemon_msg "Disabling Garage Door GPIO pins for door 0"
unexport_pin 24
unexport_pin 22

log_daemon_msg "Disabling Garage Door GPIO pins for door 1"
unexport_pin 23
unexport_pin 27
fi

Homekit Controller in Home Assistant issue

I would like to get this plugin to work with Homekit Controller in HomeAssistant. However, it require unique serial number for each accessory.

The current set up for this plugin use the same serial number for all the accessories setup in the config file
.setCharacteristic(Characteristic.SerialNumber, "Version 1.0.0");

can you make the change to so that we use the accessory name as serial number
like this
.setCharacteristic(Characteristic.SerialNumber, "Garage Door 1");
.setCharacteristic(Characteristic.SerialNumber, "Garage Door 2");

this way it, if we have two garage doors and it has unique serial for each one

It is an easy update and fix. and it will benefit everyone who still using your plugin.

change switching value of relay / make it configurable

Hi benlamonica,

I like your module very much. But I'd like to change the switching value of the relay-switch. With the current settings, the relay switches when it's powerless, so when the rasppi reboots, my garage door opens.

I switched the value in #74 to 1 and in #103 to 0 in the configuration. so the door stays closed when the system is powerless...

Thanks!
Michael

simply open a gate

hi, sorry for my English,
I have to open 2 gates with raspberry pi connected to a relay.
The relay is connected to the remote control and when it closes the contacts starts the pulse. I would like to use this plugin but do not know how to set up the garage-door-gpio script also not needing the sensors for closed door and open door, can i completely eliminate them from config.json?
ok just resolved, never mind...

Close notification issue

When I ask Siri to close the garage I receive this: "garage was opened" and after close say "garage was closed" when I open show correct but just when I close the first notification show opened inter closed.
Any one having this problem?

GPIO pin number

Doubt this was just me, but phyisical pin doesn't mean the same thing as "gpio"

I was trying to get this wired up and I went with "physical" 12 for the closed sensor. but that is gpio1

Anyways, I still can't make it work so there's probably still some PEBKAC on my part.

Suggestion: Make this work with MQTT

You don't always have the raspberry pi that is running Homebridge near your garage door. Make the exact plugin compatible with MQTT. It would be easy to run tasmota on a ESP board, attach the needed relay and sensors to the ESP.
There is no such an MQTT garage door plugin yet.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.