Hello MQTT enthusiasts! I came across an interesting problem with my MQTT lights where the brightness setting wasn’t being remembered after turning them off. If you’ve experienced this, you’re not alone! Let me walk you through how I tackled this issue and hopefully, it can help others too.
I initially set up my lights using the MQTT integration in Home Assistant. Everything worked smoothly at first—brightness adjustments, on/off commands, you name it. But there was this one quirk: whenever I turned a light off and back on, it would reset to 100% brightness. It was a bit annoying, especially after customizing the brightness to just the right level.
After some research and tweaking, I found a solution that involves modifying the MQTT configuration. By adjusting the brightness_state_topic and state_value_template, I was able to ensure that the brightness level is stored and reapplied when the light is turned back on. Here’s a snippet of the configuration that worked for me:
yaml
mqtt:
light:
- name: “EcoDimG0”
brightness_command_topic: “/devices/ecodim_dali_gw2_21/controls/Group 0 Brightness/on”
brightness_state_topic: “/devices/ecodim_dali_gw2_21/controls/Group 0 Brightness”
state_topic: “/devices/ecodim_dali_gw2_21/controls/Group 0 Brightness”
command_topic: “/devices/ecodim_dali_gw2_21/controls/Group 0 Brightness/on”
on_command_type: brightness
state_value_template: >
{% if value|int > 0 %}1{% else %}0{% endif %}
payload_on: “1”
payload_off: “0”
brightness_scale: 254
This configuration change ensures that the brightness level is saved when the light is turned off and reapplied when it’s turned on. It’s a small tweak but makes a big difference in user experience!
If you’re facing similar issues, I’d recommend checking your MQTT light configurations. Sometimes, a minor adjustment can lead to significant improvements. Happy tinkering! If anyone has further questions or needs assistance, feel free to reach out. I’m always happy to help!