Thanks for the blueprint! It’s working great for me.
One thing I will say. Echoing the comment above, if your lights support move via Zigbee2Mqtt it is a much better and smoother way of making the lights dim or brighten via the hold action.
For anyone looking to implement this. First, check if your lights support MOVE in the device information on Zigbee2Mqtt.
If they do, you can use the MQTT Publish service to send a move payload to the light(s). The payload can have a positive or negative value and can also be set to turn the light on if off or vice versa. You must also send a second payload on the release action. Some examples:
"brightness_move": 40, // Starts moving brightness up at 40 units per second
"brightness_move": -40, // Starts moving brightness down at 40 units per second
"brightness_move_onoff": 50 // turns light on if off and Increases brightness by 40
"brightness_move_onoff": -50 // Increases brightness by -50 and turns light off if on
"brightness_move": "stop", // Stop moving brightness
You must also find the Z2M topic, which is in the format:
zigbee2mqtt/FRIENDLY_NAME/set
This can either be an individual light or a Z2M light group.
An example from my own automation:
alias: Auto - Living Room Switch
description: ""
use_blueprint:
path: vandalon/z2m EnOcean PTM 215Z (Friends of Hue) switch.yaml
input:
controller: Living Room Switch
button_1_pressed:
- service: light.turn_on
data: {}
target:
entity_id: light.living_room_lights
button_1_held:
- service: mqtt.publish
data:
topic: zigbee2mqtt/Living Room Lights/set
payload: "{\"brightness_move_onoff\": 51}"
qos: 0
retain: false
button_1_released:
- service: mqtt.publish
data:
topic: zigbee2mqtt/Living Room Lights/set
payload: "{\"brightness_move\": \"stop\"}"
qos: 0
retain: false
button_2_pressed:
- service: light.turn_off
data: {}
target:
device_id: 954f8699a96afa5436ba599fef2a3038
button_2_held:
- service: mqtt.publish
data:
topic: zigbee2mqtt/Living Room Lights/set
payload: "{\"brightness_move_onoff\": -51}"
qos: 0
retain: false
button_2_released:
- service: mqtt.publish
data:
topic: zigbee2mqtt/Living Room Lights/set
payload: "{\"brightness_move\": \"stop\"}"
qos: 0
retain: false