diff --git a/Arduino/McLighting/McLighting.ino b/Arduino/McLighting/McLighting.ino index 88f2417..6df786e 100644 --- a/Arduino/McLighting/McLighting.ino +++ b/Arduino/McLighting/McLighting.ino @@ -563,6 +563,9 @@ void setup() { #ifdef ENABLE_AMQTT amqttClient.publish(mqtt_outtopic.c_str(), qospub, false, String(String("OK ?") + String(ws2812fx_speed)).c_str()); #endif + #ifdef ENABLE_HOMEASSISTANT + if(!ha_send_data.active()) ha_send_data.once(5, tickerSendState); + #endif } getStatusJSON(); diff --git a/Arduino/McLighting/request_handlers.h b/Arduino/McLighting/request_handlers.h index 9dd3a64..c4f17a4 100644 --- a/Arduino/McLighting/request_handlers.h +++ b/Arduino/McLighting/request_handlers.h @@ -415,6 +415,9 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght strip.setSpeed(convertSpeed(ws2812fx_speed)); DBG_OUTPUT_PORT.printf("WS: Set speed to: [%u]\n", ws2812fx_speed); webSocket.sendTXT(num, "OK"); + #ifdef ENABLE_HOMEASSISTANT + if(!ha_send_data.active()) ha_send_data.once(5, tickerSendState); + #endif #ifdef ENABLE_MQTT mqtt_client.publish(mqtt_outtopic, String(String("OK ") + String((char *)payload)).c_str()); #endif @@ -668,7 +671,7 @@ void checkForRequests() { } void sendState() { - const size_t bufferSize = JSON_OBJECT_SIZE(3) + JSON_OBJECT_SIZE(5); + const size_t bufferSize = JSON_OBJECT_SIZE(3) + JSON_OBJECT_SIZE(6); //StaticJsonBuffer jsonBuffer; DynamicJsonBuffer jsonBuffer(bufferSize); JsonObject& root = jsonBuffer.createObject(); @@ -683,6 +686,8 @@ void checkForRequests() { root["color_temp"] = color_temp; + root["speed"] = ws2812fx_speed; + char modeName[30]; strncpy_P(modeName, (PGM_P)strip.getModeName(strip.getMode()), sizeof(modeName)); // copy from progmem root["effect"] = modeName; @@ -833,6 +838,9 @@ void checkForRequests() { ws2812fx_speed = constrain(d, 0, 255); strip.setSpeed(convertSpeed(ws2812fx_speed)); DBG_OUTPUT_PORT.printf("MQTT: Set speed to [%u]\n", ws2812fx_speed); + #ifdef ENABLE_HOMEASSISTANT + if(!ha_send_data.active()) ha_send_data.once(5, tickerSendState); + #endif #ifdef ENABLE_MQTT mqtt_client.publish(mqtt_outtopic, String(String("OK ") + String((char *)payload)).c_str()); #endif