homebridge-gpio-wpi2
homebridge-gpio-wpi2 copied to clipboard
Feature Request: Stateful Programmable Switch
I was thinking if there would be any chance to set up platform for Stateful Programmable Switch, combining one GPIO pin to drive relay, and another GPIO pin to read status?
This is Homebridge lib for it:
/**
- Service "Stateful Programmable Switch" */
Service.StatefulProgrammableSwitch = function(displayName, subtype) { Service.call(this, displayName, '00000088-0000-1000-8000-0026BB765291', subtype);
// Required Characteristics this.addCharacteristic(Characteristic.ProgrammableSwitchEvent); this.addCharacteristic(Characteristic.ProgrammableSwitchOutputState);
// Optional Characteristics this.addOptionalCharacteristic(Characteristic.Name); };
inherits(Service.StatefulProgrammableSwitch, Service);
Service.StatefulProgrammableSwitch.UUID = '00000088-0000-1000-8000-0026BB765291';
Could you explain a bit more about what you want to get it to do?
It sounds like you mean read-an-input > turn-on-an-output, which I think it something you can do using the Home App automation, rather than doing it directly on the Pi / Homebridge.
It is for critical (to control) or time based applications. Let me give specific example of Sauna heating:
- It is switched on by connecting switch for 500ms
- Sauna is then on for 4 hours, and is switching off automatically
- If Sauna heater has switched on, then it is connecting potential free relay to give feedback that heating in on, and when Sauna heater is off then it is disconnecting the potential free relay
Critical - electricity consumption, risk & need to know if really sauna is on through feedback to Home automation switch if it has 100% switching on (not only switch triggered) < controlled by GPIO pin connected to Sauna's connecting potential free relay Time based - when it has switched off automatically after 4 hours < GPIO pin is detecting off state Parallel non-automation triggered switching on/ off - control when/ or it has been switched on/ off from physical management panel
All that can be put in Homekit standard supported simple Stateful Programmable Switch:
- One GPIO pin to trigger switch on/ off (attributes pin, switch triggering duration)
- One GPIO pin to detect real on/ off status (by reading reality, instead of assuming on/ off status from triggering switch pin)
- All showed to Homekit as single switch with real status - showing reality feedback of actual state, instead of assumptions
- Stateful Programmable Switch is not the same presentation to Homekit logic as open/ close status of doors
Such switch would even be 100% relevant and simplified logic to trigger something like garage door opening/ closing, and show it's real status, or entrance gate opening/ closing and showing it's status, or many other cases.
What do you say?
Thanks - that makes sense, although I'll have to think through the best way to implement that (it might be a separate module, otherwise the config file could get difficult to manage.
I also wonder about how the circuit would need to be designed for the remaining failure modes - I wouldn't like to think that a Pi / Node / this module is being used in anything safety critical. The Pi could still crash leaving the GPIO pins in an unknown state, so the circuit design would need to cope with that.
However, the non critical use cases do look interesting - and would potentially remove the need for the nasty polling timeout hack to detect changes on output pins.
Still got the PWM support to finish first!
Yes, it would be great to create such module. I wish I knew how... :( On safety - people safety I wouldn't put it hand of RPI base system, but good control of on off switching with real life feedback, thus giving process control is enough.
I'm not so concerned on relays, as they come and fall back to default state. So, they are triggering on action while RPI is functioning, so crashing of ROI on GPIO pin shouldn't trigger any further actions.
Would you consider to put such code together?
I'll have a play with it with a view to adding support alongside the PWM stuff.
@rsg98 Hi, are you still working on this? I would like this feature too.
Any updates?