mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 00:09:51 +03:00
updated test
This commit is contained in:
@@ -817,7 +817,7 @@ std::shared_ptr<Thermostat::HeatingCircuit> Thermostat::heating_circuit(std::sha
|
|||||||
return heating_circuits_.back(); // even after sorting, this should still point back to the newly created HC
|
return heating_circuits_.back(); // even after sorting, this should still point back to the newly created HC
|
||||||
}
|
}
|
||||||
|
|
||||||
// publish config topic for HA MQTT Discovery
|
// publish config topic for HA MQTT Discovery for main thermostat values
|
||||||
// homeassistant/climate/ems-esp/thermostat/config
|
// homeassistant/climate/ems-esp/thermostat/config
|
||||||
void Thermostat::register_mqtt_ha_config() {
|
void Thermostat::register_mqtt_ha_config() {
|
||||||
StaticJsonDocument<EMSESP_MAX_JSON_SIZE_SMALL> doc;
|
StaticJsonDocument<EMSESP_MAX_JSON_SIZE_SMALL> doc;
|
||||||
@@ -871,7 +871,7 @@ void Thermostat::register_mqtt_ha_config() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// publish config topic for HA MQTT Discovery
|
// publish config topic for HA MQTT Discovery for each of the heating circuit
|
||||||
// e.g. homeassistant/climate/ems-esp/thermostat_hc1/config
|
// e.g. homeassistant/climate/ems-esp/thermostat_hc1/config
|
||||||
void Thermostat::register_mqtt_ha_config(uint8_t hc_num) {
|
void Thermostat::register_mqtt_ha_config(uint8_t hc_num) {
|
||||||
StaticJsonDocument<EMSESP_MAX_JSON_SIZE_MEDIUM> doc;
|
StaticJsonDocument<EMSESP_MAX_JSON_SIZE_MEDIUM> doc;
|
||||||
@@ -954,7 +954,7 @@ void Thermostat::register_mqtt_ha_config(uint8_t hc_num) {
|
|||||||
// for each of the heating circuits
|
// for each of the heating circuits
|
||||||
std::string topic2(100, '\0');
|
std::string topic2(100, '\0');
|
||||||
snprintf_P(&topic2[0], topic2.capacity() + 1, PSTR("thermostat_hc%d"), hc_num);
|
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}
|
char hc_name[10]; // hc{1-4}
|
||||||
strlcpy(hc_name, "hc", 10);
|
strlcpy(hc_name, "hc", 10);
|
||||||
@@ -963,6 +963,9 @@ void Thermostat::register_mqtt_ha_config(uint8_t hc_num) {
|
|||||||
|
|
||||||
Mqtt::register_mqtt_ha_sensor(hc_name, nullptr, F_(mode), this->device_type(), "mode", nullptr, nullptr);
|
Mqtt::register_mqtt_ha_sensor(hc_name, nullptr, F_(mode), this->device_type(), "mode", nullptr, nullptr);
|
||||||
|
|
||||||
|
Mqtt::register_mqtt_ha_sensor(hc_name, nullptr, F_(seltemp), this->device_type(), "seltemp", F_(degrees), F_(icontemperature));
|
||||||
|
Mqtt::register_mqtt_ha_sensor(hc_name, nullptr, F_(currtemp), this->device_type(), "currtemp", F_(degrees), F_(icontemperature));
|
||||||
|
|
||||||
uint8_t model = this->model();
|
uint8_t model = this->model();
|
||||||
switch (model) {
|
switch (model) {
|
||||||
case EMS_DEVICE_FLAG_RC100:
|
case EMS_DEVICE_FLAG_RC100:
|
||||||
|
|||||||
@@ -78,12 +78,12 @@ bool System::command_publish(const char * value, const int8_t id) {
|
|||||||
if (Helpers::value2string(value, ha)) {
|
if (Helpers::value2string(value, ha)) {
|
||||||
if (ha == "ha") {
|
if (ha == "ha") {
|
||||||
EMSESP::publish_all(true); // includes HA
|
EMSESP::publish_all(true); // includes HA
|
||||||
LOG_INFO(F("Published all data to MQTT, including HA configs"));
|
LOG_INFO(F("Publishing all data to MQTT, including HA configs"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
EMSESP::publish_all(); // ignore value and id
|
EMSESP::publish_all(); // ignore value and id
|
||||||
LOG_INFO(F("Published all data to MQTT"));
|
LOG_INFO(F("Publishing all data to MQTT"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user