Homebridge-eDomoticz & Push Button selector switches (SwitchTypeVal 18)
Posted: Saturday 03 February 2018 14:06
Right - pushbutton support for HomeKit - here's the issue. The selector switch type used by physical push buttons is also used for many other types of device. Eg: I have a selector switch type in Domoticz that handles all the modes on my TV and has 7 states.
From what I can tell, push buttons (single tap / dbl tap / long tap - 3 states) are also being used in Domoticz as Selector Switches, and show up in the JSON API as SwitchTypeVal 18. (Head to Domoticz.ip/json.htm?type=devices&rid=[device idx] to confirm)
Enabling this patch results in ALL selector switches showing up in HomeKit with the ability to be used as a trigger, but only on the first three selector levels (ie: level 10, 20 and 30 when you edit the switch in Domoticz). So for those of you without Physical Push Buttons who like me have selector switches being used for other purposes within Domoticz, don’t get excited. This patch isn’t to enable the full level of functionality of selector switches...
Anyways, the selector switch type logically maps to HomeKit's Stateless Programmable Switch type. This is the only service type suitable and made available to us by Apple, and accepts 3 levels: 0, 1, 2. These are READ ONLY characteristics. They will appear as sensors, not controls, and will reflect whatever they're set to from Domoticz, BUT you would NOT be able to interact with them / use them to control that device from HomeKit. These 3 levels map to levels 10, 20 and 30 within Domoticz. Level 0 / Off doesn’t factor into the equation at the HomeKit end.
All this does is allow you to assign the single / dbl / long tap (or the action of changing a selector switch from level 10 to 20 to 30) to trigger another already existing switch in HomeKit, or a Scene.
So... all that said, I’ve just pushed 2.1.6 up to NPM which maps selector switches into HomeKit so that you CAN use your physical button as a HomeKit trigger, rather than as a Domoticz-native trigger... so, push-button support: done.
Once added, tap and hold on the button in Home.app and tap details to configure what actions trigger what switches / scenes.
For users with Selector Switches in general (not related to Physical Push Buttons) who want full functionality of all the selector levels available from within Homekit, the solution is simple(ish) - you need to create virtual switches in Domoticz for each button's state, and set the on actions to target the selector switch via Domoticz' http api - see https://www.domoticz.com/wiki/Domoticz_ ... tor_Switch
These virtual switches should be left as switches if your button device is set with the switch select type, or set as Push On switches if your button device is set with the button select type (and add a value in the off delay field in Domoticz so they flip off after being selected)
Edit your button devices selector switch to find which it's currently set to.
If switch select type, you then need to head to Domoticz events and create blocky if do else if do scripts to handle turning the other virtual switches off when you turn one on, and to ensure that the virtual switches represent the button devices selector state when it's been changed with your physical button.
The virtual switches will then be picked up in HomeKit and function correctly / as appropriate for however you've configured your virtual switches / blocky events.
From what I can tell, push buttons (single tap / dbl tap / long tap - 3 states) are also being used in Domoticz as Selector Switches, and show up in the JSON API as SwitchTypeVal 18. (Head to Domoticz.ip/json.htm?type=devices&rid=[device idx] to confirm)
Enabling this patch results in ALL selector switches showing up in HomeKit with the ability to be used as a trigger, but only on the first three selector levels (ie: level 10, 20 and 30 when you edit the switch in Domoticz). So for those of you without Physical Push Buttons who like me have selector switches being used for other purposes within Domoticz, don’t get excited. This patch isn’t to enable the full level of functionality of selector switches...
Anyways, the selector switch type logically maps to HomeKit's Stateless Programmable Switch type. This is the only service type suitable and made available to us by Apple, and accepts 3 levels: 0, 1, 2. These are READ ONLY characteristics. They will appear as sensors, not controls, and will reflect whatever they're set to from Domoticz, BUT you would NOT be able to interact with them / use them to control that device from HomeKit. These 3 levels map to levels 10, 20 and 30 within Domoticz. Level 0 / Off doesn’t factor into the equation at the HomeKit end.
All this does is allow you to assign the single / dbl / long tap (or the action of changing a selector switch from level 10 to 20 to 30) to trigger another already existing switch in HomeKit, or a Scene.
So... all that said, I’ve just pushed 2.1.6 up to NPM which maps selector switches into HomeKit so that you CAN use your physical button as a HomeKit trigger, rather than as a Domoticz-native trigger... so, push-button support: done.
Once added, tap and hold on the button in Home.app and tap details to configure what actions trigger what switches / scenes.
For users with Selector Switches in general (not related to Physical Push Buttons) who want full functionality of all the selector levels available from within Homekit, the solution is simple(ish) - you need to create virtual switches in Domoticz for each button's state, and set the on actions to target the selector switch via Domoticz' http api - see https://www.domoticz.com/wiki/Domoticz_ ... tor_Switch
These virtual switches should be left as switches if your button device is set with the switch select type, or set as Push On switches if your button device is set with the button select type (and add a value in the off delay field in Domoticz so they flip off after being selected)
Edit your button devices selector switch to find which it's currently set to.
If switch select type, you then need to head to Domoticz events and create blocky if do else if do scripts to handle turning the other virtual switches off when you turn one on, and to ensure that the virtual switches represent the button devices selector state when it's been changed with your physical button.
The virtual switches will then be picked up in HomeKit and function correctly / as appropriate for however you've configured your virtual switches / blocky events.