ebaauw / homebridge-rpi

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

Add support for Switch inputPin #140

Closed brancooo1 closed 1 year ago

brancooo1 commented 1 year ago

First of all, thanks for your work on this plugin. I've searched the history for a solution to this problem, but I ended up writing a new request.

There are cases where devices are switched on and off by pulse and on another pin you monitor the status of the device. This is also the case for standard installation pulse relays. A switch on the wall creates a pulse that changes the state of the pulse relay.

I think the solution would be an optional parameter inputPin, which if filled would serve as a mirroring for the switch state. Now obsolete homebridge-gpio-device plugin had a very similar approach, notice the configuration.

With debouncing it can work very nicely, for example with a configuration like this. What do you think about it, thanks for your opinion.

{
     "device": "switch",
     "name": "Kitchen Light",
     "gpio": 18,
     "pulse": 500,
     "inputPin": 20
}
Screenshot 2022-08-28 at 10 04 26
ebaauw commented 1 year ago

There are cases where devices are switched on and off by pulse and on another pin you monitor the status of the device.

Please link a fact sheet for such device. Afaik, these are electronic switches that work on mains power, for the output as well as for the input pulse, very much like the device you show in the picture. You cannot connect these directly to the Raspberry Pi's GPIO pins (they use 3.3V DC, not 240V AC).

I suppose you could use a switch with a relay connected to an output GPIO pin to drive the pulse, but I'm not sure how to monitor the output signal of the device. You'd need like a reverse relay, using 240V AC as input to switch 3.3V DC to the input GPIO pin. I seriously recommend against driving 240V relays from a Raspberry Pi. It's probably safer and easier to use a Zigbee switch module.

Even if you would manage to build such an integration, I won't be supporting home grown devices using multiple GPIO pins in Homebridge RPi.

brancooo1 commented 1 year ago

I find it an important use case when you want to control the light from the app but also from the wall. Synchronize states is necessary. Another example is if you have any device and want to control it from both, HomeKit and from a physical button. Another example is basically any garage door - which could become also supported thanks to this small feature (https://github.com/ebaauw/homebridge-rpi/issues/76 by camrun91, https://github.com/ebaauw/homebridge-rpi/issues/128 by @inzan3 ).

The device in the picture (standard installation pulse relay) has a control circuit at 24/110/230V etc, this is the standard for control circuit wiring in new buildings with smart home wirings. But because of the savings on transformers, a 240V AC control voltage is often used. But this is basically just a hardware implementation detail...

Here's datasheet for installation impulse relay from picture, which confirms what I say. I have same in my home, trying to connect it to HomeBridge: https://image.schrackcdn.com/datenblaetter/h_lq6-----_de.pdf

You never connect 230V directly to the Raspberry, that's what the optocoupler is for. And for the RPi output to 230V a relay with optocouplers are used.

There have as well been requests in the last year to add this feature to homebridge-rpi: https://github.com/ebaauw/homebridge-rpi/issues/82

I also add an implemented example request from a similar but unfortunately old plugin. To expand horizons: https://github.com/dubocr/homebridge-gpio-device/issues/38

ebaauw commented 1 year ago

So you're building a custom solution using the impulse replay and some optocouplers. As I said, I won't be supporting that from Homebridge RPi.

brancooo1 commented 1 year ago

Hm, I wonder what's behind your stubbornness not to extend the plugin in the direction so many users are asking for..I'm a bit sorry, considering the potential.

ebaauw commented 1 year ago

My stubbornness? I don't think you appreciate how open source works. I write my Homebridge plugins in my free time, for my own benefit, automating my home. Because I really appreciate the open source software I base my home automation on, I publish my code on GitHub, so others might benefit from it. I'm not providing any product nor service to anyone. I am under no obligation, morally, legally, or otherwise to extend my plugin because someone, of even a lot of someones, sees some potential. If you think this is an important case, you're more than welcome to copy my code, and implement it yourself.