Homebridge-eDomoticz & Push Button selector switches (SwitchTypeVal 18)

Post Reply
User avatar
Marci
Posts: 521
Joined: Friday 22 January 2016 19:00
Target OS: Raspberry Pi
Domoticz version: 3.8153
Location: Wakefield, West Yorkshire UK
Contact:

Homebridge-eDomoticz & Push Button selector switches (SwitchTypeVal 18)

Post by Marci » Saturday 03 February 2018 15: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.
Extended Domoticz homebridge-plugin for latest Homebridge - adds temp/humidity/pressure sensors, power consumption sensors, DarkSkies virtual weather station support, YouLess Meter support, general % usage support & switch/lamp status checking!

islandman
Posts: 57
Joined: Saturday 05 August 2017 20:27
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Homebridge-eDomoticz & Push Button selector switches (SwitchTypeVal 18)

Post by islandman » Saturday 03 February 2018 18:57

Thanks for your work, however I have a strange behaving. I does not matter how i click (single, double, long) it always triggered long press in HomeKit (within 1 second) So it always only triggers long click. Oh and long click is triggering long click in HomeKit twice!
Attachments
screenshot_83.png
screenshot_83.png (178.46 KiB) Viewed 2108 times

User avatar
Marci
Posts: 521
Joined: Friday 22 January 2016 19:00
Target OS: Raspberry Pi
Domoticz version: 3.8153
Location: Wakefield, West Yorkshire UK
Contact:

Re: Homebridge-eDomoticz & Push Button selector switches (SwitchTypeVal 18)

Post by Marci » Saturday 03 February 2018 19:38

That’s probably your off reset (Abschaltverzogerung). Set to 0, otherwise it’ll transmit an off signal by mqtt which will trip things up.

Homebridge is listening for a single signal, regardless of your clicks. That single signal will contain either 10, 20 or 30, depending whether you single, double or triple click. The physical switch should talk to domoticz and trigger the change of the selector. The selector should then emit a single MQTT signal with the value of either 10, 20, or 30. If multiple things happen, multiple signals are being sent by Domoticz.

If setting Off timer to 0 doesn’t work you’ll need to run

Code: Select all

DEBUG=* homebridge -D
then fire your switch and look at what mqtt output is being received by homebridge. All works fine here.
Extended Domoticz homebridge-plugin for latest Homebridge - adds temp/humidity/pressure sensors, power consumption sensors, DarkSkies virtual weather station support, YouLess Meter support, general % usage support & switch/lamp status checking!

islandman
Posts: 57
Joined: Saturday 05 August 2017 20:27
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Homebridge-eDomoticz & Push Button selector switches (SwitchTypeVal 18)

Post by islandman » Saturday 03 February 2018 20:06

I did change to 0, still the same. Debug shows 10 HomeKit says LongClick

Single Click

Code: Select all

Name:		Alarm Button
Device:		Light/Switch,Selector Switch
Is Switch:	true
SwitchTypeVal:	18
MQTT Message:
{
    "Battery": 87,
    "LevelActions": "|||",
    "LevelNames": "Off|Click|Double Click|Long Click",
    "LevelOffHidden": "false",
    "RSSI": 12,
    "SelectorStyle": "0",
    "description": "",
    "dtype": "Light/Switch",
    "id": "01A3F835",
    "idx": 381,
    "name": "Alarm Button",
    "nvalue": 1,
    "stype": "Selector Switch",
    "svalue1": "10",
    "switchType": "Selector",
    "unit": 1
}
  EventedHTTPServer [::ffff:192.168.0.10] Sending HTTP event '63.10' with data: {"characteristics":[{"aid":63,"iid":10,"value":2}]} +5s
  EventedHTTPServer [::ffff:192.168.0.19] Sending HTTP event '63.10' with data: {"characteristics":[{"aid":63,"iid":10,"value":2}]} +2ms
  EventedHTTPServer [::ffff:127.0.0.1] New connection from client +5s
  EventedHTTPServer [::ffff:127.0.0.1] HTTP server listening on port 44671 +1ms
  EventedHTTPServer [::ffff:127.0.0.1] HTTP request: / +22ms
  HAPServer [CD:21:4D:E3:CE:32] HAP Request: GET / +1ms
  HAPServer [CD:21:4D:E3:CE:32] WARNING: Handler for / not implemented +1ms
  EventedHTTPServer [::ffff:127.0.0.1] HTTP Response is finished +3ms
  EventedHTTPServer [::ffff:127.0.0.1] HTTP connection was closed +28ms
  EventedHTTPServer [::ffff:127.0.0.1] HTTP server was closed +9ms
  EventedHTTPServer [::ffff:127.0.0.1] Client connection closed +1ms
  EventedHTTPServer [::ffff:127.0.0.1] New connection from client +10s
  EventedHTTPServer [::ffff:127.0.0.1] HTTP server listening on port 45141 +1ms
  EventedHTTPServer [::ffff:127.0.0.1] HTTP request: / +11ms
  HAPServer [CD:21:4D:E3:CE:32] HAP Request: GET / +1ms
  HAPServer [CD:21:4D:E3:CE:32] WARNING: Handler for / not implemented +1ms
  EventedHTTPServer [::ffff:127.0.0.1] HTTP Response is finished +2ms
  EventedHTTPServer [::ffff:127.0.0.1] HTTP connection was closed +15ms
  EventedHTTPServer [::ffff:127.0.0.1] HTTP server was closed +1ms
  EventedHTTPServer [::ffff:127.0.0.1] Client connection closed +1ms

