mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 16:29:51 +03:00
fix for https://github.com/proddy/EMS-ESP/issues/190 - MQTT not working for multiple HCs
This commit is contained in:
@@ -914,10 +914,6 @@ void publishValues(bool force) {
|
|||||||
fchecksum = crc.finalize();
|
fchecksum = crc.finalize();
|
||||||
if ((previousThermostatPublishCRC != fchecksum) || force) {
|
if ((previousThermostatPublishCRC != fchecksum) || force) {
|
||||||
previousThermostatPublishCRC = fchecksum;
|
previousThermostatPublishCRC = fchecksum;
|
||||||
myDebugLog("Publishing thermostat data via MQTT");
|
|
||||||
|
|
||||||
// send values via MQTT
|
|
||||||
|
|
||||||
char thermostat_topicname[20];
|
char thermostat_topicname[20];
|
||||||
strlcpy(thermostat_topicname, TOPIC_THERMOSTAT_DATA, sizeof(thermostat_topicname)); // "thermostat_data"
|
strlcpy(thermostat_topicname, TOPIC_THERMOSTAT_DATA, sizeof(thermostat_topicname)); // "thermostat_data"
|
||||||
// if we have more than 1 active Heating Circuit, postfix with the HC number
|
// if we have more than 1 active Heating Circuit, postfix with the HC number
|
||||||
@@ -925,6 +921,7 @@ void publishValues(bool force) {
|
|||||||
char buffer[4];
|
char buffer[4];
|
||||||
strlcat(thermostat_topicname, itoa(total_active_hc, buffer, 10), sizeof(thermostat_topicname));
|
strlcat(thermostat_topicname, itoa(total_active_hc, buffer, 10), sizeof(thermostat_topicname));
|
||||||
}
|
}
|
||||||
|
myDebugLog("Publishing thermostat data via MQTT");
|
||||||
myESP.mqttPublish(thermostat_topicname, data);
|
myESP.mqttPublish(thermostat_topicname, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1607,7 +1604,7 @@ uint8_t _hasHCspecified(const char * topic, const char * input) {
|
|||||||
return EMS_THERMOSTAT_DEFAULTHC; // identical, use default
|
return EMS_THERMOSTAT_DEFAULTHC; // identical, use default
|
||||||
}
|
}
|
||||||
|
|
||||||
// return the value of the last char
|
// return the value of the last char, 0-9
|
||||||
return input[orig_len] - '0';
|
return input[orig_len] - '0';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1618,12 +1615,40 @@ uint8_t _hasHCspecified(const char * topic, const char * input) {
|
|||||||
void MQTTCallback(unsigned int type, const char * topic, const char * message) {
|
void MQTTCallback(unsigned int type, const char * topic, const char * message) {
|
||||||
// we're connected. lets subscribe to some topics
|
// we're connected. lets subscribe to some topics
|
||||||
if (type == MQTT_CONNECT_EVENT) {
|
if (type == MQTT_CONNECT_EVENT) {
|
||||||
myESP.mqttSubscribe(TOPIC_THERMOSTAT_CMD_TEMP);
|
// subscribe to the 4 heating circuits
|
||||||
myESP.mqttSubscribe(TOPIC_THERMOSTAT_CMD_MODE);
|
char topic_s[50];
|
||||||
myESP.mqttSubscribe(TOPIC_THERMOSTAT_CMD_HC);
|
char buffer[4];
|
||||||
myESP.mqttSubscribe(TOPIC_THERMOSTAT_CMD_DAYTEMP);
|
for (uint8_t hc = 0; hc < EMS_THERMOSTAT_MAXHC; hc++) {
|
||||||
myESP.mqttSubscribe(TOPIC_THERMOSTAT_CMD_NIGHTTEMP);
|
strlcpy(topic_s, TOPIC_THERMOSTAT_CMD_TEMP, sizeof(topic_s));
|
||||||
myESP.mqttSubscribe(TOPIC_THERMOSTAT_CMD_HOLIDAYTEMP);
|
if (hc) {
|
||||||
|
strlcat(topic_s, itoa(hc, buffer, 10), sizeof(topic_s)); // add 1-4 at the end
|
||||||
|
}
|
||||||
|
myESP.mqttSubscribe(topic_s);
|
||||||
|
|
||||||
|
strlcpy(topic_s, TOPIC_THERMOSTAT_CMD_MODE, sizeof(topic_s));
|
||||||
|
if (hc) {
|
||||||
|
strlcat(topic_s, itoa(hc, buffer, 10), sizeof(topic_s)); // add 1-4 at the end
|
||||||
|
}
|
||||||
|
myESP.mqttSubscribe(topic_s);
|
||||||
|
|
||||||
|
strlcpy(topic_s, TOPIC_THERMOSTAT_CMD_DAYTEMP, sizeof(topic_s));
|
||||||
|
if (hc) {
|
||||||
|
strlcat(topic_s, itoa(hc, buffer, 10), sizeof(topic_s)); // add 1-4 at the end
|
||||||
|
}
|
||||||
|
myESP.mqttSubscribe(topic_s);
|
||||||
|
|
||||||
|
strlcpy(topic_s, TOPIC_THERMOSTAT_CMD_NIGHTTEMP, sizeof(topic_s));
|
||||||
|
if (hc) {
|
||||||
|
strlcat(topic_s, itoa(hc, buffer, 10), sizeof(topic_s)); // add 1-4 at the end
|
||||||
|
}
|
||||||
|
myESP.mqttSubscribe(topic_s);
|
||||||
|
|
||||||
|
strlcpy(topic_s, TOPIC_THERMOSTAT_CMD_HOLIDAYTEMP, sizeof(topic_s));
|
||||||
|
if (hc) {
|
||||||
|
strlcat(topic_s, itoa(hc, buffer, 10), sizeof(topic_s)); // add 1-4 at the end
|
||||||
|
}
|
||||||
|
myESP.mqttSubscribe(topic_s);
|
||||||
|
}
|
||||||
|
|
||||||
myESP.mqttSubscribe(TOPIC_BOILER_CMD_WWACTIVATED);
|
myESP.mqttSubscribe(TOPIC_BOILER_CMD_WWACTIVATED);
|
||||||
myESP.mqttSubscribe(TOPIC_BOILER_CMD_WWTEMP);
|
myESP.mqttSubscribe(TOPIC_BOILER_CMD_WWTEMP);
|
||||||
@@ -1650,6 +1675,7 @@ void MQTTCallback(unsigned int type, const char * topic, const char * message) {
|
|||||||
myDebug_P(PSTR("MQTT topic: thermostat HC%d temperature value %s"), hc, _float_to_char(s, f));
|
myDebug_P(PSTR("MQTT topic: thermostat HC%d temperature value %s"), hc, _float_to_char(s, f));
|
||||||
ems_setThermostatTemp(f, hc);
|
ems_setThermostatTemp(f, hc);
|
||||||
publishValues(true); // publish back immediately
|
publishValues(true); // publish back immediately
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// thermostat mode changes
|
// thermostat mode changes
|
||||||
@@ -1663,6 +1689,7 @@ void MQTTCallback(unsigned int type, const char * topic, const char * message) {
|
|||||||
} else if (strcmp((char *)message, "night") == 0 || strcmp((char *)message, "off") == 0) {
|
} else if (strcmp((char *)message, "night") == 0 || strcmp((char *)message, "off") == 0) {
|
||||||
ems_setThermostatMode(0, hc);
|
ems_setThermostatMode(0, hc);
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// set night temp value
|
// set night temp value
|
||||||
@@ -1672,6 +1699,7 @@ void MQTTCallback(unsigned int type, const char * topic, const char * message) {
|
|||||||
char s[10] = {0};
|
char s[10] = {0};
|
||||||
myDebug_P(PSTR("MQTT topic: new thermostat HC%d night temperature value %s"), hc, _float_to_char(s, f));
|
myDebug_P(PSTR("MQTT topic: new thermostat HC%d night temperature value %s"), hc, _float_to_char(s, f));
|
||||||
ems_setThermostatTemp(f, hc, 1);
|
ems_setThermostatTemp(f, hc, 1);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// set daytemp value
|
// set daytemp value
|
||||||
@@ -1681,6 +1709,7 @@ void MQTTCallback(unsigned int type, const char * topic, const char * message) {
|
|||||||
char s[10] = {0};
|
char s[10] = {0};
|
||||||
myDebug_P(PSTR("MQTT topic: new thermostat HC%d day temperature value %s"), hc, _float_to_char(s, f));
|
myDebug_P(PSTR("MQTT topic: new thermostat HC%d day temperature value %s"), hc, _float_to_char(s, f));
|
||||||
ems_setThermostatTemp(f, hc, 2);
|
ems_setThermostatTemp(f, hc, 2);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// set holiday value
|
// set holiday value
|
||||||
@@ -1690,6 +1719,7 @@ void MQTTCallback(unsigned int type, const char * topic, const char * message) {
|
|||||||
char s[10] = {0};
|
char s[10] = {0};
|
||||||
myDebug_P(PSTR("MQTT topic: new thermostat HC%d holiday temperature value %s"), hc, _float_to_char(s, f));
|
myDebug_P(PSTR("MQTT topic: new thermostat HC%d holiday temperature value %s"), hc, _float_to_char(s, f));
|
||||||
ems_setThermostatTemp(f, hc, 3);
|
ems_setThermostatTemp(f, hc, 3);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// wwActivated
|
// wwActivated
|
||||||
@@ -1699,6 +1729,7 @@ void MQTTCallback(unsigned int type, const char * topic, const char * message) {
|
|||||||
} else if (message[0] == '0' || strcmp(message, "off") == 0) {
|
} else if (message[0] == '0' || strcmp(message, "off") == 0) {
|
||||||
ems_setWarmWaterActivated(false);
|
ems_setWarmWaterActivated(false);
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// boiler wwtemp changes
|
// boiler wwtemp changes
|
||||||
@@ -1707,6 +1738,7 @@ void MQTTCallback(unsigned int type, const char * topic, const char * message) {
|
|||||||
myDebug_P(PSTR("MQTT topic: boiler warm water temperature value %d"), t);
|
myDebug_P(PSTR("MQTT topic: boiler warm water temperature value %d"), t);
|
||||||
ems_setWarmWaterTemp(t);
|
ems_setWarmWaterTemp(t);
|
||||||
publishValues(true); // publish back immediately, can't remember why I do this?!
|
publishValues(true); // publish back immediately, can't remember why I do this?!
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// boiler ww comfort setting
|
// boiler ww comfort setting
|
||||||
@@ -1719,6 +1751,7 @@ void MQTTCallback(unsigned int type, const char * topic, const char * message) {
|
|||||||
} else if (strcmp((char *)message, "intelligent") == 0) {
|
} else if (strcmp((char *)message, "intelligent") == 0) {
|
||||||
ems_setWarmWaterModeComfort(3);
|
ems_setWarmWaterModeComfort(3);
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// boiler flowtemp setting
|
// boiler flowtemp setting
|
||||||
@@ -1726,6 +1759,7 @@ void MQTTCallback(unsigned int type, const char * topic, const char * message) {
|
|||||||
uint8_t t = atoi((char *)message);
|
uint8_t t = atoi((char *)message);
|
||||||
myDebug_P(PSTR("MQTT topic: boiler flowtemp value %d"), t);
|
myDebug_P(PSTR("MQTT topic: boiler flowtemp value %d"), t);
|
||||||
ems_setFlowTemp(t);
|
ems_setFlowTemp(t);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// shower timer
|
// shower timer
|
||||||
@@ -1736,6 +1770,7 @@ void MQTTCallback(unsigned int type, const char * topic, const char * message) {
|
|||||||
EMSESP_Settings.shower_timer = false;
|
EMSESP_Settings.shower_timer = false;
|
||||||
}
|
}
|
||||||
set_showerTimer();
|
set_showerTimer();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// shower alert
|
// shower alert
|
||||||
@@ -1746,11 +1781,13 @@ void MQTTCallback(unsigned int type, const char * topic, const char * message) {
|
|||||||
EMSESP_Settings.shower_alert = false;
|
EMSESP_Settings.shower_alert = false;
|
||||||
}
|
}
|
||||||
set_showerAlert();
|
set_showerAlert();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// shower cold shot
|
// shower cold shot
|
||||||
if (strcmp(topic, TOPIC_SHOWER_COLDSHOT) == 0) {
|
if (strcmp(topic, TOPIC_SHOWER_COLDSHOT) == 0) {
|
||||||
_showerColdShotStart();
|
_showerColdShotStart();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1571,6 +1571,7 @@ void _process_RC30Set(_EMS_RxTelegram * EMS_RxTelegram) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// return which heating circuit it is, 1-4
|
// return which heating circuit it is, 1-4
|
||||||
|
// based on type 0x3E (HC1), 0x48 (HC2), 0x52 (HC3), 0x5C (HC4)
|
||||||
uint8_t _getHeatingCircuit(_EMS_RxTelegram * EMS_RxTelegram) {
|
uint8_t _getHeatingCircuit(_EMS_RxTelegram * EMS_RxTelegram) {
|
||||||
uint8_t hc_num;
|
uint8_t hc_num;
|
||||||
switch (EMS_RxTelegram->type) {
|
switch (EMS_RxTelegram->type) {
|
||||||
|
|||||||
@@ -16,11 +16,11 @@
|
|||||||
* Common Type
|
* Common Type
|
||||||
*/
|
*/
|
||||||
#define EMS_TYPE_Version 0x02
|
#define EMS_TYPE_Version 0x02
|
||||||
|
#define EMS_TYPE_UBADevices 0x07 // EMS connected devices
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Boiler Telegram Types...
|
* Boiler Telegram Types...
|
||||||
*/
|
*/
|
||||||
#define EMS_TYPE_UBADevices 0x07 // EMS connected devices
|
|
||||||
#define EMS_TYPE_UBAMonitorFast 0x18 // is an automatic monitor broadcast
|
#define EMS_TYPE_UBAMonitorFast 0x18 // is an automatic monitor broadcast
|
||||||
#define EMS_TYPE_UBAMonitorSlow 0x19 // is an automatic monitor broadcast
|
#define EMS_TYPE_UBAMonitorSlow 0x19 // is an automatic monitor broadcast
|
||||||
#define EMS_TYPE_UBAMonitorWWMessage 0x34 // is an automatic monitor broadcast
|
#define EMS_TYPE_UBAMonitorWWMessage 0x34 // is an automatic monitor broadcast
|
||||||
|
|||||||
@@ -18,7 +18,6 @@
|
|||||||
#define TOPIC_THERMOSTAT_DATA "thermostat_data" // for sending thermostat values to MQTT
|
#define TOPIC_THERMOSTAT_DATA "thermostat_data" // for sending thermostat values to MQTT
|
||||||
#define TOPIC_THERMOSTAT_CMD_TEMP "thermostat_cmd_temp" // temp changes via MQTT
|
#define TOPIC_THERMOSTAT_CMD_TEMP "thermostat_cmd_temp" // temp changes via MQTT
|
||||||
#define TOPIC_THERMOSTAT_CMD_MODE "thermostat_cmd_mode" // mode changes via MQTT
|
#define TOPIC_THERMOSTAT_CMD_MODE "thermostat_cmd_mode" // mode changes via MQTT
|
||||||
#define TOPIC_THERMOSTAT_CMD_HC "thermostat_cmd_hc" // hc number changes via MQTT
|
|
||||||
#define TOPIC_THERMOSTAT_CMD_DAYTEMP "thermostat_daytemp" // day temp (RC35 specific)
|
#define TOPIC_THERMOSTAT_CMD_DAYTEMP "thermostat_daytemp" // day temp (RC35 specific)
|
||||||
#define TOPIC_THERMOSTAT_CMD_NIGHTTEMP "thermostat_nighttemp" // night temp (RC35 specific)
|
#define TOPIC_THERMOSTAT_CMD_NIGHTTEMP "thermostat_nighttemp" // night temp (RC35 specific)
|
||||||
#define TOPIC_THERMOSTAT_CMD_HOLIDAYTEMP "thermostat_holidayttemp" // holiday temp (RC35 specific)
|
#define TOPIC_THERMOSTAT_CMD_HOLIDAYTEMP "thermostat_holidayttemp" // holiday temp (RC35 specific)
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
#define APP_VERSION "1.9.1b7"
|
#define APP_VERSION "1.9.1b8"
|
||||||
|
|||||||
Reference in New Issue
Block a user