Philips Hue Dimmer Switch v2 (Zigbee2MQTT)

thx, working like a charme here with 24x hue dimmer switches and set homeassistant_legacy_triggers: false.
Will migrate over my 24x hue dimmer switches to your blueprint.
So Z2M 2.0.0 can come for me… :grinning:

P.S.: Also my feelings are like yours, the reaction is slightly faster.

thx a lot.

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.

1 Like

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.