douple Click

Code: Select all

Name:		Alarm Button
Device:		Light/Switch,Selector Switch
Is Switch:	true
SwitchTypeVal:	18
MQTT Message:
{
    "Battery": 87,
    "LevelActions": "|||",
    "LevelNames": "Off|Click|Double Click|Long Click",
    "LevelOffHidden": "false",
    "RSSI": 12,
    "SelectorStyle": "0",
    "description": "",
    "dtype": "Light/Switch",
    "id": "01A3F835",
    "idx": 381,
    "name": "Alarm Button",
    "nvalue": 1,
    "stype": "Selector Switch",
    "svalue1": "20",
    "switchType": "Selector",
    "unit": 1
}
  EventedHTTPServer [::ffff:192.168.0.10] Sending HTTP event '63.10' with data: {"characteristics":[{"aid":63,"iid":10,"value":2}]} +7s
  EventedHTTPServer [::ffff:192.168.0.19] Sending HTTP event '63.10' with data: {"characteristics":[{"aid":63,"iid":10,"value":2}]} +6ms
  EventedHTTPServer [::ffff:127.0.0.1] New connection from client +3s
  EventedHTTPServer [::ffff:127.0.0.1] HTTP server listening on port 39949 +1ms
  EventedHTTPServer [::ffff:127.0.0.1] HTTP request: / +8ms
  HAPServer [CD:21:4D:E3:CE:32] HAP Request: GET / +1ms
  HAPServer [CD:21:4D:E3:CE:32] WARNING: Handler for / not implemented +0ms
  EventedHTTPServer [::ffff:127.0.0.1] HTTP Response is finished +2ms
  EventedHTTPServer [::ffff:127.0.0.1] HTTP connection was closed +8ms
  EventedHTTPServer [::ffff:127.0.0.1] HTTP server was closed +1ms
  EventedHTTPServer [::ffff:127.0.0.1] Client connection closed +4ms

Long Click

Code: Select all

Name:		Alarm Button
Device:		Light/Switch,Selector Switch
Is Switch:	true
SwitchTypeVal:	18
MQTT Message:
{
    "Battery": 87,
    "LevelActions": "|||",
    "LevelNames": "Off|Click|Double Click|Long Click",
    "LevelOffHidden": "false",
    "RSSI": 12,
    "SelectorStyle": "0",
    "description": "",
    "dtype": "Light/Switch",
    "id": "01A3F835",
    "idx": 381,
    "name": "Alarm Button",
    "nvalue": 1,
    "stype": "Selector Switch",
    "svalue1": "30",
    "switchType": "Selector",
    "unit": 1
}
  EventedHTTPServer [::ffff:192.168.0.10] Sending HTTP event '63.10' with data: {"characteristics":[{"aid":63,"iid":10,"value":2}]} +4s
  EventedHTTPServer [::ffff:192.168.0.19] Sending HTTP event '63.10' with data: {"characteristics":[{"aid":63,"iid":10,"value":2}]} +2ms
