nested publish for mixing, nofrosttemp, designtemp, roominfluence

This commit is contained in:
MichaelDvP
2020-10-11 15:46:22 +02:00
parent 97c948b623
commit 1ff5c9f9db
23 changed files with 137 additions and 56 deletions

View File

@@ -299,9 +299,21 @@ void EMSESP::publish_all() {
}
void EMSESP::publish_device_values(uint8_t device_type) {
if (device_type == EMSdevice::DeviceType::MIXING && Mqtt::mqtt_format() != Mqtt::Format::SINGLE) {
StaticJsonDocument<EMSESP_MAX_JSON_SIZE_MEDIUM> doc;
JsonObject output = doc.to<JsonObject>();
for (const auto & emsdevice : emsdevices) {
if (emsdevice && (emsdevice->device_type() == device_type)) {
emsdevice->publish_values(output);
}
}
Mqtt::publish("mixing_data", doc.as<JsonObject>());
return;
}
for (const auto & emsdevice : emsdevices) {
if (emsdevice && (emsdevice->device_type() == device_type)) {
emsdevice->publish_values();
JsonObject dummy;
emsdevice->publish_values(dummy);
}
}
}
@@ -310,7 +322,8 @@ void EMSESP::publish_other_values() {
for (const auto & emsdevice : emsdevices) {
if (emsdevice && (emsdevice->device_type() != EMSdevice::DeviceType::BOILER) && (emsdevice->device_type() != EMSdevice::DeviceType::THERMOSTAT)
&& (emsdevice->device_type() != EMSdevice::DeviceType::SOLAR) && (emsdevice->device_type() != EMSdevice::DeviceType::MIXING)) {
emsdevice->publish_values();
JsonObject dummy;
emsdevice->publish_values(dummy);
}
}
}
@@ -556,7 +569,7 @@ bool EMSESP::process_telegram(std::shared_ptr<const Telegram> telegram) {
if (telegram->type_id == publish_id_) {
publish_id_ = 0;
}
emsdevice->publish_values(); // publish to MQTT if we explicitly have too
publish_device_values(emsdevice->device_type()); // publish to MQTT if we explicitly have too
}
}
break;
@@ -695,6 +708,11 @@ bool EMSESP::add_device(const uint8_t device_id, const uint8_t product_id, std::
return true;
}
// send a read request, passing it into to the Tx Service, with offset
void EMSESP::send_read_request(const uint16_t type_id, const uint8_t dest, const uint8_t offset) {
txservice_.read_request(type_id, dest, offset);
}
// send a read request, passing it into to the Tx Service, with no offset
void EMSESP::send_read_request(const uint16_t type_id, const uint8_t dest) {
txservice_.read_request(type_id, dest, 0); // 0 = no offset