homebridge-gpio-wpi2 icon indicating copy to clipboard operation
homebridge-gpio-wpi2 copied to clipboard

Feature Request: Stateful Programmable Switch

Open varna33 opened this issue 8 years ago • 7 comments

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';

varna33 avatar Mar 21 '17 09:03 varna33

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.

rsg98 avatar Mar 22 '17 17:03 rsg98

It is for critical (to control) or time based applications. Let me give specific example of Sauna heating:

  1. It is switched on by connecting switch for 500ms
  2. Sauna is then on for 4 hours, and is switching off automatically
  3. 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:

  1. One GPIO pin to trigger switch on/ off (attributes pin, switch triggering duration)
  2. One GPIO pin to detect real on/ off status (by reading reality, instead of assuming on/ off status from triggering switch pin)
  3. All showed to Homekit as single switch with real status - showing reality feedback of actual state, instead of assumptions
  4. 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?

varna33 avatar Mar 22 '17 20:03 varna33

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!

rsg98 avatar Mar 24 '17 17:03 rsg98

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?

varna33 avatar Mar 26 '17 16:03 varna33

I'll have a play with it with a view to adding support alongside the PWM stuff.

rsg98 avatar Mar 30 '17 19:03 rsg98

@rsg98 Hi, are you still working on this? I would like this feature too.

superjeng1 avatar Mar 30 '18 12:03 superjeng1

Any updates?

rpolenthon avatar May 18 '19 13:05 rpolenthon