Philips Hue Dimmer Switch v2 (Zigbee2MQTT)

Thank you for your contribution. I’ll make sure to update the blueprint before Z2M 2.0 release. I’m a bit hesitant to do so right now as I have several different third-party blueprints that will likely break, so it would take quite some time updating them all.

@JetSerge if you use my proposed approach (with MQTT topic), then it will work already with < 1.42 Z2M version. You should be able to test it immediately. The event type from within Z2M will come after 2.0.0, but I think we shall wait for Z2M to become stable in the event aspect, since there is a warning that somethings may change.

MQTT topic approach is being used with the Hue Tap switch since a while. I use one Blueprint from the link below:

1 Like

Hi @tilz0R

Like you, I use this blueprint or the automation Zigbee2MQTT - Philips Hue Tap Dial Switch by SmartHomeGeeks.io
and would also like to adapt its MQTT section for the Dimmer Switch, as you suggested.

However, already in tap dial automation I come across warning messages in the HA log after a restart when I deactivate (in preparation for zigbee2mqtt 2.0) the homeassistant legacy_triggers in z2m. For example:

Template variable warning: 'dict object' has no attribute 'action' when rendering '{{ trigger.payload_json.action is match('^button_[1-4]_press$') }}'
Template variable warning: 'dict object' has no attribute 'action' when rendering '{{ trigger.payload_json.action is match('button_[1-4]_press_release') and states(counter_var) > '1' }}'
Template variable warning: 'dict object' has no attribute 'action' when rendering '{{ trigger.payload_json.action is match('button_[1-4]_press_release') }}'
Template variable warning: 'dict object' has no attribute 'action' when rendering '{{ states(input_text_var) == '3' and trigger.payload_json.action is match('^dial_rotate_') }}'

It affects all template lines that contain trigger.payload_json.action

This is my configuration for z2m:

homeassistant:
  experimental_event_entities: true

advanced:
  homeassistant_legacy_entity_attributes: false
  legacy_api: false
  legacy_availability_payload: false
  homeassistant_legacy_triggers: false

And when I press the hue tap switch, I get the payload data (as seen in the automation, payload part of the trigger variable):

{
  "action":"button_3_press_release",
  "action_direction":null,
  "action_step_size":null,
  "action_time":null,
  "action_type":null,
  "battery":100,
  "brightness":null,
  "linkquality":142,
  "update":{
    "installed_version":33569561,
    "latest_version":33569561,
    "state":"idle"
  },
  "update_available":null
}

And when I try the same for dimmer, I get:

{
  "action":"off_press_release",
  "battery":100,
  "linkquality":156,
  "update": {
    "installed_version":33565954,
    "latest_version":33565954,
    "state":"idle"
  },
  "update_available":null
}

In both cases I see the action.

Z2M version 1.42.0

Thank you for your answer. I think I have to describe it a little more precisely, because the automations work. So when I press a button, action is also published.

The warning messages in the HA Log only appear after a restart or full restart of HA. Probably because during the evaluation of the automations, the zigbee device (Tap Dial or dimmer) has not yet sent a topic, or zigbee2mqtt is not yet fully loaded at this time. Maybe something needs to be added to the templates to prevent this?

I have the same zigbee2mqtt configuration as you, except for the experimental event entities.

OK, now it makes more sense.

The blueprint condition would need to be changed, to something like below (not tested in reality):

condition:
  - condition: template
    value_template: "{{ 'action' in trigger.payload_json and trigger.payload_json.action != '' }}"

Check shall be done verifying that action key exists, before its value is validated.

2 Likes

Thank you for your support. Unfortunately, I won’t be able to try it out for a few days. I’ll come back and report if it works.

Edit: @tilz0R
I was able to test it and it looks very good. I did several reboots and also a full reboot:
No more warnings appear in the log! Thank you very much for your support and have a nice weekend.

1 Like

Thank you for your solution. Has anybody gotten a blueprint that works with the event entity instead though? I am hoping to not create additional event helper entities if it’s not necessary.

The event entity will be available in HA from the Z2M, but only in the version Z2M v2.0.0 or if you enable the preview features of Z2M.

1 Like

Hey @tilz0R do you have a working blueprint you could share that works with the dimmer V2 and uses the experimental events?

You can take the original blueprint, use the take over feature and then modify it.

Thanks, I only use very basic functionality and I’ve just managed to port what I need over into an automation.

I just use the press/release for each of the 4 buttons but the code could be modified for other things.

It’s a trigger off the event and then a 4-way conditional action based on the button pressed.

Brilliant Blueprint, thank you!

It doesn’t seem to work with Z2M 2 so I’ve checked the legacy option and it seems to work again. Do we know when the Blueprint will be updated to support it?

Also, is it possible to append the version number of the Blueprint to the name so it’s easy to work out whether we need to reimport to get the latest changes?

1 Like

I’ve just forked and updated compatibility here, will need to enable the new event entities. It seems to work ok for me.

5 Likes

Use the one from tilz0R from dec 24.

thx, that fixed the warning also for me!

Can you please change your post here: Philips Hue Dimmer Switch v2 (Zigbee2MQTT) - #39 by tilz0R

thx
pOpY

Done.

Now waiting OP to release new version of this blueprint.

1 Like

Thanks. I will do the test and update it soon. So far, I had to enable:

homeassistant:
  legacy_action_sensor: true

as I have at least 3 different blueprints for various devices that stopped working after the Z2M update.

Updating them all plus changing several dozens of automations with the new mqtt topics would take a lot of time in my setup.

Actually it is a few min of work. A variable needs to be created to recreate the “button_name_action” and then used this in the if statements.

True, but if you have several different blueprints and 30+ devices using these blueprints via 30+ automations, it will take time to go through all of them and update the mqtt topic for the correct device that triggers them, then locate the devices and actually test if they still work and you did it all correctly.