Browse Source

MQTT and HA brightness (#1730)

* MQTT and HA brightness shall only be depended on LIGHT_PROVIDER != LIGHT_PROVIDER_NONE

* remove unnecessary changes
master
copyrights 5 years ago
committed by Max Prokhorov
parent
commit
d9b9e1449d
2 changed files with 5 additions and 3 deletions
  1. +3
    -2
      code/espurna/homeassistant.ino
  2. +2
    -1
      code/espurna/light.ino

+ 3
- 2
code/espurna/homeassistant.ino View File

@ -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);


+ 2
- 1
code/espurna/light.ino View File

@ -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);


Loading…
Cancel
Save