fix ha mqtt parsing hc number - #609

This commit is contained in:
proddy
2020-11-15 20:15:46 +01:00
parent 293d49bd56
commit 1f07c38440

View File

@@ -964,7 +964,7 @@ void Thermostat::register_mqtt_ha_config(uint8_t hc_num) {
// for each of the heating circuits
std::string topic2(100, '\0');
snprintf_P(&topic2[0], topic2.capacity() + 1, PSTR("thermostat_hc%d"), hc_num);
register_mqtt_topic(topic2, [&](const char * m) { return thermostat_ha_cmd(m, hc_num); });
register_mqtt_topic(topic2, [=](const char * m) { return thermostat_ha_cmd(m, hc_num); });
char hc_name[10]; // hc{1-4}
strlcpy(hc_name, "hc", 10);
@@ -1023,7 +1023,7 @@ void Thermostat::register_mqtt_ha_config(uint8_t hc_num) {
}
// for HA specifically when receiving over MQTT in the thermostat topic
// it could be either a 'mode' or a float value
// it could be either a 'mode' or a float value for a temperature. we try brute force both and see which one works.
// return true if it parses the message correctly
bool Thermostat::thermostat_ha_cmd(const char * message, uint8_t hc_num) {
// check if it's json. We know the message isn't empty