ebaauw / homebridge-rpi

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

[Feature request] Switch with status #82

Closed Joe2824 closed 3 years ago

Joe2824 commented 3 years ago

Is it possible to generate a new switch with an output and input to detect the current status of a device without having multiple contacts and switches?

ebaauw commented 3 years ago

No, it’s not, I’m afraid. You’d need to map the output GPIO pin to a target state, and the input pin to the current state. However, HomeKit doesn’t provide target vs current state on a stateful switch. You’d need to expose the device as something like a valve, window covering, or door lock.

What’s your use case? What device do you want to expose, and how is that connected to the GPIO pins?

Joe2824 commented 3 years ago

I want to control a Display. But I want to know if the display is on or off. My current setup is to use a switch and a separate contact to get the current state. Would be great if I could use a switch or a valve with an output and an input verify the current state without the extra contact.

But if this is not possible with the current HomeKit then it is just like that.

ebaauw commented 3 years ago

And the display can be off while the switch is on? How would you turn it on, then?

Joe2824 commented 3 years ago

Yes it could be. It’s a push button that turns the display on. Sometimes the Display needs a little bit time to boot. I bridge the switch with a transistor and get the on signal from the status led

ebaauw commented 3 years ago

So the output GPIO is like a stateless (pulse) switch, and the input GPIO provides the actual state. I don’t know any predefined HomeKit service that acts like this; normally this would be two different services in HomeKit. If you try and expose that as a single Switch service, it will act weirdly: after you turn it on, it reverts to off, then after a while it turns itself on. And I suppose, there’s no way to turn it off? Or similar weird behaviour (it reverts to on and then after a while turns itself off).

Joe2824 commented 3 years ago

Ah okay than I have to stick with my current setup. Thanks for your help. :)

{
    "device": "switch",
    "name": "Display",
    "gpio": 23,
    "pulse": 1000
},
{
    "device": "contact",
    "name": "Display ON",
    "gpio": 24
}