ebaauw / homebridge-rpi

Homebridge plugin for Raspberry Pi.
Apache License 2.0
308 stars 18 forks source link

rocker to locally control a light #154

Closed Olivierbkk closed 1 year ago

Olivierbkk commented 1 year ago

Would it be possible to expand the functionality of the rocker switch to control an output GPIO locally on the raspberry pi without the need to make an automation in homekit?

I just did it with an ESP32 and the HomeSpan library, the advantages are that I can turn the light on/off with the physical switch even if the wifi or homekit are down and there is no noticeable latency when using the physical switch. Note that only the light is exposed to HomeKit, not the switch, and the light can of course be turned on/off from HomeKit.

ebaauw commented 1 year ago

I always appreciate a fallback setup, where you can still operate your devices when your network or home automation systems are down. Especially, since HomeKit isn’t the most reliable ecosystem.

You would need to run something on the Pi that monitors the input GPIO, connected to the switch and controls the output GPIO, connected to the light. A very crude version would be a shell script using pigs to poll the input GPIO, but it would be cleaner to use a programme that actually subscribes to pigpiod notifications to receive an event when the input GPIO changes. You could probably re-use PigpioClient.js, if you write this in JavaScript.

In my view, Homebridge’s purpose is simply to expose devices to HomeKit. Any home automation runs in HomeKit or with the device, not in Homebridge nor in any Homebridge plugin. Also, as Homebridge RPi might run on a different server, connecting to the Pi over the network, it would not even be the correct place for a fallback function, as it would still depend on the network.

Olivierbkk commented 1 year ago

In my view, Homebridge’s purpose is simply to expose devices to HomeKit. Any home automation runs in HomeKit or with the device,

yes and no... I saw some homebridge plugins like garage doors using multiple GPIOs and some logic acting as what you call a device. Adding the fallback as I would like would be the same. And actually homebridge would still exposes the light to HK.

Anyway I understand your point of view and do not mean to argue here. I won't play around with the Raspberry pi code as I am not good enough for that and either continue with the automation in HK or add an ESP32 next to the Pi just for the light switches.

Thanks for the quick reply as usual.