diff --git a/src/hasp/hasp_dispatch.cpp b/src/hasp/hasp_dispatch.cpp index 302cebb0..d43a76c1 100644 --- a/src/hasp/hasp_dispatch.cpp +++ b/src/hasp/hasp_dispatch.cpp @@ -42,8 +42,8 @@ extern uint8_t hasp_sleep_state; dispatch_conf_t dispatch_setings = {.teleperiod = 300}; -uint32_t dispatchLastMillis; -uint8_t nCommands = 0; +uint32_t dispatchLastMillis = -3000000; // force discovery +uint8_t nCommands = 0; haspCommand_t commands[18]; struct moodlight_t diff --git a/src/mqtt/hasp_mqtt_paho_single.cpp b/src/mqtt/hasp_mqtt_paho_single.cpp index 3c1f1841..337bbc6f 100644 --- a/src/mqtt/hasp_mqtt_paho_single.cpp +++ b/src/mqtt/hasp_mqtt_paho_single.cpp @@ -253,6 +253,13 @@ int mqtt_send_state(const __FlashStringHelper* subtopic, const char* payload) return mqttPublish(tmp_topic, payload, strlen(payload), false); } +int mqtt_send_discovery(const char* payload) +{ + char tmp_topic[20]; + snprintf_P(tmp_topic, sizeof(tmp_topic), PSTR(MQTT_PREFIX "/discovery")); + return mqttPublish(tmp_topic, payload, strlen(payload), false); +} + int mqtt_send_object_state(uint8_t pageid, uint8_t btnid, const char* payload) { char tmp_topic[strlen(mqttNodeTopic) + 20]; @@ -268,6 +275,7 @@ static void onConnect(void* context) printf("Successful connection\n"); mqtt_subscribe(mqtt_client, TOPIC "command/#"); + mqtt_subscribe(mqtt_client, TOPIC "config/#"); // mqtt_subscribe(mqtt_client, TOPIC "command"); mqtt_subscribe(mqtt_client, TOPIC "light/#"); mqtt_subscribe(mqtt_client, TOPIC "brightness/#");