Philips Hue and Z2M Brightness Adjustment Tips

Philips Hue and Z2M Brightness Adjustment TipsHey everyone, I wanted to share my experience with adjusting Philips Hue lights using Zigbee2MQTT (Z2M). I’ve been working on a script to change the brightness of these lights without turning them on if they’re currently off. Here’s what I’ve discovered and how I’ve approached the problem.My current setup uses the light.turn_on command, which, as expected, turns the light on and sets the brightness. However, I wanted a way to adjust the brightness without turning the light on if it’s off. After some research, I found that sending direct MQTT commands might be a solution, but I ran into an issue where the light would still turn on with the brightness adjustment.I tried modifying the MQTT message to include “status:OFF” to keep the light off while adjusting the brightness. Unfortunately, this didn’t work as intended. The light either stayed off or turned on regardless of the status command. It was a bit frustrating, but I kept experimenting.Here’s what I’ve learned so far:- The light.turn_on command is straightforward but doesn’t allow for brightness adjustments without turning the light on.- Direct MQTT commands can bypass some behaviors, but they require careful crafting to avoid unintended side effects.- Using variables to track the light’s state might be a way to handle this more effectively.I’m considering using a variable to store the desired brightness level when the light is off. Then, when the light is turned on, the brightness value can be applied automatically. This approach would ensure that the brightness adjustment is preserved without turning the light on prematurely.If anyone has successfully implemented a similar solution or has tips on how to achieve this, I’d love to hear about it! Let’s keep the discussion positive and focused on finding a reliable way to adjust brightness without turning the lights on.Happy tinkering!