diff --git a/sonoff/sonoff.ino b/sonoff/sonoff.ino index 9d2892ed3..0ee89ac72 100755 --- a/sonoff/sonoff.ino +++ b/sonoff/sonoff.ino @@ -631,7 +631,7 @@ void MqttShowState(void) for (uint32_t i = 1; i <= devices_present; i++) { #ifdef USE_LIGHT - if (i >= light_device) { + if ((light_device) && (i >= light_device)) { if (i == light_device) { LightState(1); } // call it only once } else { #endif diff --git a/sonoff/xdrv_04_light.ino b/sonoff/xdrv_04_light.ino index e7755c587..4968d7ea4 100644 --- a/sonoff/xdrv_04_light.ino +++ b/sonoff/xdrv_04_light.ino @@ -1643,10 +1643,10 @@ void LightState(uint8_t append) GetPowerDevice(scommand, light_device + i, sizeof(scommand), 1); uint32_t light_power_masked = light_power & (1 << i); // the light_power value for this device light_power_masked = light_power_masked ? 1 : 0; // convert to on/off - ResponseAppend_P(PSTR("\"%s\":\"%s\",\"" D_CMND_CHANNEL "%d\":%d"), scommand, GetStateText(light_power_masked), light_device + i, + ResponseAppend_P(PSTR("\"%s\":\"%s\",\"" D_CMND_CHANNEL "%d\":%d,"), scommand, GetStateText(light_power_masked), light_device + i, changeUIntScale(light_current_color[i], 0, 255, 0, 100)); } - ResponseAppend_P(PSTR(",\"" D_CMND_COLOR "\":\"%s\""), LightGetColor(scolor)); + ResponseAppend_P(PSTR("\"" D_CMND_COLOR "\":\"%s\""), LightGetColor(scolor)); } // light_pwm_multi_channels if (!append) {