diff --git a/src/devices/boiler.cpp b/src/devices/boiler.cpp index 31d74b15..cf348e0d 100644 --- a/src/devices/boiler.cpp +++ b/src/devices/boiler.cpp @@ -77,7 +77,6 @@ Boiler::Boiler(uint8_t device_type, int8_t device_id, uint8_t product_id, const register_mqtt_cmd(F("pumpmodmax"), [&](const char * value, const int8_t id) { return set_max_pump(value, id); }); register_mqtt_cmd(F("pumpmodmin"), [&](const char * value, const int8_t id) { return set_min_pump(value, id); }); - EMSESP::send_read_request(0x10, device_id); // read last errorcode on start (only published on errors) EMSESP::send_read_request(0x11, device_id); // read last errorcode on start (only published on errors) EMSESP::send_read_request(0x15, device_id); // read maintenace data on start (only published on change) @@ -214,114 +213,118 @@ void Boiler::register_mqtt_ha_config_ww() { } // send stuff to the Web UI -void Boiler::device_info_web(JsonArray & root) { +void Boiler::device_info_web(JsonArray & root, uint8_t & part) { // fetch the values into a JSON document StaticJsonDocument doc; JsonObject json = doc.to(); - if (!export_values_main(json, true)) { - return; // empty - } - - create_value_json(root, F("heatingActive"), nullptr, F_(heatingActive), nullptr, json); - create_value_json(root, F("tapwaterActive"), nullptr, F_(tapwaterActive), nullptr, json); - create_value_json(root, F("serviceCode"), nullptr, F_(serviceCode), nullptr, json); - create_value_json(root, F("serviceCodeNumber"), nullptr, F_(serviceCodeNumber), nullptr, json); - create_value_json(root, F("lastCode"), nullptr, F_(lastCode), nullptr, json); - create_value_json(root, F("selFlowTemp"), nullptr, F_(selFlowTemp), F_(degrees), json); - create_value_json(root, F("selBurnPow"), nullptr, F_(selBurnPow), F_(percent), json); - create_value_json(root, F("curBurnPow"), nullptr, F_(curBurnPow), F_(percent), json); - create_value_json(root, F("pumpMod"), nullptr, F_(pumpMod), F_(percent), json); - create_value_json(root, F("pumpMod2"), nullptr, F_(pumpMod2), F_(percent), json); - create_value_json(root, F("outdoorTemp"), nullptr, F_(outdoorTemp), F_(degrees), json); - create_value_json(root, F("curFlowTemp"), nullptr, F_(curFlowTemp), F_(degrees), json); - create_value_json(root, F("retTemp"), nullptr, F_(retTemp), F_(degrees), json); - create_value_json(root, F("switchTemp"), nullptr, F_(switchTemp), F_(degrees), json); - create_value_json(root, F("sysPress"), nullptr, F_(sysPress), nullptr, json); - create_value_json(root, F("boilTemp"), nullptr, F_(boilTemp), F_(degrees), json); - create_value_json(root, F("burnGas"), nullptr, F_(burnGas), nullptr, json); - create_value_json(root, F("flameCurr"), nullptr, F_(flameCurr), F_(uA), json); - create_value_json(root, F("heatPump"), nullptr, F_(heatPump), nullptr, json); - create_value_json(root, F("fanWork"), nullptr, F_(fanWork), nullptr, json); - create_value_json(root, F("ignWork"), nullptr, F_(ignWork), nullptr, json); - create_value_json(root, F("heatingActivated"), nullptr, F_(heatingActivated), nullptr, json); - create_value_json(root, F("heatingTemp"), nullptr, F_(heatingTemp), F_(degrees), json); - create_value_json(root, F("pumpModMax"), nullptr, F_(pumpModMax), F_(percent), json); - create_value_json(root, F("pumpModMin"), nullptr, F_(pumpModMin), F_(percent), json); - create_value_json(root, F("pumpDelay"), nullptr, F_(pumpDelay), F_(min), json); - create_value_json(root, F("burnMinPeriod"), nullptr, F_(burnMinPeriod), F_(min), json); - create_value_json(root, F("burnMinPower"), nullptr, F_(burnMinPower), F_(percent), json); - create_value_json(root, F("burnMaxPower"), nullptr, F_(burnMaxPower), F_(percent), json); - create_value_json(root, F("boilHystOn"), nullptr, F_(boilHystOn), F_(degrees), json); - create_value_json(root, F("boilHystOff"), nullptr, F_(boilHystOff), F_(degrees), json); - create_value_json(root, F("setFlowTemp"), nullptr, F_(setFlowTemp), F_(degrees), json); - create_value_json(root, F("setBurnPow"), nullptr, F_(setBurnPow), F_(percent), json); - create_value_json(root, F("burnStarts"), nullptr, F_(burnStarts), nullptr, json); - create_value_json(root, F("burnWorkMin"), nullptr, F_(burnWorkMin), nullptr, json); - create_value_json(root, F("heatWorkMin"), nullptr, F_(heatWorkMin), nullptr, json); - create_value_json(root, F("UBAuptime"), nullptr, F_(UBAuptime), nullptr, json); + if (part == 0) { + if (!export_values_main(json, true)) { + return; // empty + } - // information - create_value_json(root, F("upTimeControl"), nullptr, F_(upTimeControl), nullptr, json); - create_value_json(root, F("upTimeCompHeating"), nullptr, F_(upTimeCompHeating), nullptr, json); - create_value_json(root, F("upTimeCompCooling"), nullptr, F_(upTimeCompCooling), nullptr, json); - create_value_json(root, F("upTimeCompWw"), nullptr, F_(upTimeCompWw), nullptr, json); - create_value_json(root, F("heatingStarts"), nullptr, F_(heatingStarts), nullptr, json); - create_value_json(root, F("coolingStarts"), nullptr, F_(coolingStarts), nullptr, json); - create_value_json(root, F("wWStarts2"), nullptr, F_(wWStarts2), nullptr, json); - create_value_json(root, F("nrgConsTotal"), nullptr, F_(nrgConsTotal), F_(kwh), json); - create_value_json(root, F("auxElecHeatNrgConsTotal"), nullptr, F_(auxElecHeatNrgConsTotal), F_(kwh), json); - create_value_json(root, F("auxElecHeatNrgConsHeating"), nullptr, F_(auxElecHeatNrgConsHeating), F_(kwh), json); - create_value_json(root, F("auxElecHeatNrgConsDHW"), nullptr, F_(auxElecHeatNrgConsDHW), F_(kwh), json); - create_value_json(root, F("nrgConsCompTotal"), nullptr, F_(nrgConsCompTotal), F_(kwh), json); - create_value_json(root, F("nrgConsCompHeating"), nullptr, F_(nrgConsCompHeating), F_(kwh), json); - create_value_json(root, F("nrgConsCompWw"), nullptr, F_(nrgConsCompWw), F_(kwh), json); - create_value_json(root, F("nrgConsCoolingTotal"), nullptr, F_(nrgConsCompCooling), F_(kwh), json); - create_value_json(root, F("nrgSuppTotal"), nullptr, F_(nrgSuppTotal), F_(kwh), json); - create_value_json(root, F("nrgSuppHeating"), nullptr, F_(nrgSuppHeating), F_(kwh), json); - create_value_json(root, F("nrgSuppWw"), nullptr, F_(nrgSuppWw), F_(kwh), json); - create_value_json(root, F("nrgSuppCooling"), nullptr, F_(nrgSuppCooling), F_(kwh), json); - create_value_json(root, F("maintenanceMessage"), nullptr, F_(maintenanceMessage), nullptr, json); - if (maintenanceType_ == 1) { - create_value_json(root, F("maintenance"), nullptr, F_(maintenance), F_(hours), json); - } else { - create_value_json(root, F("maintenance"), nullptr, F_(maintenance), nullptr, json); - } - // create_value_json(root, F("maintenance"), nullptr, F_(maintenance), nullptr, json); - // create_value_json(root, F("maintenanceTime"), nullptr, F_(maintenanceTime), F_(hours), json); - // create_value_json(root, F("maintenanceDate"), nullptr, F_(maintenanceDate), nullptr, json); - doc.clear(); - if (!export_values_ww(json, true)) { // append ww values - return; - } + create_value_json(root, F("heatingActive"), nullptr, F_(heatingActive), nullptr, json); + create_value_json(root, F("tapwaterActive"), nullptr, F_(tapwaterActive), nullptr, json); + create_value_json(root, F("serviceCode"), nullptr, F_(serviceCode), nullptr, json); + create_value_json(root, F("serviceCodeNumber"), nullptr, F_(serviceCodeNumber), nullptr, json); + create_value_json(root, F("lastCode"), nullptr, F_(lastCode), nullptr, json); + create_value_json(root, F("selFlowTemp"), nullptr, F_(selFlowTemp), F_(degrees), json); + create_value_json(root, F("selBurnPow"), nullptr, F_(selBurnPow), F_(percent), json); + create_value_json(root, F("curBurnPow"), nullptr, F_(curBurnPow), F_(percent), json); + create_value_json(root, F("pumpMod"), nullptr, F_(pumpMod), F_(percent), json); + create_value_json(root, F("pumpMod2"), nullptr, F_(pumpMod2), F_(percent), json); + create_value_json(root, F("outdoorTemp"), nullptr, F_(outdoorTemp), F_(degrees), json); + create_value_json(root, F("curFlowTemp"), nullptr, F_(curFlowTemp), F_(degrees), json); + create_value_json(root, F("retTemp"), nullptr, F_(retTemp), F_(degrees), json); + create_value_json(root, F("switchTemp"), nullptr, F_(switchTemp), F_(degrees), json); + create_value_json(root, F("sysPress"), nullptr, F_(sysPress), nullptr, json); + create_value_json(root, F("boilTemp"), nullptr, F_(boilTemp), F_(degrees), json); + create_value_json(root, F("burnGas"), nullptr, F_(burnGas), nullptr, json); + create_value_json(root, F("flameCurr"), nullptr, F_(flameCurr), F_(uA), json); + create_value_json(root, F("heatPump"), nullptr, F_(heatPump), nullptr, json); + create_value_json(root, F("fanWork"), nullptr, F_(fanWork), nullptr, json); + create_value_json(root, F("ignWork"), nullptr, F_(ignWork), nullptr, json); + create_value_json(root, F("heatingActivated"), nullptr, F_(heatingActivated), nullptr, json); + create_value_json(root, F("heatingTemp"), nullptr, F_(heatingTemp), F_(degrees), json); + create_value_json(root, F("pumpModMax"), nullptr, F_(pumpModMax), F_(percent), json); + create_value_json(root, F("pumpModMin"), nullptr, F_(pumpModMin), F_(percent), json); + create_value_json(root, F("pumpDelay"), nullptr, F_(pumpDelay), F_(min), json); + create_value_json(root, F("burnMinPeriod"), nullptr, F_(burnMinPeriod), F_(min), json); + create_value_json(root, F("burnMinPower"), nullptr, F_(burnMinPower), F_(percent), json); + create_value_json(root, F("burnMaxPower"), nullptr, F_(burnMaxPower), F_(percent), json); + create_value_json(root, F("boilHystOn"), nullptr, F_(boilHystOn), F_(degrees), json); + create_value_json(root, F("boilHystOff"), nullptr, F_(boilHystOff), F_(degrees), json); + create_value_json(root, F("setFlowTemp"), nullptr, F_(setFlowTemp), F_(degrees), json); + create_value_json(root, F("setBurnPow"), nullptr, F_(setBurnPow), F_(percent), json); + create_value_json(root, F("burnStarts"), nullptr, F_(burnStarts), nullptr, json); + create_value_json(root, F("burnWorkMin"), nullptr, F_(burnWorkMin), nullptr, json); + create_value_json(root, F("heatWorkMin"), nullptr, F_(heatWorkMin), nullptr, json); + create_value_json(root, F("UBAuptime"), nullptr, F_(UBAuptime), nullptr, json); + + // information + create_value_json(root, F("upTimeControl"), nullptr, F_(upTimeControl), nullptr, json); + create_value_json(root, F("upTimeCompHeating"), nullptr, F_(upTimeCompHeating), nullptr, json); + create_value_json(root, F("upTimeCompCooling"), nullptr, F_(upTimeCompCooling), nullptr, json); + create_value_json(root, F("upTimeCompWw"), nullptr, F_(upTimeCompWw), nullptr, json); + create_value_json(root, F("heatingStarts"), nullptr, F_(heatingStarts), nullptr, json); + create_value_json(root, F("coolingStarts"), nullptr, F_(coolingStarts), nullptr, json); + create_value_json(root, F("wWStarts2"), nullptr, F_(wWStarts2), nullptr, json); + create_value_json(root, F("nrgConsTotal"), nullptr, F_(nrgConsTotal), F_(kwh), json); + create_value_json(root, F("auxElecHeatNrgConsTotal"), nullptr, F_(auxElecHeatNrgConsTotal), F_(kwh), json); + create_value_json(root, F("auxElecHeatNrgConsHeating"), nullptr, F_(auxElecHeatNrgConsHeating), F_(kwh), json); + create_value_json(root, F("auxElecHeatNrgConsDHW"), nullptr, F_(auxElecHeatNrgConsDHW), F_(kwh), json); + create_value_json(root, F("nrgConsCompTotal"), nullptr, F_(nrgConsCompTotal), F_(kwh), json); + create_value_json(root, F("nrgConsCompHeating"), nullptr, F_(nrgConsCompHeating), F_(kwh), json); + create_value_json(root, F("nrgConsCompWw"), nullptr, F_(nrgConsCompWw), F_(kwh), json); + create_value_json(root, F("nrgConsCoolingTotal"), nullptr, F_(nrgConsCompCooling), F_(kwh), json); + create_value_json(root, F("nrgSuppTotal"), nullptr, F_(nrgSuppTotal), F_(kwh), json); + create_value_json(root, F("nrgSuppHeating"), nullptr, F_(nrgSuppHeating), F_(kwh), json); + create_value_json(root, F("nrgSuppWw"), nullptr, F_(nrgSuppWw), F_(kwh), json); + create_value_json(root, F("nrgSuppCooling"), nullptr, F_(nrgSuppCooling), F_(kwh), json); + create_value_json(root, F("maintenanceMessage"), nullptr, F_(maintenanceMessage), nullptr, json); + if (maintenanceType_ == 1) { + create_value_json(root, F("maintenance"), nullptr, F_(maintenance), F_(hours), json); + } else { + create_value_json(root, F("maintenance"), nullptr, F_(maintenance), nullptr, json); + } + // create_value_json(root, F("maintenance"), nullptr, F_(maintenance), nullptr, json); + // create_value_json(root, F("maintenanceTime"), nullptr, F_(maintenanceTime), F_(hours), json); + // create_value_json(root, F("maintenanceDate"), nullptr, F_(maintenanceDate), nullptr, json); + part++; + } else if (part == 1) { + if (!export_values_ww(json, true)) { // append ww values + return; + } - // ww - create_value_json(root, F("wWSelTemp"), nullptr, F_(wWSelTemp), F_(degrees), json); - create_value_json(root, F("wWSetTemp"), nullptr, F_(wWSetTemp), F_(degrees), json); - create_value_json(root, F("wWDisinfectionTemp"), nullptr, F_(wWDisinfectionTemp), F_(degrees), json); - create_value_json(root, F("wWType"), nullptr, F_(wWType), nullptr, json); - create_value_json(root, F("wWChargeType"), nullptr, F_(wWChargeType), nullptr, json); - create_value_json(root, F("wWCircPump"), nullptr, F_(wWCircPump), nullptr, json); - create_value_json(root, F("wWCircPumpMode"), nullptr, F_(wWCircPumpMode), nullptr, json); - create_value_json(root, F("wWCirc"), nullptr, F_(wWCirc), nullptr, json); - create_value_json(root, F("wWCurTemp"), nullptr, F_(wWCurTemp), F_(degrees), json); - create_value_json(root, F("wWCurTemp2"), nullptr, F_(wWCurTemp2), F_(degrees), json); - create_value_json(root, F("wWCurFlow"), nullptr, F_(wWCurFlow), F("l/min"), json); - create_value_json(root, F("wwStorageTemp1"), nullptr, F_(wwStorageTemp1), F_(degrees), json); - create_value_json(root, F("wwStorageTemp2"), nullptr, F_(wwStorageTemp2), F_(degrees), json); - create_value_json(root, F("exhaustTemp"), nullptr, F_(exhaustTemp), F_(degrees), json); - create_value_json(root, F("wWActivated"), nullptr, F_(wWActivated), nullptr, json); - create_value_json(root, F("wWOneTime"), nullptr, F_(wWOneTime), nullptr, json); - create_value_json(root, F("wWDisinfecting"), nullptr, F_(wWDisinfecting), nullptr, json); - create_value_json(root, F("wWCharging"), nullptr, F_(wWCharging), nullptr, json); - create_value_json(root, F("wWRecharging"), nullptr, F_(wWRecharging), nullptr, json); - create_value_json(root, F("wWTempOK"), nullptr, F_(wWTempOK), nullptr, json); - create_value_json(root, F("wWActive"), nullptr, F_(wWActive), nullptr, json); - create_value_json(root, F("wWHeat"), nullptr, F_(wWHeat), nullptr, json); - create_value_json(root, F("wWSetPumpPower"), nullptr, F_(wWSetPumpPower), F_(percent), json); - create_value_json(root, F("wwMixTemperature"), nullptr, F_(wwMixTemperature), F_(degrees), json); - create_value_json(root, F("wwBufferTemperature"), nullptr, F_(wwBufferTemperature), F_(degrees), json); - create_value_json(root, F("wWStarts"), nullptr, F_(wWStarts), nullptr, json); - create_value_json(root, F("wWWorkM"), nullptr, F_(wWWorkM), nullptr, json); + // ww + create_value_json(root, F("wWSelTemp"), nullptr, F_(wWSelTemp), F_(degrees), json); + create_value_json(root, F("wWSetTemp"), nullptr, F_(wWSetTemp), F_(degrees), json); + create_value_json(root, F("wWDisinfectionTemp"), nullptr, F_(wWDisinfectionTemp), F_(degrees), json); + create_value_json(root, F("wWType"), nullptr, F_(wWType), nullptr, json); + create_value_json(root, F("wWChargeType"), nullptr, F_(wWChargeType), nullptr, json); + create_value_json(root, F("wWCircPump"), nullptr, F_(wWCircPump), nullptr, json); + create_value_json(root, F("wWCircPumpMode"), nullptr, F_(wWCircPumpMode), nullptr, json); + create_value_json(root, F("wWCirc"), nullptr, F_(wWCirc), nullptr, json); + create_value_json(root, F("wWCurTemp"), nullptr, F_(wWCurTemp), F_(degrees), json); + create_value_json(root, F("wWCurTemp2"), nullptr, F_(wWCurTemp2), F_(degrees), json); + create_value_json(root, F("wWCurFlow"), nullptr, F_(wWCurFlow), F("l/min"), json); + create_value_json(root, F("wwStorageTemp1"), nullptr, F_(wwStorageTemp1), F_(degrees), json); + create_value_json(root, F("wwStorageTemp2"), nullptr, F_(wwStorageTemp2), F_(degrees), json); + create_value_json(root, F("exhaustTemp"), nullptr, F_(exhaustTemp), F_(degrees), json); + create_value_json(root, F("wWActivated"), nullptr, F_(wWActivated), nullptr, json); + create_value_json(root, F("wWOneTime"), nullptr, F_(wWOneTime), nullptr, json); + create_value_json(root, F("wWDisinfecting"), nullptr, F_(wWDisinfecting), nullptr, json); + create_value_json(root, F("wWCharging"), nullptr, F_(wWCharging), nullptr, json); + create_value_json(root, F("wWRecharging"), nullptr, F_(wWRecharging), nullptr, json); + create_value_json(root, F("wWTempOK"), nullptr, F_(wWTempOK), nullptr, json); + create_value_json(root, F("wWActive"), nullptr, F_(wWActive), nullptr, json); + create_value_json(root, F("wWHeat"), nullptr, F_(wWHeat), nullptr, json); + create_value_json(root, F("wWSetPumpPower"), nullptr, F_(wWSetPumpPower), F_(percent), json); + create_value_json(root, F("wwMixTemperature"), nullptr, F_(wwMixTemperature), F_(degrees), json); + create_value_json(root, F("wwBufferTemperature"), nullptr, F_(wwBufferTemperature), F_(degrees), json); + create_value_json(root, F("wWStarts"), nullptr, F_(wWStarts), nullptr, json); + create_value_json(root, F("wWWorkM"), nullptr, F_(wWWorkM), nullptr, json); + part = 0; // no more parts + } } bool Boiler::export_values(JsonObject & json) { @@ -1308,6 +1311,7 @@ bool Boiler::set_flow_temp(const char * value, const int8_t id) { LOG_INFO(F("Setting boiler flow temperature to %d C"), v); // some boiler have it in 0x1A, some in 0x35, but both telegrams are sometimes writeonly + write_command(0x35, 3, v); write_command(EMS_TYPE_UBASetPoints, 0, v, EMS_TYPE_UBASetPoints); // write_command(0x35, 3, v, 0x35); diff --git a/src/devices/boiler.h b/src/devices/boiler.h index afdb81bc..4e803b32 100644 --- a/src/devices/boiler.h +++ b/src/devices/boiler.h @@ -40,7 +40,7 @@ class Boiler : public EMSdevice { virtual void publish_values(JsonObject & json, bool force); virtual bool export_values(JsonObject & json); - virtual void device_info_web(JsonArray & root); + virtual void device_info_web(JsonArray & root, uint8_t & part); virtual bool updated_values(); private: diff --git a/src/devices/connect.cpp b/src/devices/connect.cpp index 401f08aa..f48e1365 100644 --- a/src/devices/connect.cpp +++ b/src/devices/connect.cpp @@ -28,7 +28,7 @@ Connect::Connect(uint8_t device_type, uint8_t device_id, uint8_t product_id, con : EMSdevice(device_type, device_id, product_id, version, name, flags, brand) { } -void Connect::device_info_web(JsonArray & root) { +void Connect::device_info_web(JsonArray & root, uint8_t & part) { } // publish values via MQTT diff --git a/src/devices/connect.h b/src/devices/connect.h index 40991315..6c15df47 100644 --- a/src/devices/connect.h +++ b/src/devices/connect.h @@ -37,7 +37,7 @@ class Connect : public EMSdevice { virtual void publish_values(JsonObject & json, bool force); virtual bool export_values(JsonObject & json); - virtual void device_info_web(JsonArray & root); + virtual void device_info_web(JsonArray & root, uint8_t & part); virtual bool updated_values(); private: diff --git a/src/devices/controller.cpp b/src/devices/controller.cpp index 7acc5460..b7c490b6 100644 --- a/src/devices/controller.cpp +++ b/src/devices/controller.cpp @@ -28,7 +28,7 @@ Controller::Controller(uint8_t device_type, uint8_t device_id, uint8_t product_i : EMSdevice(device_type, device_id, product_id, version, name, flags, brand) { } -void Controller::device_info_web(JsonArray & root) { +void Controller::device_info_web(JsonArray & root, uint8_t & part) { } // publish values via MQTT diff --git a/src/devices/controller.h b/src/devices/controller.h index 1db0222a..d7aa009f 100644 --- a/src/devices/controller.h +++ b/src/devices/controller.h @@ -37,7 +37,7 @@ class Controller : public EMSdevice { virtual void publish_values(JsonObject & json, bool force); virtual bool export_values(JsonObject & json); - virtual void device_info_web(JsonArray & root); + virtual void device_info_web(JsonArray & root, uint8_t & part); virtual bool updated_values(); private: diff --git a/src/devices/gateway.cpp b/src/devices/gateway.cpp index 9a0827f1..a0f414ac 100644 --- a/src/devices/gateway.cpp +++ b/src/devices/gateway.cpp @@ -28,7 +28,7 @@ Gateway::Gateway(uint8_t device_type, uint8_t device_id, uint8_t product_id, con : EMSdevice(device_type, device_id, product_id, version, name, flags, brand) { } -void Gateway::device_info_web(JsonArray & root) { +void Gateway::device_info_web(JsonArray & root, uint8_t & part) { } // publish values via MQTT diff --git a/src/devices/gateway.h b/src/devices/gateway.h index 92563e00..21eaa732 100644 --- a/src/devices/gateway.h +++ b/src/devices/gateway.h @@ -37,7 +37,7 @@ class Gateway : public EMSdevice { virtual void publish_values(JsonObject & json, bool force); virtual bool export_values(JsonObject & json); - virtual void device_info_web(JsonArray & root); + virtual void device_info_web(JsonArray & root, uint8_t & part); virtual bool updated_values(); private: diff --git a/src/devices/generic.cpp b/src/devices/generic.cpp index 749c01ed..5a182d20 100644 --- a/src/devices/generic.cpp +++ b/src/devices/generic.cpp @@ -28,7 +28,7 @@ Generic::Generic(uint8_t device_type, uint8_t device_id, uint8_t product_id, con : EMSdevice(device_type, device_id, product_id, version, name, flags, brand) { } -void Generic::device_info_web(JsonArray & root) { +void Generic::device_info_web(JsonArray & root, uint8_t & part) { } // publish values via MQTT diff --git a/src/devices/generic.h b/src/devices/generic.h index 4762bd9c..9655bdc0 100644 --- a/src/devices/generic.h +++ b/src/devices/generic.h @@ -37,7 +37,7 @@ class Generic : public EMSdevice { virtual void publish_values(JsonObject & json, bool force); virtual bool export_values(JsonObject & json); - virtual void device_info_web(JsonArray & root); + virtual void device_info_web(JsonArray & root, uint8_t & part); virtual bool updated_values(); private: diff --git a/src/devices/heatpump.cpp b/src/devices/heatpump.cpp index 8245d1b6..e48a9560 100644 --- a/src/devices/heatpump.cpp +++ b/src/devices/heatpump.cpp @@ -47,7 +47,7 @@ bool Heatpump::export_values(JsonObject & json) { return json.size(); } -void Heatpump::device_info_web(JsonArray & root) { +void Heatpump::device_info_web(JsonArray & root, uint8_t & part) { // fetch the values into a JSON document StaticJsonDocument doc; JsonObject json = doc.to(); diff --git a/src/devices/heatpump.h b/src/devices/heatpump.h index 6685df54..c30b01a4 100644 --- a/src/devices/heatpump.h +++ b/src/devices/heatpump.h @@ -38,7 +38,7 @@ class Heatpump : public EMSdevice { virtual void publish_values(JsonObject & json, bool force); virtual bool export_values(JsonObject & json); - virtual void device_info_web(JsonArray & root); + virtual void device_info_web(JsonArray & root, uint8_t & part); virtual bool updated_values(); private: diff --git a/src/devices/mixer.cpp b/src/devices/mixer.cpp index 7b9a7a03..30dce341 100644 --- a/src/devices/mixer.cpp +++ b/src/devices/mixer.cpp @@ -56,7 +56,7 @@ Mixer::Mixer(uint8_t device_type, uint8_t device_id, uint8_t product_id, const s } // output json to web UI -void Mixer::device_info_web(JsonArray & root) { +void Mixer::device_info_web(JsonArray & root, uint8_t & part) { if (type() == Type::NONE) { return; // don't have any values yet } diff --git a/src/devices/mixer.h b/src/devices/mixer.h index 4ad5d044..256cd674 100644 --- a/src/devices/mixer.h +++ b/src/devices/mixer.h @@ -38,7 +38,7 @@ class Mixer : public EMSdevice { virtual void publish_values(JsonObject & json, bool force); virtual bool export_values(JsonObject & json); - virtual void device_info_web(JsonArray & root); + virtual void device_info_web(JsonArray & root, uint8_t & part); virtual bool updated_values(); private: diff --git a/src/devices/solar.cpp b/src/devices/solar.cpp index 17751b48..a6a25c6f 100644 --- a/src/devices/solar.cpp +++ b/src/devices/solar.cpp @@ -62,7 +62,7 @@ Solar::Solar(uint8_t device_type, uint8_t device_id, uint8_t product_id, const s } // print to web -void Solar::device_info_web(JsonArray & root) { +void Solar::device_info_web(JsonArray & root, uint8_t & part) { // fetch the values into a JSON document StaticJsonDocument doc; JsonObject json = doc.to(); diff --git a/src/devices/solar.h b/src/devices/solar.h index 33b54c5a..1e8b5ef7 100644 --- a/src/devices/solar.h +++ b/src/devices/solar.h @@ -38,7 +38,7 @@ class Solar : public EMSdevice { virtual void publish_values(JsonObject & json, bool force); virtual bool export_values(JsonObject & json); - virtual void device_info_web(JsonArray & root); + virtual void device_info_web(JsonArray & root, uint8_t & part); virtual bool updated_values(); private: diff --git a/src/devices/switch.cpp b/src/devices/switch.cpp index f7d0ed92..bdf0254d 100644 --- a/src/devices/switch.cpp +++ b/src/devices/switch.cpp @@ -36,7 +36,7 @@ Switch::Switch(uint8_t device_type, uint8_t device_id, uint8_t product_id, const } // fetch the values into a JSON document for display in the web -void Switch::device_info_web(JsonArray & root) { +void Switch::device_info_web(JsonArray & root, uint8_t & part) { StaticJsonDocument doc; JsonObject json = doc.to(); if (export_values(json)) { diff --git a/src/devices/switch.h b/src/devices/switch.h index 6a6f4436..c0fa02ec 100644 --- a/src/devices/switch.h +++ b/src/devices/switch.h @@ -38,7 +38,7 @@ class Switch : public EMSdevice { virtual void publish_values(JsonObject & json, bool force); virtual bool export_values(JsonObject & json); - virtual void device_info_web(JsonArray & root); + virtual void device_info_web(JsonArray & root, uint8_t & part); virtual bool updated_values(); private: diff --git a/src/devices/thermostat.cpp b/src/devices/thermostat.cpp index 62686351..0c2ae5a2 100644 --- a/src/devices/thermostat.cpp +++ b/src/devices/thermostat.cpp @@ -187,70 +187,73 @@ Thermostat::Thermostat(uint8_t device_type, uint8_t device_id, uint8_t product_i } // prepare data for Web UI -void Thermostat::device_info_web(JsonArray & root) { +void Thermostat::device_info_web(JsonArray & root, uint8_t & part) { StaticJsonDocument doc; - JsonObject json_main = doc.to(); - if (export_values_main(json_main)) { - create_value_json(root, F("time"), nullptr, F_(time), nullptr, json_main); - create_value_json(root, F("errorcode"), nullptr, F_(error), nullptr, json_main); - create_value_json(root, F("lastcode"), nullptr, F_(lastCode), nullptr, json_main); - create_value_json(root, F("display"), nullptr, F_(display), nullptr, json_main); - create_value_json(root, F("language"), nullptr, F_(language), nullptr, json_main); - create_value_json(root, F("offsetclock"), nullptr, F_(offsetclock), nullptr, json_main); - create_value_json(root, F("dampedtemp"), nullptr, F_(dampedtemp), F_(degrees), json_main); - create_value_json(root, F("inttemp1"), nullptr, F_(inttemp1), F_(degrees), json_main); - create_value_json(root, F("inttemp2"), nullptr, F_(inttemp2), F_(degrees), json_main); - create_value_json(root, F("intoffset"), nullptr, F_(intoffset), nullptr, json_main); - create_value_json(root, F("minexttemp"), nullptr, F_(minexttemp), F_(degrees), json_main); - create_value_json(root, F("building"), nullptr, F_(building), nullptr, json_main); - create_value_json(root, F("floordry"), nullptr, F_(floordry), nullptr, json_main); - create_value_json(root, F("floordrytemp"), nullptr, F_(floordrytemp), F_(degrees), json_main); - create_value_json(root, F("wwmode"), nullptr, F_(wwmode), nullptr, json_main); - create_value_json(root, F("wwtemp"), nullptr, F_(wwtemp), nullptr, json_main); - create_value_json(root, F("wwtemplow"), nullptr, F_(wwtemplow), nullptr, json_main); - create_value_json(root, F("wwextra1"), nullptr, F_(wwextra1), nullptr, json_main); - create_value_json(root, F("wwcircmode"), nullptr, F_(wwcircmode), nullptr, json_main); - } - doc.clear(); - JsonObject json_hc = doc.to(); - - if (export_values_hc(Mqtt::Format::NESTED, json_hc)) { - // display for each active heating circuit - for (const auto & hc : heating_circuits_) { - if (hc->is_active()) { - char prefix_str[10]; - snprintf_P(prefix_str, sizeof(prefix_str), PSTR("hc%d"), hc->hc_num()); - JsonObject json = json_hc[prefix_str]; - - snprintf_P(prefix_str, sizeof(prefix_str), PSTR("(hc %d) "), hc->hc_num()); - - create_value_json(root, F("seltemp"), FPSTR(prefix_str), F_(seltemp), F_(degrees), json); - create_value_json(root, F("currtemp"), FPSTR(prefix_str), F_(currtemp), F_(degrees), json); - create_value_json(root, F("heattemp"), FPSTR(prefix_str), F_(heattemp), F_(degrees), json); - create_value_json(root, F("comforttemp"), FPSTR(prefix_str), F_(comforttemp), F_(degrees), json); - create_value_json(root, F("daytemp"), FPSTR(prefix_str), F_(daytemp), F_(degrees), json); - create_value_json(root, F("ecotemp"), FPSTR(prefix_str), F_(ecotemp), F_(degrees), json); - create_value_json(root, F("nighttemp"), FPSTR(prefix_str), F_(nighttemp), F_(degrees), json); - create_value_json(root, F("manualtemp"), FPSTR(prefix_str), F_(manualtemp), F_(degrees), json); - create_value_json(root, F("holidaytemp"), FPSTR(prefix_str), F_(holidaytemp), F_(degrees), json); - create_value_json(root, F("nofrosttemp"), FPSTR(prefix_str), F_(nofrosttemp), F_(degrees), json); - create_value_json(root, F("heatingtype"), FPSTR(prefix_str), F_(heatingtype), nullptr, json); - create_value_json(root, F("targetflowtemp"), FPSTR(prefix_str), F_(targetflowtemp), F_(degrees), json); - create_value_json(root, F("offsettemp"), FPSTR(prefix_str), F_(offsettemp), F_(degrees), json); - create_value_json(root, F("designtemp"), FPSTR(prefix_str), F_(designtemp), F_(degrees), json); - create_value_json(root, F("roominfluence"), FPSTR(prefix_str), F_(roominfluence), F_(degrees), json); - create_value_json(root, F("flowtempoffset"), FPSTR(prefix_str), F_(flowtempoffset), F_(degrees), json); - create_value_json(root, F("minflowtemp"), FPSTR(prefix_str), F_(minflowtemp), F_(degrees), json); - create_value_json(root, F("maxflowtemp"), FPSTR(prefix_str), F_(maxflowtemp), F_(degrees), json); - create_value_json(root, F("summertemp"), FPSTR(prefix_str), F_(summertemp), F_(degrees), json); - create_value_json(root, F("summermode"), FPSTR(prefix_str), F_(summermode), F_(degrees), json); - create_value_json(root, F("reducemode"), FPSTR(prefix_str), F_(reducemode), nullptr, json); - create_value_json(root, F("program"), FPSTR(prefix_str), F_(program), nullptr, json); - create_value_json(root, F("controlmode"), FPSTR(prefix_str), F_(controlmode), nullptr, json); - create_value_json(root, F("mode"), FPSTR(prefix_str), F_(mode), nullptr, json); - create_value_json(root, F("modetype"), FPSTR(prefix_str), F_(modetype), nullptr, json); + if (part == 0) { + JsonObject json_main = doc.to(); + if (export_values_main(json_main)) { + create_value_json(root, F("time"), nullptr, F_(time), nullptr, json_main); + create_value_json(root, F("errorcode"), nullptr, F_(error), nullptr, json_main); + create_value_json(root, F("lastcode"), nullptr, F_(lastCode), nullptr, json_main); + create_value_json(root, F("display"), nullptr, F_(display), nullptr, json_main); + create_value_json(root, F("language"), nullptr, F_(language), nullptr, json_main); + create_value_json(root, F("offsetclock"), nullptr, F_(offsetclock), nullptr, json_main); + create_value_json(root, F("dampedtemp"), nullptr, F_(dampedtemp), F_(degrees), json_main); + create_value_json(root, F("inttemp1"), nullptr, F_(inttemp1), F_(degrees), json_main); + create_value_json(root, F("inttemp2"), nullptr, F_(inttemp2), F_(degrees), json_main); + create_value_json(root, F("intoffset"), nullptr, F_(intoffset), nullptr, json_main); + create_value_json(root, F("minexttemp"), nullptr, F_(minexttemp), F_(degrees), json_main); + create_value_json(root, F("building"), nullptr, F_(building), nullptr, json_main); + create_value_json(root, F("floordry"), nullptr, F_(floordry), nullptr, json_main); + create_value_json(root, F("floordrytemp"), nullptr, F_(floordrytemp), F_(degrees), json_main); + create_value_json(root, F("wwmode"), nullptr, F_(wwmode), nullptr, json_main); + create_value_json(root, F("wwtemp"), nullptr, F_(wwtemp), nullptr, json_main); + create_value_json(root, F("wwtemplow"), nullptr, F_(wwtemplow), nullptr, json_main); + create_value_json(root, F("wwextra1"), nullptr, F_(wwextra1), nullptr, json_main); + create_value_json(root, F("wwcircmode"), nullptr, F_(wwcircmode), nullptr, json_main); + } + part++; + } else if (part == 1) { + JsonObject json_hc = doc.to(); + if (export_values_hc(Mqtt::Format::NESTED, json_hc)) { + // display for each active heating circuit + for (const auto & hc : heating_circuits_) { + if (hc->is_active()) { + char prefix_str[10]; + snprintf_P(prefix_str, sizeof(prefix_str), PSTR("hc%d"), hc->hc_num()); + JsonObject json = json_hc[prefix_str]; + + snprintf_P(prefix_str, sizeof(prefix_str), PSTR("(hc %d) "), hc->hc_num()); + + create_value_json(root, F("seltemp"), FPSTR(prefix_str), F_(seltemp), F_(degrees), json); + create_value_json(root, F("currtemp"), FPSTR(prefix_str), F_(currtemp), F_(degrees), json); + create_value_json(root, F("heattemp"), FPSTR(prefix_str), F_(heattemp), F_(degrees), json); + create_value_json(root, F("comforttemp"), FPSTR(prefix_str), F_(comforttemp), F_(degrees), json); + create_value_json(root, F("daytemp"), FPSTR(prefix_str), F_(daytemp), F_(degrees), json); + create_value_json(root, F("ecotemp"), FPSTR(prefix_str), F_(ecotemp), F_(degrees), json); + create_value_json(root, F("nighttemp"), FPSTR(prefix_str), F_(nighttemp), F_(degrees), json); + create_value_json(root, F("manualtemp"), FPSTR(prefix_str), F_(manualtemp), F_(degrees), json); + create_value_json(root, F("holidaytemp"), FPSTR(prefix_str), F_(holidaytemp), F_(degrees), json); + create_value_json(root, F("nofrosttemp"), FPSTR(prefix_str), F_(nofrosttemp), F_(degrees), json); + create_value_json(root, F("heatingtype"), FPSTR(prefix_str), F_(heatingtype), nullptr, json); + create_value_json(root, F("targetflowtemp"), FPSTR(prefix_str), F_(targetflowtemp), F_(degrees), json); + create_value_json(root, F("offsettemp"), FPSTR(prefix_str), F_(offsettemp), F_(degrees), json); + create_value_json(root, F("designtemp"), FPSTR(prefix_str), F_(designtemp), F_(degrees), json); + create_value_json(root, F("roominfluence"), FPSTR(prefix_str), F_(roominfluence), F_(degrees), json); + create_value_json(root, F("flowtempoffset"), FPSTR(prefix_str), F_(flowtempoffset), F_(degrees), json); + create_value_json(root, F("minflowtemp"), FPSTR(prefix_str), F_(minflowtemp), F_(degrees), json); + create_value_json(root, F("maxflowtemp"), FPSTR(prefix_str), F_(maxflowtemp), F_(degrees), json); + create_value_json(root, F("summertemp"), FPSTR(prefix_str), F_(summertemp), F_(degrees), json); + create_value_json(root, F("summermode"), FPSTR(prefix_str), F_(summermode), F_(degrees), json); + create_value_json(root, F("reducemode"), FPSTR(prefix_str), F_(reducemode), nullptr, json); + create_value_json(root, F("program"), FPSTR(prefix_str), F_(program), nullptr, json); + create_value_json(root, F("controlmode"), FPSTR(prefix_str), F_(controlmode), nullptr, json); + create_value_json(root, F("mode"), FPSTR(prefix_str), F_(mode), nullptr, json); + create_value_json(root, F("modetype"), FPSTR(prefix_str), F_(modetype), nullptr, json); + } } } + part = 0; // no more parts } } @@ -1861,7 +1864,10 @@ bool Thermostat::set_holiday(const char * value, const int8_t id) { LOG_WARNING(F("Set holiday: Heating Circuit %d not found or activated for device ID 0x%02X"), hc_num, device_id()); return false; } - + if (hd.length() != 21 || hd[6] != '2' || hd[17] != '2') { + LOG_WARNING(F("Set holiday: Invalid value")); + return false; + } uint8_t data[6]; data[0] = (hd[0] - '0') * 10 + (hd[1] - '0'); data[1] = (hd[3] - '0') * 10 + (hd[4] - '0'); diff --git a/src/devices/thermostat.h b/src/devices/thermostat.h index c0d40f25..5a9d4af7 100644 --- a/src/devices/thermostat.h +++ b/src/devices/thermostat.h @@ -127,7 +127,7 @@ class Thermostat : public EMSdevice { virtual void publish_values(JsonObject & json, bool force); virtual bool export_values(JsonObject & json); - virtual void device_info_web(JsonArray & root); + virtual void device_info_web(JsonArray & root, uint8_t & part); virtual bool updated_values(); private: diff --git a/src/emsdevice.h b/src/emsdevice.h index 59a3ee1c..13af5a10 100644 --- a/src/emsdevice.h +++ b/src/emsdevice.h @@ -143,7 +143,7 @@ class EMSdevice { virtual void publish_values(JsonObject & json, bool force = false) = 0; virtual bool export_values(JsonObject & json) = 0; virtual bool updated_values() = 0; - virtual void device_info_web(JsonArray & root) = 0; + virtual void device_info_web(JsonArray & root, uint8_t & part) = 0; std::string telegram_type_name(std::shared_ptr telegram); diff --git a/src/emsesp.cpp b/src/emsesp.cpp index d7d515a0..212fc1ea 100644 --- a/src/emsesp.cpp +++ b/src/emsesp.cpp @@ -279,7 +279,7 @@ void EMSESP::show_device_values(uuid::console::Shell & shell) { return; } - DynamicJsonDocument doc(EMSESP_MAX_JSON_SIZE_MAX_DYN); + DynamicJsonDocument doc(EMSESP_MAX_JSON_SIZE_LARGE_DYN); // do this in the order of factory classes to keep a consistent order when displaying for (const auto & device_class : EMSFactory::device_handlers()) { @@ -287,16 +287,19 @@ void EMSESP::show_device_values(uuid::console::Shell & shell) { if ((emsdevice) && (emsdevice->device_type() == device_class.first)) { // print header shell.printfln(F("%s: %s"), emsdevice->device_type_name().c_str(), emsdevice->to_string().c_str()); + uint8_t part = 0; + do { + JsonArray root = doc.to(); + emsdevice->device_info_web(root, part); // create array + + // iterate values and print to shell + uint8_t key_value = 0; + for (const JsonVariant & value : root) { + shell.printf((++key_value & 1) ? " %s: " : "%s\r\n", value.as()); + } - doc.clear(); // clear so we can re-use for each device - JsonArray root = doc.to(); - emsdevice->device_info_web(root); // create array - - // iterate values and print to shell - uint8_t key_value = 0; - for (const JsonVariant & value : root) { - shell.printf((++key_value & 1) ? " %s: " : "%s\r\n", value.as()); - } + doc.clear(); // clear so we can re-use for each device + } while (part); shell.println(); } @@ -694,7 +697,10 @@ void EMSESP::device_info_web(const uint8_t unique_id, JsonObject & root) { if (emsdevice->unique_id() == unique_id) { root["name"] = emsdevice->to_string_short(); // can't use c_str() because of scope JsonArray data = root.createNestedArray("data"); - emsdevice->device_info_web(data); + uint8_t part = 0; + do { + emsdevice->device_info_web(data, part); + } while (part); return; } }