diff --git a/code/espurna/homeassistant.ino b/code/espurna/homeassistant.ino index 553de28b..079e58d9 100644 --- a/code/espurna/homeassistant.ino +++ b/code/espurna/homeassistant.ino @@ -98,9 +98,10 @@ void _haSendSwitch(unsigned char i, JsonObject& config) { if (i == 0) { + config["brightness_state_topic"] = mqttTopic(MQTT_TOPIC_BRIGHTNESS, false); + config["brightness_command_topic"] = mqttTopic(MQTT_TOPIC_BRIGHTNESS, true); + if (lightHasColor()) { - config["brightness_state_topic"] = mqttTopic(MQTT_TOPIC_BRIGHTNESS, false); - config["brightness_command_topic"] = mqttTopic(MQTT_TOPIC_BRIGHTNESS, true); config["rgb_state_topic"] = mqttTopic(MQTT_TOPIC_COLOR_RGB, false); config["rgb_command_topic"] = mqttTopic(MQTT_TOPIC_COLOR_RGB, true); config["color_temp_command_topic"] = mqttTopic(MQTT_TOPIC_MIRED, true); diff --git a/code/espurna/light.ino b/code/espurna/light.ino index 5e58b5b3..51ab46b9 100644 --- a/code/espurna/light.ino +++ b/code/espurna/light.ino @@ -539,8 +539,9 @@ void _lightMQTTCallback(unsigned int type, const char * topic, const char * payl if (type == MQTT_CONNECT_EVENT) { + mqttSubscribe(MQTT_TOPIC_BRIGHTNESS); + if (_light_has_color) { - mqttSubscribe(MQTT_TOPIC_BRIGHTNESS); mqttSubscribe(MQTT_TOPIC_MIRED); mqttSubscribe(MQTT_TOPIC_KELVIN); mqttSubscribe(MQTT_TOPIC_COLOR_RGB);