diff --git a/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/ClimateIoT.cpp b/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/ClimateIoT.cpp index e6e179c..138e32d 100644 --- a/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/ClimateIoT.cpp +++ b/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/ClimateIoT.cpp @@ -148,6 +148,7 @@ void ClimateIoT::subscribe() { this->subscribeRelative(AC_TEMPERATURE_SET_TOPIC); this->subscribeRelative(AC_MODE_SET_TOPIC); this->subscribeRelative(AC_FAN_SPEED_SET_TOPIC); + this->subscribeRelative(AC_REQUEST_STATE_TOPIC); ESP_LOGD("ClimateIoT", "Subscribed to topics"); } diff --git a/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/ClimateIoT.hpp b/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/ClimateIoT.hpp index b376afd..8d5cb57 100644 --- a/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/ClimateIoT.hpp +++ b/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/ClimateIoT.hpp @@ -12,7 +12,7 @@ #define AC_FAN_SPEED_SET_TOPIC "set/fan_speed" #define AC_ROOM_TEMPERATURE_REPORT_TOPIC "room_temperature" #define AC_HUMIDITY_REPORT_TOPIC "humidity" -#define AC_REQUEST_STATE_TOPIC "request_state" +#define AC_REQUEST_STATE_TOPIC "requeststate" /** * @brief The ClimateIoT class is a class for connecting the Climate Card to the IoT module. diff --git a/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/DigitalInputIoT.cpp b/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/DigitalInputIoT.cpp index 7b7a6b0..f138e52 100644 --- a/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/DigitalInputIoT.cpp +++ b/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/DigitalInputIoT.cpp @@ -31,6 +31,7 @@ bool DigitalInputIoT::begin(uint8_t card_id, ExpansionCard *card, PubSubClient * */ void DigitalInputIoT::subscribe() { this->subscribeRelative(PUBLISH_ENABLE_TOPIC); + this->subscribeRelative(INPUT_REQUEST_STATE_TOPIC); } /** @@ -40,14 +41,18 @@ void DigitalInputIoT::subscribe() { * @param payload The null-terminated payload of the MQTT message. */ void DigitalInputIoT::handleMqttMessage(char *topic, char *payload) { + if (!strcmp(topic, INPUT_REQUEST_STATE_TOPIC)) { + this->publishDigitalInputs(); + } // payload is char '0' or '1' - if (!strcmp(topic, PUBLISH_ENABLE_TOPIC)) { + else if (!strcmp(topic, PUBLISH_ENABLE_TOPIC)) { if (payload[0] == '1') { this->setDigitalInputsPublishEnabled(true); } else { this->setDigitalInputsPublishEnabled(false); } } + } /** diff --git a/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/DigitalInputIoT.hpp b/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/DigitalInputIoT.hpp index 978135f..6a8d44e 100644 --- a/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/DigitalInputIoT.hpp +++ b/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/DigitalInputIoT.hpp @@ -6,6 +6,7 @@ // MQTT Topics #define PUBLISH_ENABLE_TOPIC "publish_enable" +#define INPUT_REQUEST_STATE_TOPIC "requeststate" /** * @brief The DigitalInputIoT class is a class for connecting the Digital Input Card to the IoT module.