improve MQTT state request
This commit is contained in:
parent
dc96be25b8
commit
d75b028cd2
|
@ -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");
|
||||
}
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue