ebaauw / homebridge-rpi

Homebridge plugin for Raspberry Pi.
Apache License 2.0
311 stars 19 forks source link

Lock opens when rebooting the Rpi #144

Closed Olivierbkk closed 2 years ago

Olivierbkk commented 2 years ago

Hi, when I reboot the RPi the lock goes through a cycle of open/close which is causing my door to open. Is there a way to do not have this to happen? I use this feature to activate a relay that acts like a push button, each time you press the button it opens or close the door depending on its curent state.

here is the boot up log [20/09/2022, 18:33:16] [RPi] raspberrypi Gate: set Lock Target State from 1 to 0 [20/09/2022, 18:33:17] [RPi] raspberrypi Gate: set Lock Current State from 1 to 0 [20/09/2022, 18:33:17] [RPi] raspberrypi Gate: set Lock Target State from 0 to 1 [20/09/2022, 18:33:17] [RPi] raspberrypi Gate: set Lock Current State from 0 to 1

Here is the device setting "devices": [ { "device": "lock", "name": "Gate", "gpio": 18, "reversed": true, "pulse": 500 },

ebaauw commented 2 years ago

Make sure you set the correct GPIO state on boot, see https://github.com/ebaauw/homebridge-rpi/wiki/Supported-Devices#device-state, last paragraph.

Olivierbkk commented 2 years ago

Thanks for the very quick answer! I checked in the /boot/config.txt and there is not specific settings for GPIO state on boot. I have tried GPIO 8 and GPIO 18 with "reverse" true and false, all possible combinations... I have tried lock device type and switch devide type (actually switch is probably more appropriate as on the hardware side we really have only a push button, the relay connected to the Pi is in parallel with the push button) When I restart the server, some combination do not open the gate but as soon as I reboot the Pi the relay is activated for a short while and the gate opens. Perhaps you have a bullet proof way to set this up ... for dummies ;-)

ebaauw commented 2 years ago

I checked in the /boot/config.txt and there is not specific settings for GPIO state on boot.

No, so the GPIO defaults to low on boot, which activates the relay. When Homebridge RPi starts, it resets the GPIO to high (because of the reverse and pulse settings) after 500ms (the value of pulse).

Perhaps you have a bullet proof way to set this up ...

You need to add the appropriate line to /boot/config.txt, so that the GPIO defaults to high on boot, see https://www.raspberrypi.com/documentation/computers/config_txt.html#gpio-control

This concerns the (boot) configuration of your Raspberry Pi, and has nothing to do with the Homebridge RPi configuration.

Olivierbkk commented 2 years ago

That works like a charm... Thank you Sir for your kindness to assist a Noob