I’m currently using a Lutron Aurora zigbee dial. It can either rotate left, rotate right, or be clicked. I’m using Zigbee2MQTT, and trying to use the dial to smoothly adjust a Zigbee light group I’ve defined in Z2M. But here are the issues:
1.) The Lutron Aurora’s MQTT payload does not make it clear which action was being taken. Every action is labeled as brightness_move_to_level, whether it’s a dial turn or button press. There are two additional values that can be looked at: action_level and action_transition_time (there is another value called brightness that does not ever change for some reason). Luckily the action_transition_time value helps differentiate between action types: it’s 0.07 for a button press and 0.02 for a dial turn.
2.) The action_level describes the brightness target on a scale from 0 to 255. However, this value is an absolute reference. I.e. If I reach an action_level of 128 with the dial, then use the app to set the light’s brightness to 200, then turn the dial to the right, the dial will send an action_level value of something like 135, because it was still referencing the value of 128 it held previously. This means I have no idea if the dial was moved to the left or to the right based solely on a single MQTT message (aside from corner cases where the value is 2 (minimum for turning left) or 255 (maximum for turning right)).
So what am I trying to do?
I’d like an automation that:
- Toggles the light if the button is pressed (let’s make it easy and assume we’ll always set the brightness to 255 if it toggles on)
- Adjusts the brightness up by a standard amount if the dial is turned to the right
- Adjust the brightness down by a standard amount if the dial is turned to the left
On a single MQTT message, there are four possibilities.
-
action_transition_time == 0.07
===> button pressed -
action_transition_time == 0.02
andaction_move_to_level == 2
===> dial turned left -
action_transition_time == 0.02
andaction_move_to_level == 255
===> dial turned right -
action_transition_time == 0.02
andaction_move_to_level ~= 2 or 255
===> dial turned in unknown direction
In case 4, I assume I’ll need to compare the current action_move_to_level value to a previous value to determine the direction. This is where I need help.
I’ve looked over mqtt sensors, trigger variables, value templates, and mqtt triggers, but I’m not finding a good example to get me started. The closest I’ve come up with so far is creating an mqtt sensor that updates based on the mqtt message, and an automation adjusts the light based on a state change of that mqtt sensor. I’m assuming this is not optimal because it results in VERY slow response times.
Any guidance would be greatly appreciated!
Below is the raw MQTT for button presses and dial turns:
# Clicking button (action level 255, transition 0.07)
Info 2023-08-21 14:08:26MQTT publish: topic 'zigbee2mqtt/Craft Room Lutron', payload '{"action":"brightness_move_to_level","action_group":47454,"action_level":255,"action_transition_time":0.07,"brightness":132,"linkquality":120,"update":{"installed_version":-1,"latest_version":-1,"state":null},"update_available":null}'
Info 2023-08-21 14:08:26MQTT publish: topic 'zigbee2mqtt/Craft Room Lutron', payload '{"action":"","brightness":132,"linkquality":120,"update":{"installed_version":-1,"latest_version":-1,"state":null},"update_available":null}'
Info 2023-08-21 14:08:26MQTT publish: topic 'zigbee2mqtt/Craft Room Lutron/action', payload 'brightness_move_to_level'
# Click button (action level 0, transition 0.07)
Info 2023-08-21 14:08:28MQTT publish: topic 'zigbee2mqtt/Craft Room Lutron', payload '{"action":"brightness_move_to_level","action_group":47454,"action_level":0,"action_transition_time":0.07,"brightness":132,"linkquality":116,"update":{"installed_version":-1,"latest_version":-1,"state":null},"update_available":null}'
Info 2023-08-21 14:08:28MQTT publish: topic 'zigbee2mqtt/Craft Room Lutron', payload '{"action":"","brightness":132,"linkquality":116,"update":{"installed_version":-1,"latest_version":-1,"state":null},"update_available":null}'
Info 2023-08-21 14:08:28MQTT publish: topic 'zigbee2mqtt/Craft Room Lutron/action', payload 'brightness_move_to_level'
# Turn knob to the left multiple times (action level stays at 2, transition 0.02)
Info 2023-08-21 14:08:30MQTT publish: topic 'zigbee2mqtt/Craft Room Lutron', payload '{"action":"brightness_move_to_level","action_group":47454,"action_level":2,"action_transition_time":0.02,"brightness":132,"linkquality":116,"update":{"installed_version":-1,"latest_version":-1,"state":null},"update_available":null}'
Info 2023-08-21 14:08:30MQTT publish: topic 'zigbee2mqtt/Craft Room Lutron', payload '{"action":"","brightness":132,"linkquality":116,"update":{"installed_version":-1,"latest_version":-1,"state":null},"update_available":null}'
Info 2023-08-21 14:08:30MQTT publish: topic 'zigbee2mqtt/Craft Room Lutron/action', payload 'brightness_move_to_level'
Info 2023-08-21 14:08:31MQTT publish: topic 'zigbee2mqtt/Craft Room Lutron', payload '{"action":"brightness_move_to_level","action_level":2,"action_transition_time":0.02,"brightness":132,"linkquality":116,"update":{"installed_version":-1,"latest_version":-1,"state":null},"update_available":null}'
Info 2023-08-21 14:08:31MQTT publish: topic 'zigbee2mqtt/Craft Room Lutron', payload '{"action":"","brightness":132,"linkquality":116,"update":{"installed_version":-1,"latest_version":-1,"state":null},"update_available":null}'
Info 2023-08-21 14:08:31MQTT publish: topic 'zigbee2mqtt/Craft Room Lutron/action', payload 'brightness_move_to_level'
Info 2023-08-21 14:08:31MQTT publish: topic 'zigbee2mqtt/Craft Room Lutron', payload '{"action":"brightness_move_to_level","action_level":2,"action_transition_time":0.02,"brightness":132,"linkquality":116,"update":{"installed_version":-1,"latest_version":-1,"state":null},"update_available":null}'
Info 2023-08-21 14:08:31MQTT publish: topic 'zigbee2mqtt/Craft Room Lutron', payload '{"action":"","brightness":132,"linkquality":116,"update":{"installed_version":-1,"latest_version":-1,"state":null},"update_available":null}'
Info 2023-08-21 14:08:31MQTT publish: topic 'zigbee2mqtt/Craft Room Lutron/action', payload 'brightness_move_to_level'
Info 2023-08-21 14:08:31MQTT publish: topic 'zigbee2mqtt/Craft Room Lutron', payload '{"action":"brightness_move_to_level","action_level":2,"action_transition_time":0.02,"brightness":132,"linkquality":116,"update":{"installed_version":-1,"latest_version":-1,"state":null},"update_available":null}'
Info 2023-08-21 14:08:31MQTT publish: topic 'zigbee2mqtt/Craft Room Lutron', payload '{"action":"","brightness":132,"linkquality":116,"update":{"installed_version":-1,"latest_version":-1,"state":null},"update_available":null}'
Info 2023-08-21 14:08:31MQTT publish: topic 'zigbee2mqtt/Craft Room Lutron/action', payload 'brightness_move_to_level'
# Turn knob to the right multiple times (action level incrementally moves up, transition 0.02)
Info 2023-08-21 14:08:32MQTT publish: topic 'zigbee2mqtt/Craft Room Lutron', payload '{"action":"brightness_move_to_level","action_level":15,"action_transition_time":0.02,"brightness":132,"linkquality":116,"update":{"installed_version":-1,"latest_version":-1,"state":null},"update_available":null}'
Info 2023-08-21 14:08:32MQTT publish: topic 'zigbee2mqtt/Craft Room Lutron', payload '{"action":"","brightness":132,"linkquality":116,"update":{"installed_version":-1,"latest_version":-1,"state":null},"update_available":null}'
Info 2023-08-21 14:08:32MQTT publish: topic 'zigbee2mqtt/Craft Room Lutron/action', payload 'brightness_move_to_level'
Info 2023-08-21 14:08:32MQTT publish: topic 'zigbee2mqtt/Craft Room Lutron', payload '{"action":"brightness_move_to_level","action_level":66,"action_transition_time":0.02,"brightness":132,"linkquality":116,"update":{"installed_version":-1,"latest_version":-1,"state":null},"update_available":null}'
Info 2023-08-21 14:08:32MQTT publish: topic 'zigbee2mqtt/Craft Room Lutron', payload '{"action":"","brightness":132,"linkquality":116,"update":{"installed_version":-1,"latest_version":-1,"state":null},"update_available":null}'
Info 2023-08-21 14:08:32MQTT publish: topic 'zigbee2mqtt/Craft Room Lutron/action', payload 'brightness_move_to_level'
Info 2023-08-21 14:08:33MQTT publish: topic 'zigbee2mqtt/Craft Room Lutron', payload '{"action":"brightness_move_to_level","action_level":73,"action_transition_time":0.02,"brightness":132,"linkquality":116,"update":{"installed_version":-1,"latest_version":-1,"state":null},"update_available":null}'
Info 2023-08-21 14:08:33MQTT publish: topic 'zigbee2mqtt/Craft Room Lutron', payload '{"action":"","brightness":132,"linkquality":116,"update":{"installed_version":-1,"latest_version":-1,"state":null},"update_available":null}'
Info 2023-08-21 14:08:33MQTT publish: topic 'zigbee2mqtt/Craft Room Lutron/action', payload 'brightness_move_to_level'
Info 2023-08-21 14:08:33MQTT publish: topic 'zigbee2mqtt/Craft Room Lutron', payload '{"action":"brightness_move_to_level","action_level":110,"action_transition_time":0.02,"brightness":132,"linkquality":112,"update":{"installed_version":-1,"latest_version":-1,"state":null},"update_available":null}'
Info 2023-08-21 14:08:33MQTT publish: topic 'zigbee2mqtt/Craft Room Lutron', payload '{"action":"","brightness":132,"linkquality":112,"update":{"installed_version":-1,"latest_version":-1,"state":null},"update_available":null}'
Info 2023-08-21 14:08:33MQTT publish: topic 'zigbee2mqtt/Craft Room Lutron/action', payload 'brightness_move_to_level'
# Turn knob to the left once (action level decreases, transition 0.02)
Info 2023-08-21 14:08:34MQTT publish: topic 'zigbee2mqtt/Craft Room Lutron', payload '{"action":"brightness_move_to_level","action_level":81,"action_transition_time":0.02,"brightness":132,"linkquality":116,"update":{"installed_version":-1,"latest_version":-1,"state":null},"update_available":null}'
Info 2023-08-21 14:08:34MQTT publish: topic 'zigbee2mqtt/Craft Room Lutron', payload '{"action":"","brightness":132,"linkquality":116,"update":{"installed_version":-1,"latest_version":-1,"state":null},"update_available":null}'
Info 2023-08-21 14:08:34MQTT publish: topic 'zigbee2mqtt/Craft Room Lutron/action', payload 'brightness_move_to_level'