[2018-2-3 14:08:09] [eDomoticz] MQTT Message received for Alarm Button.
Name:		Alarm Button
Device:		Light/Switch,Selector Switch
Is Switch:	true
SwitchTypeVal:	18
MQTT Message:
{
    "Battery": 87,
    "LevelActions": "|||",
    "LevelNames": "Off|Click|Double Click|Long Click",
    "LevelOffHidden": "false",
    "RSSI": 12,
    "SelectorStyle": "0",
    "description": "",
    "dtype": "Light/Switch",
    "id": "01A3F835",
    "idx": 381,
    "name": "Alarm Button",
    "nvalue": 1,
    "stype": "Selector Switch",
    "svalue1": "40",
    "switchType": "Selector",
    "unit": 1
}
  EventedHTTPServer [::ffff:192.168.0.10] Sending HTTP event '63.10' with data: {"characteristics":[{"aid":63,"iid":10,"value":2}]} +619ms
  EventedHTTPServer [::ffff:192.168.0.19] Sending HTTP event '63.10' with data: {"characteristics":[{"aid":63,"iid":10,"value":2}]} +1ms
  EventedHTTPServer [::ffff:127.0.0.1] New connection from client +1s
  EventedHTTPServer [::ffff:127.0.0.1] HTTP server listening on port 44957 +1ms
  EventedHTTPServer [::ffff:127.0.0.1] HTTP request: / +9ms
  HAPServer [CD:21:4D:E3:CE:32] HAP Request: GET / +0ms
  HAPServer [CD:21:4D:E3:CE:32] WARNING: Handler for / not implemented +1ms
  EventedHTTPServer [::ffff:127.0.0.1] HTTP Response is finished +2ms
  EventedHTTPServer [::ffff:127.0.0.1] HTTP connection was closed +9ms
  EventedHTTPServer [::ffff:127.0.0.1] HTTP server was closed +1ms
  EventedHTTPServer [::ffff:127.0.0.1] Client connection closed +2ms
  EventedHTTPServer [::ffff:127.0.0.1] New connection from client +10s
  EventedHTTPServer [::ffff:127.0.0.1] HTTP server listening on port 37225 +1ms
  EventedHTTPServer [::ffff:127.0.0.1] HTTP request: / +11ms
  HAPServer [CD:21:4D:E3:CE:32] HAP Request: GET / +0ms
  HAPServer [CD:21:4D:E3:CE:32] WARNING: Handler for / not implemented +1ms
  EventedHTTPServer [::ffff:127.0.0.1] HTTP Response is finished +2ms
  EventedHTTPServer [::ffff:127.0.0.1] HTTP connection was closed +9ms
  EventedHTTPServer [::ffff:127.0.0.1] HTTP server was closed +1ms
  EventedHTTPServer [::ffff:127.0.0.1] Client connection closed +3ms
