Domoticz: [Request] Philips Hue Dimmer Switch

Created on 2 Jul 2019  路  22Comments  路  Source: domoticz/domoticz

It would be nice if domoticz can add a Hue Dimmer Switch (ZLLSwitch) to make it work with other domoticz devices. The workaround with the LUA script is not very handy.
I think the starting point is at the GetSensors function. We already have an empty else if condition for the switch types.

else if ((hsensor.m_type == SensorTypeZGPSwitch) || (hsensor.m_type == SensorTypeZLLSwitch))
{
}

Are there any rabbit holes I am not aware of?

Here is an example JSON

"name": "wall switch",
    "type": "ZLLSwitch",
    "modelid": "RWL021",
    "manufacturername": "Philips",
    "productname": "Hue dimmer switch",
    "diversityid": "**cleared**",
    "swversion": "5.45.1.17846",
    "uniqueid": "**cleared**",
    "capabilities": {
      "certified": true,
      "primary": true,
      "inputs": [
        {
          "repeatintervals": [
            800
          ],
          "events": [
            {
              "buttonevent": 1000,
              "eventtype": "initial_press"
            },
            {
              "buttonevent": 1001,
              "eventtype": "repeat"
            },
            {
              "buttonevent": 1002,
              "eventtype": "short_release"
            },
            {
              "buttonevent": 1003,
              "eventtype": "long_release"
            }
          ]
        },
        {
          "repeatintervals": [
            800
          ],
          "events": [
            {
              "buttonevent": 2000,
              "eventtype": "initial_press"
            },
            {
              "buttonevent": 2001,
              "eventtype": "repeat"
            },
            {
              "buttonevent": 2002,
              "eventtype": "short_release"
            },
            {
              "buttonevent": 2003,
              "eventtype": "long_release"
            }
          ]
        },

Most helpful comment

@Lyr3x and others,
I'm about to do pull request. I implemented the switch.

It's implemented as an SELECTOR switch. All the possible levels are automatically added on first sight, based on the capabilities. It works with ZLL switch, TAP and Friens of Hue Switches.

Regards,
Richard

All 22 comments

Yes i think that's the place to add it....
But i miss the 'state' ... it seems your dimmer has two buttons, and you would like to know what button was pressed, and how it was pressed.
The 'how' (state) i do not see in your example JSON, is this the call to http:// There should be a 'sensors' part in the JSON as well, could you post that ?

You want to convert 'short_release' and 'long_release' to be part of the 'id' for the switch so you get unique switches.
After this you should be able to use those switches in scenes/groups in domoticz

Could you point to the LUA script ?

Maybe the dimmer is not part of the 'sensors' JSON section... maybe post your complete JSON dump on https://pastebin.com/ and past the link here ?

Update: Due to lack of spare time i couldn't implement the switch yet, will continue very soon though.

Link to JSON response from http://<ip>/api/<api_key>/sensors: https://pastebin.com/EbZzNgjS
Link to LUA script: https://www.domoticz.com/forum/viewtopic.php?f=23&t=11882&p=85418#p85418
You can see that the switch is contains a capabilities section where the four buttons are modeled. Each button has four events: initial_press, repeat, short_release, long_release. As far as i can tell the buttons are mapped in the following order:

  1. On button (buttonevent: 100X)
  2. Brighter button (buttonevent: 200X)
  3. Darker button (buttonevent: 300X)
  4. Off button (buttonevent: 400X)

I don't have a clean idea, how to map all four possible buttonevents to domoticz switches. Any suggestions here? 4x4 switches in domoticz might be a little overkill.
My only suggestion: for each button a selector switch with the four events.

You want to convert 'short_release' and 'long_release' to be part of the 'id' for the switch so you get unique switches.

Isn't a selector switch more appropriate for a multi button switch? Maybe its also not a bad idea to implement the darker/brighter buttons as a slider? You can't customize those buttons, so a slider would be more useful i think.

Hello Lyr3x, gizmocuz, and all,

I have pretty much the same idea. Ignoring "initial_press" and "repeat". So you have 8 switches in domoticz. Only send "On" events to the workerthread.

In my case i will not set actions in the hue bridge for my remotes. Leave it all for dzVents. This way i have all the freedom to do with the remote i want.

Can i help to implement this?

Regards,
Richard

I think we should respect the actions set in hue bridge, because that's the common way to use those switches. But i would also like to control the switch completely with domoticz.

Sure i'd like some help with that one

At my github account, in the domoticz fork i have branch "HueDimmerSwitch".

I am not completly happy with the code yet, needs some refactoring. Functionality is basically fine. I running this code now for a few days. Sometimes a button press is missed, but i am not sure if it is the bridge or domoticz. Als i have only dimmer to test with, not tap or friend of hue switches.

Found and fixed the reason a button was missed once in a while. Refactored the code and rebased the branch (sorry for the forced push).

Looking for somebody to review the code before i do an pull request...

@Lyr3x and others,
I'm about to do pull request. I implemented the switch.

It's implemented as an SELECTOR switch. All the possible levels are automatically added on first sight, based on the capabilities. It works with ZLL switch, TAP and Friens of Hue Switches.

Regards,
Richard

Awesome. Couldn't find enough time to proceed.. love to review ur PR

Little note: I'm going to use my "RDols" github account in the future for Domoticz.

Regards,
Richard Dols

@RedDigital I just saw that the PR is merged. Do i need to do anything special to get my dimmer switch recognized? Not popping up after the update

No, only press the button once. It should create the level switch then.

I'm just pulled, compiled lua 5.3 and domoticz. Im going to test now.

Not working for me right now. Will test more tomorrow.

Just did a test with clean database my switches are added as expected.

Are you using the rectangular philips dimmer switch, the TAP or an Friend Of Hue switch?

On the devices page search for "ZLLSwitch" or "ZGPSwitch". Is the switch in the Hue Bridge Json file?

I am.using the rectangular switch. You can see the original json in my first post, where the switch is included. I'll check tomorrow if a delete from the hue bridge helps

The json in top is incomplete. But i guess this is a copy, paste fault. For what i can see it looks ok. It has the correct type, and the capabilities are included.

Try to do a rebuld-all, maybe it went wrong there.

edit: I just made the latest update an the switch is added to the db and is working fine.
I deleted the switch from the app and paired it again, but still no switch in Domoticz.

@Lyr3x , has this issue been solved ?

I just needed to power off the hue bridge, restart domoticz and power on the bridge again. After that the new switch was available and it's working

I am sorry if this is a noob question; will this work when having a hardware type of "Philips Hue Bridge"? Right now I can only see lights; not accessories, which this dimmer falls into. And if so, which version do i need to install of Domoticz?

Keep up the good work!

will this work when having a hardware type of "Philips Hue Bridge"? And if so, which version do i need to install of Domoticz?

Yes, it does work with the bridge. Functionality was added in V4.11454, so any version newer as V4.11453 will do.

btw. best to use the forum for these kind of questions.

will this work when having a hardware type of "Philips Hue Bridge"? And if so, which version do i need to install of Domoticz?

Yes, it does work with the bridge. Functionality was added in V4.11454, so any version newer as V4.11453 will do.

btw. best to use the forum for these kind of questions.

Thanks for the reply - and yes, I agree in regards to the forum; sorry about that - i was caught in the moment.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DarkosGahan picture DarkosGahan  路  18Comments

g-chevalier picture g-chevalier  路  22Comments

FireWizard52 picture FireWizard52  路  11Comments

sushukka picture sushukka  路  15Comments

kovainfo picture kovainfo  路  4Comments