[2018-2-
Last edited by islandman on Saturday 03 February 2018 20:42, edited 1 time in total.

User avatar
Marci
Posts: 521
Joined: Friday 22 January 2016 19:00
Target OS: Raspberry Pi
Domoticz version: 3.8153
Location: Wakefield, West Yorkshire UK
Contact:

Re: Homebridge-eDomoticz & Push Button selector switches (SwitchTypeVal 18)

Post by Marci » Saturday 03 February 2018 20:12

Have just pushed v2.1.9 with a few added break; cases... this may resolve.

Code: Select all

sudo npm update -g homebridge-edomoticz
nb: your long click needs to send 30 - looking at the above it’s sending 30 followed by 40.
Extended Domoticz homebridge-plugin for latest Homebridge - adds temp/humidity/pressure sensors, power consumption sensors, DarkSkies virtual weather station support, YouLess Meter support, general % usage support & switch/lamp status checking!

islandman
Posts: 57
Joined: Saturday 05 August 2017 20:27
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Homebridge-eDomoticz & Push Button selector switches (SwitchTypeVal 18)

Post by islandman » Saturday 03 February 2018 20:28

Did update again

Code: Select all

pi@raspberrypi:~ $ sudo npm update -g homebridge-edomoticz
/usr/lib
└── homebridge-edomoticz@2.1.9 
Still the same and yes there is a Stage 40 send release long click, I removed it but still sending the information.

islandman
Posts: 57
Joined: Saturday 05 August 2017 20:27
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Homebridge-eDomoticz & Push Button selector switches (SwitchTypeVal 18)

Post by islandman » Saturday 03 February 2018 20:43

Sorry always shows long click in HomeKit not double click, and if you actual use double click it release twice (maybe it sees the 40 long click release?)

User avatar
Marci
Posts: 521
Joined: Friday 22 January 2016 19:00
Target OS: Raspberry Pi
Domoticz version: 3.8153
Location: Wakefield, West Yorkshire UK
Contact:

Re: Homebridge-eDomoticz & Push Button selector switches (SwitchTypeVal 18)

Post by Marci » Saturday 03 February 2018 20:53

There should be no release. The selector should send ONLY send 10, 20 or 30, which maps to 0,1,2 in HomeKit, which are the only acceptable values. Anything outside of these ranges will confuse matters.
Extended Domoticz homebridge-plugin for latest Homebridge - adds temp/humidity/pressure sensors, power consumption sensors, DarkSkies virtual weather station support, YouLess Meter support, general % usage support & switch/lamp status checking!

islandman
Posts: 57
Joined: Saturday 05 August 2017 20:27
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Homebridge-eDomoticz & Push Button selector switches (SwitchTypeVal 18)

Post by islandman » Saturday 03 February 2018 21:00

I understand, however even if i do single click and it only send 10, HomeKit shows long click.

I just created a dummy button with 10/20/30 it also always is sending long Click to HomeKit

Code: Select all

Name:		Test Button
Device:		Light/Switch,Selector Switch
Is Switch:	true
SwitchTypeVal:	18
MQTT Message:
{
    "Battery": 255,
    "LevelNames": "Off|Level1|Level2|Level3",
    "RSSI": 12,
    "SelectorStyle": "0",
    "description": "",
    "dtype": "Light/Switch",
    "id": "000141F0",
    "idx": 416,
    "name": "Test Button",
    "nvalue": 2,
    "stype": "Selector Switch",
    "svalue1": "10",
    "switchType": "Selector",
    "unit": 1
}

User avatar
Marci
Posts: 521
Joined: Friday 22 January 2016 19:00
Target OS: Raspberry Pi
Domoticz version: 3.8153
Location: Wakefield, West Yorkshire UK
Contact:

Re: Homebridge-eDomoticz & Push Button selector switches (SwitchTypeVal 18)

Post by Marci » Saturday 03 February 2018 21:16

Problem found and fixed! MQTT handler getting diverted thru the wrong function...

Update to 2.1.10 and all should work perfectly (finally)!

Code: Select all

sudo npm update -g homebridge-edomoticz
Extended Domoticz homebridge-plugin for latest Homebridge - adds temp/humidity/pressure sensors, power consumption sensors, DarkSkies virtual weather station support, YouLess Meter support, general % usage support & switch/lamp status checking!

islandman
Posts: 57
Joined: Saturday 05 August 2017 20:27
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Homebridge-eDomoticz & Push Button selector switches (SwitchTypeVal 18)

Post by islandman » Saturday 03 February 2018 21:49

Confirm its working now!!!! Thanks again @marci GREAT WORK!

User avatar
Marci
Posts: 521
Joined: Friday 22 January 2016 19:00
Target OS: Raspberry Pi
Domoticz version: 3.8153
Location: Wakefield, West Yorkshire UK
Contact:

Re: Homebridge-eDomoticz & Push Button selector switches (SwitchTypeVal 18)

Post by Marci » Saturday 03 February 2018 21:57

Yay! No probs - now it’s drinking’ time... 8-)
Extended Domoticz homebridge-plugin for latest Homebridge - adds temp/humidity/pressure sensors, power consumption sensors, DarkSkies virtual weather station support, YouLess Meter support, general % usage support & switch/lamp status checking!

KungFooKamel
Posts: 2
Joined: Monday 26 November 2018 6:16
Target OS: Linux
Domoticz version:
Contact:

Re: Homebridge-eDomoticz & Push Button selector switches (SwitchTypeVal 18)

Post by KungFooKamel » Monday 26 November 2018 6:21

I'm running the Xiaomi Gateway with wireless push button switches.

I have them running in Domoticz fine, when I push a button, Demoticz is responding, but the button activation is not being sent to Homebridge, I have looked at the logs in Homebridge and there is nothing happening, I can assign Homekit devices like a lamp or a light to a single press or a double press, but they will not respond as Domoticz doesnt seem to update Homebridge with a switch press statice.

Any chance you can help me out with whats happening here?

KungFooKamel
Posts: 2
Joined: Monday 26 November 2018 6:16
Target OS: Linux
Domoticz version:
Contact:

Re: Homebridge-eDomoticz & Push Button selector switches (SwitchTypeVal 18)

Post by KungFooKamel » Monday 26 November 2018 7:32

Nevermind, I figured it out,

Incase anyone else is having this issue, I hadn't installed the MQTT service

Domoticz: Install MQTT Virtual Hardware
Homebridge System: Install Mosquito MQTT

Now button presses are all updated in Homekit.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests