mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 08:19:52 +03:00
HA MQTT Discovert - added remaining values - HomeAssistant Discovery #288
This commit is contained in:
@@ -24,7 +24,7 @@
|
|||||||
#include <ESPAsyncWebServer.h>
|
#include <ESPAsyncWebServer.h>
|
||||||
#include <SecurityManager.h>
|
#include <SecurityManager.h>
|
||||||
|
|
||||||
#define MAX_EMSESP_DEVICE_SIZE 2500
|
#define MAX_EMSESP_DEVICE_SIZE 4096
|
||||||
|
|
||||||
#define EMSESP_DEVICES_SERVICE_PATH "/rest/allDevices"
|
#define EMSESP_DEVICES_SERVICE_PATH "/rest/allDevices"
|
||||||
#define SCAN_DEVICES_SERVICE_PATH "/rest/scanDevices"
|
#define SCAN_DEVICES_SERVICE_PATH "/rest/scanDevices"
|
||||||
|
|||||||
@@ -76,10 +76,6 @@ Boiler::Boiler(uint8_t device_type, int8_t device_id, uint8_t product_id, const
|
|||||||
Command::add_with_json(this->device_type(), F("info"), [&](const char * value, const int8_t id, JsonObject & object) {
|
Command::add_with_json(this->device_type(), F("info"), [&](const char * value, const int8_t id, JsonObject & object) {
|
||||||
return command_info(value, id, object);
|
return command_info(value, id, object);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (Mqtt::mqtt_format() == Mqtt::Format::HA) {
|
|
||||||
register_mqtt_ha_config();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// create the config topics for Home Assistant MQTT Discovery
|
// create the config topics for Home Assistant MQTT Discovery
|
||||||
@@ -117,15 +113,12 @@ void Boiler::register_mqtt_ha_config() {
|
|||||||
Mqtt::register_mqtt_ha_sensor(nullptr, F_(wWType), this->device_type(), "wWType", nullptr, nullptr);
|
Mqtt::register_mqtt_ha_sensor(nullptr, F_(wWType), this->device_type(), "wWType", nullptr, nullptr);
|
||||||
Mqtt::register_mqtt_ha_sensor(nullptr, F_(wWChargeType), this->device_type(), "wWChargeType", nullptr, nullptr);
|
Mqtt::register_mqtt_ha_sensor(nullptr, F_(wWChargeType), this->device_type(), "wWChargeType", nullptr, nullptr);
|
||||||
Mqtt::register_mqtt_ha_sensor(nullptr, F_(wWCircPump), this->device_type(), "wWCircPump", nullptr, nullptr);
|
Mqtt::register_mqtt_ha_sensor(nullptr, F_(wWCircPump), this->device_type(), "wWCircPump", nullptr, nullptr);
|
||||||
Mqtt::register_mqtt_ha_sensor(nullptr, F_(wWCiPuMode), this->device_type(), "wWCiPuMode", nullptr, nullptr);
|
Mqtt::register_mqtt_ha_sensor(nullptr, F_(wWCircPumpMode), this->device_type(), "wWCircPumpMode", nullptr, nullptr);
|
||||||
Mqtt::register_mqtt_ha_sensor(nullptr, F_(wWCirc), this->device_type(), "wWCirc", nullptr, nullptr);
|
Mqtt::register_mqtt_ha_sensor(nullptr, F_(wWCirc), this->device_type(), "wWCirc", nullptr, nullptr);
|
||||||
|
|
||||||
// TODO add remaining values to MQTT
|
|
||||||
/*
|
|
||||||
|
|
||||||
Mqtt::register_mqtt_ha_sensor(nullptr, F_(outdoorTemp), this->device_type(), "outdoorTemp", F_(degrees), F_(icontemperature));
|
Mqtt::register_mqtt_ha_sensor(nullptr, F_(outdoorTemp), this->device_type(), "outdoorTemp", F_(degrees), F_(icontemperature));
|
||||||
Mqtt::register_mqtt_ha_sensor(nullptr, F_(wWCurTmp), this->device_type(), "wWCurTmp", F_(degrees), F_(icontemperature));
|
Mqtt::register_mqtt_ha_sensor(nullptr, F_(wWCurTemp), this->device_type(), "wWCurTemp", F_(degrees), F_(icontemperature));
|
||||||
Mqtt::register_mqtt_ha_sensor(nullptr, F_(wWCurTmp2), this->device_type(), "wWCurTmp2", F_(degrees), F_(icontemperature));
|
Mqtt::register_mqtt_ha_sensor(nullptr, F_(wWCurTemp2), this->device_type(), "wWCurTemp2", F_(degrees), F_(icontemperature));
|
||||||
Mqtt::register_mqtt_ha_sensor(nullptr, F_(wWCurFlow), this->device_type(), "wWCurFlow", F("l/min"), F_(icontemperature));
|
Mqtt::register_mqtt_ha_sensor(nullptr, F_(wWCurFlow), this->device_type(), "wWCurFlow", F("l/min"), F_(icontemperature));
|
||||||
Mqtt::register_mqtt_ha_sensor(nullptr, F_(curFlowTemp), this->device_type(), "curFlowTemp", F_(degrees), F_(icontemperature));
|
Mqtt::register_mqtt_ha_sensor(nullptr, F_(curFlowTemp), this->device_type(), "curFlowTemp", F_(degrees), F_(icontemperature));
|
||||||
Mqtt::register_mqtt_ha_sensor(nullptr, F_(retTemp), this->device_type(), "retTemp", F_(degrees), F_(icontemperature));
|
Mqtt::register_mqtt_ha_sensor(nullptr, F_(retTemp), this->device_type(), "retTemp", F_(degrees), F_(icontemperature));
|
||||||
@@ -133,129 +126,109 @@ void Boiler::register_mqtt_ha_config() {
|
|||||||
Mqtt::register_mqtt_ha_sensor(nullptr, F_(sysPress), this->device_type(), "sysPress", F_(bar), nullptr);
|
Mqtt::register_mqtt_ha_sensor(nullptr, F_(sysPress), this->device_type(), "sysPress", F_(bar), nullptr);
|
||||||
Mqtt::register_mqtt_ha_sensor(nullptr, F_(boilTemp), this->device_type(), "boilTemp", F_(degrees), nullptr);
|
Mqtt::register_mqtt_ha_sensor(nullptr, F_(boilTemp), this->device_type(), "boilTemp", F_(degrees), nullptr);
|
||||||
|
|
||||||
Mqtt::register_mqtt_ha_sensor(F_(burnGas), this->device_type(), "burnGas", nullptr, nullptr);
|
Mqtt::register_mqtt_ha_sensor(nullptr, F_(burnGas), this->device_type(), "burnGas", nullptr, nullptr);
|
||||||
Mqtt::register_mqtt_ha_sensor(F_(flameCurr), this->device_type(), "flameCurr", F_(uA), nullptr);
|
Mqtt::register_mqtt_ha_sensor(nullptr, F_(flameCurr), this->device_type(), "flameCurr", F_(uA), nullptr);
|
||||||
Mqtt::register_mqtt_ha_sensor(F_(heatPump), this->device_type(), "heatPump", nullptr, nullptr);
|
Mqtt::register_mqtt_ha_sensor(nullptr, F_(heatPump), this->device_type(), "heatPump", nullptr, nullptr);
|
||||||
Mqtt::register_mqtt_ha_sensor(F_(fanWork), this->device_type(), "fanWork", nullptr, nullptr);
|
Mqtt::register_mqtt_ha_sensor(nullptr, F_(fanWork), this->device_type(), "fanWork", nullptr, nullptr);
|
||||||
Mqtt::register_mqtt_ha_sensor(F_(ignWork), this->device_type(), "ignWork", nullptr, nullptr);
|
Mqtt::register_mqtt_ha_sensor(nullptr, F_(ignWork), this->device_type(), "ignWork", nullptr, nullptr);
|
||||||
Mqtt::register_mqtt_ha_sensor(F_(wWHeat), this->device_type(), "wWHeat", nullptr, nullptr);
|
Mqtt::register_mqtt_ha_sensor(nullptr, F_(wWHeat), this->device_type(), "wWHeat", nullptr, nullptr);
|
||||||
|
|
||||||
Mqtt::register_mqtt_ha_sensor(F_(wwStorageTemp1), this->device_type(), "wwStorageTemp1", F_(degrees), F_(icontemperature));
|
Mqtt::register_mqtt_ha_sensor(nullptr, F_(wwStorageTemp1), this->device_type(), "wwStorageTemp1", F_(degrees), F_(icontemperature));
|
||||||
Mqtt::register_mqtt_ha_sensor(F_(wwStorageTemp2), this->device_type(), "wwStorageTemp2", F_(degrees), F_(icontemperature));
|
Mqtt::register_mqtt_ha_sensor(nullptr, F_(wwStorageTemp2), this->device_type(), "wwStorageTemp2", F_(degrees), F_(icontemperature));
|
||||||
Mqtt::register_mqtt_ha_sensor(F_(exhaustTemp), this->device_type(), "exhaustTemp", F_(degrees), F_(icontemperature));
|
Mqtt::register_mqtt_ha_sensor(nullptr, F_(exhaustTemp), this->device_type(), "exhaustTemp", F_(degrees), F_(icontemperature));
|
||||||
Mqtt::register_mqtt_ha_sensor(F_(wWActivated), this->device_type(), "wWActivated", nullptr, nullptr);
|
Mqtt::register_mqtt_ha_sensor(nullptr, F_(wWActivated), this->device_type(), "wWActivated", nullptr, nullptr);
|
||||||
Mqtt::register_mqtt_ha_sensor(F_(wWOnetime), this->device_type(), "wWOnetime", nullptr, nullptr);
|
Mqtt::register_mqtt_ha_sensor(nullptr, F_(wWOneTime), this->device_type(), "wWOneTime", nullptr, nullptr);
|
||||||
|
|
||||||
Mqtt::register_mqtt_ha_sensor(F_(wWDisinfecting), this->device_type(), "wWDisinfecting", nullptr, nullptr);
|
Mqtt::register_mqtt_ha_sensor(nullptr, F_(wWDisinfecting), this->device_type(), "wWDisinfecting", nullptr, nullptr);
|
||||||
Mqtt::register_mqtt_ha_sensor(F_(wWCharge), this->device_type(), "wWCharge", nullptr, nullptr);
|
Mqtt::register_mqtt_ha_sensor(nullptr, F_(wWCharging), this->device_type(), "wWCharging", nullptr, nullptr);
|
||||||
Mqtt::register_mqtt_ha_sensor(F_(wWRecharge), this->device_type(), "wWRecharge", nullptr, nullptr);
|
Mqtt::register_mqtt_ha_sensor(nullptr, F_(wWRecharging), this->device_type(), "wWRecharging", nullptr, nullptr);
|
||||||
Mqtt::register_mqtt_ha_sensor(F_(wWTempOK), this->device_type(), "wWTempOK", nullptr, nullptr);
|
Mqtt::register_mqtt_ha_sensor(nullptr, F_(wWTempOK), this->device_type(), "wWTempOK", nullptr, nullptr);
|
||||||
Mqtt::register_mqtt_ha_sensor(F_(wWActive), this->device_type(), "wWActive", nullptr, nullptr);
|
Mqtt::register_mqtt_ha_sensor(nullptr, F_(wWActive), this->device_type(), "wWActive", nullptr, nullptr);
|
||||||
|
|
||||||
Mqtt::register_mqtt_ha_sensor(F_(heatingActivated), this->device_type(), "heatingActivated", nullptr, nullptr);
|
Mqtt::register_mqtt_ha_sensor(nullptr, F_(heatingActivated), this->device_type(), "heatingActivated", nullptr, nullptr);
|
||||||
Mqtt::register_mqtt_ha_sensor(F_(heatingTemp), this->device_type(), "heatingTemp", F_(degrees), F_(icontemperature));
|
Mqtt::register_mqtt_ha_sensor(nullptr, F_(heatingTemp), this->device_type(), "heatingTemp", F_(degrees), F_(icontemperature));
|
||||||
Mqtt::register_mqtt_ha_sensor(F_(pumpModMax), this->device_type(), "pumpModMax", F_(percent), F_(iconpercent));
|
Mqtt::register_mqtt_ha_sensor(nullptr, F_(pumpModMax), this->device_type(), "pumpModMax", F_(percent), F_(iconpercent));
|
||||||
Mqtt::register_mqtt_ha_sensor(F_(pumpModMin), this->device_type(), "pumpModMin", F_(percent), F_(iconpercent));
|
Mqtt::register_mqtt_ha_sensor(nullptr, F_(pumpModMin), this->device_type(), "pumpModMin", F_(percent), F_(iconpercent));
|
||||||
Mqtt::register_mqtt_ha_sensor(F_(pumpDelay), this->device_type(), "pumpDelay", F_(min), nullptr);
|
Mqtt::register_mqtt_ha_sensor(nullptr, F_(pumpDelay), this->device_type(), "pumpDelay", F_(min), nullptr);
|
||||||
Mqtt::register_mqtt_ha_sensor(F_(burnMinPeriod), this->device_type(), "burnMinPeriod", F_(min), nullptr);
|
Mqtt::register_mqtt_ha_sensor(nullptr, F_(burnMinPeriod), this->device_type(), "burnMinPeriod", F_(min), nullptr);
|
||||||
Mqtt::register_mqtt_ha_sensor(F_(burnMinPower), this->device_type(), "burnMinPower", F_(percent), F_(iconpercent));
|
Mqtt::register_mqtt_ha_sensor(nullptr, F_(burnMinPower), this->device_type(), "burnMinPower", F_(percent), F_(iconpercent));
|
||||||
Mqtt::register_mqtt_ha_sensor(F_(burnMaxPower), this->device_type(), "burnMaxPower", F_(percent), F_(iconpercent));
|
Mqtt::register_mqtt_ha_sensor(nullptr, F_(burnMaxPower), this->device_type(), "burnMaxPower", F_(percent), F_(iconpercent));
|
||||||
Mqtt::register_mqtt_ha_sensor(F_(boilHystOn), this->device_type(), "boilHystOn", F_(degrees), F_(icontemperature));
|
Mqtt::register_mqtt_ha_sensor(nullptr, F_(boilHystOn), this->device_type(), "boilHystOn", F_(degrees), F_(icontemperature));
|
||||||
Mqtt::register_mqtt_ha_sensor(F_(boilHystOff), this->device_type(), "boilHystOff", F_(degrees), F_(icontemperature));
|
Mqtt::register_mqtt_ha_sensor(nullptr, F_(boilHystOff), this->device_type(), "boilHystOff", F_(degrees), F_(icontemperature));
|
||||||
Mqtt::register_mqtt_ha_sensor(F_(setFlowTemp), this->device_type(), "setFlowTemp", F_(degrees), F_(icontemperature));
|
Mqtt::register_mqtt_ha_sensor(nullptr, F_(setFlowTemp), this->device_type(), "setFlowTemp", F_(degrees), F_(icontemperature));
|
||||||
Mqtt::register_mqtt_ha_sensor(F_(wWSetPumpPower), this->device_type(), "wWSetPumpPower", F_(percent), F_(iconpercent));
|
Mqtt::register_mqtt_ha_sensor(nullptr, F_(wWSetPumpPower), this->device_type(), "wWSetPumpPower", F_(percent), F_(iconpercent));
|
||||||
Mqtt::register_mqtt_ha_sensor(F_(wwMixTemperature), this->device_type(), "wwMixTemperature", F_(degrees), F_(icontemperature));
|
Mqtt::register_mqtt_ha_sensor(nullptr, F_(wwMixTemperature), this->device_type(), "wwMixTemperature", F_(degrees), F_(icontemperature));
|
||||||
Mqtt::register_mqtt_ha_sensor(F_(wwBufferBoilerTemperature), this->device_type(), "wwBufferBoilerTemperature", F_(degrees), F_(icontemperature));
|
Mqtt::register_mqtt_ha_sensor(nullptr, F_(wwBufferBoilerTemperature), this->device_type(), "wwBufferBoilerTemperature", F_(degrees), F_(icontemperature));
|
||||||
Mqtt::register_mqtt_ha_sensor(F_(wWStarts), this->device_type(), "wWStarts", nullptr, nullptr);
|
Mqtt::register_mqtt_ha_sensor(nullptr, F_(wWStarts), this->device_type(), "wWStarts", nullptr, nullptr);
|
||||||
Mqtt::register_mqtt_ha_sensor(F_(wWWorkM), this->device_type(), "wWWorkM", nullptr, nullptr);
|
Mqtt::register_mqtt_ha_sensor(nullptr, F_(wWWorkM), this->device_type(), "wWWorkM", nullptr, nullptr);
|
||||||
Mqtt::register_mqtt_ha_sensor(F_(setBurnPow), this->device_type(), "setBurnPow", F_(percent), F_(iconpercent));
|
Mqtt::register_mqtt_ha_sensor(nullptr, F_(setBurnPow), this->device_type(), "setBurnPow", F_(percent), F_(iconpercent));
|
||||||
Mqtt::register_mqtt_ha_sensor(F_(burnStarts), this->device_type(), "burnStarts", nullptr, nullptr);
|
Mqtt::register_mqtt_ha_sensor(nullptr, F_(burnStarts), this->device_type(), "burnStarts", nullptr, nullptr);
|
||||||
|
|
||||||
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// send stuff to the Web UI
|
// send stuff to the Web UI
|
||||||
void Boiler::device_info_web(JsonArray & root) {
|
void Boiler::device_info_web(JsonArray & root) {
|
||||||
JsonObject dataElement;
|
JsonObject dataElement;
|
||||||
|
|
||||||
render_value_json(root, "", F_(serviceCode), serviceCodeChar_, nullptr);
|
render_value_json(root, "", F_(heatingActive), heatingActive_, nullptr, EMS_VALUE_BOOL);
|
||||||
render_value_json(root, "", F_(serviceCodeNumber), serviceCode_, nullptr);
|
render_value_json(root, "", F_(tapwaterActive), tapwaterActive_, nullptr, EMS_VALUE_BOOL);
|
||||||
render_value_json(root, "", F_(tapwaterActive), tap_water_active_, nullptr, EMS_VALUE_BOOL);
|
render_value_json(root, "", F_(serviceCode), serviceCode_, nullptr);
|
||||||
render_value_json(root, "", F_(heatingActive), heating_active_, nullptr, EMS_VALUE_BOOL);
|
render_value_json(root, "", F_(serviceCodeNumber), serviceCodeNumber_, nullptr);
|
||||||
render_value_json(root, "", F_(selFlowTemp), selFlowTemp_, F_(degrees));
|
|
||||||
render_value_json(root, "", F_(curFlowTemp), curFlowTemp_, F_(degrees), 10);
|
|
||||||
render_value_json(root, "", F_(wWSelTemp), wWSelTemp_, F_(degrees));
|
render_value_json(root, "", F_(wWSelTemp), wWSelTemp_, F_(degrees));
|
||||||
render_value_json(root, "", F_(wWSetTemp), wWSetTmp_, F_(degrees));
|
render_value_json(root, "", F_(wWSetTemp), wWSetTemp_, F_(degrees));
|
||||||
render_value_json(root, "", F_(wWCurTmp), wWCurTmp_, F_(degrees), 10);
|
render_value_json(root, "", F_(wWDisinfectionTemp), wWDisinfectionTemp_, F_(degrees));
|
||||||
render_value_json(root, "", F_(wWCurTmp2), wWCurTmp2_, F_(degrees), 10);
|
render_value_json(root, "", F_(selFlowTemp), selFlowTemp_, F_(degrees));
|
||||||
|
render_value_json(root, "", F_(selBurnPow), selBurnPow_, F_(percent));
|
||||||
|
render_value_json(root, "", F_(curBurnPow), curBurnPow_, F_(percent));
|
||||||
render_value_json(root, "", F_(pumpMod), pumpMod_, F_(percent));
|
render_value_json(root, "", F_(pumpMod), pumpMod_, F_(percent));
|
||||||
render_value_json(root, "", F_(pumpMod2), pumpMod2_, F_(percent));
|
render_value_json(root, "", F_(pumpMod2), pumpMod2_, F_(percent));
|
||||||
|
render_value_json(root, "", F_(wWType), wWType_, nullptr);
|
||||||
|
render_value_json(root, "", F_(wWChargeType), wWChargeType_, nullptr);
|
||||||
|
render_value_json(root, "", F_(wWCircPump), wWCircPump_, nullptr);
|
||||||
|
render_value_json(root, "", F_(wWCircPumpMode), wWCircPumpMode_, nullptr);
|
||||||
|
render_value_json(root, "", F_(wWCirc), wWCirc_, nullptr, EMS_VALUE_BOOL);
|
||||||
|
render_value_json(root, "", F_(outdoorTemp), outdoorTemp_, F_(degrees), 10);
|
||||||
|
render_value_json(root, "", F_(wWCurTemp), wWCurTemp_, F_(degrees), 10);
|
||||||
|
render_value_json(root, "", F_(wWCurTemp2), wWCurTemp2_, F_(degrees), 10);
|
||||||
|
render_value_json(root, "", F_(wWCurFlow), wWCurFlow_, F("l/min"), 10);
|
||||||
|
render_value_json(root, "", F_(curFlowTemp), curFlowTemp_, F_(degrees), 10);
|
||||||
|
render_value_json(root, "", F_(retTemp), retTemp_, F_(degrees), 10);
|
||||||
|
render_value_json(root, "", F_(switchTemp), switchTemp_, F_(degrees), 10);
|
||||||
render_value_json(root, "", F_(sysPress), sysPress_, F_(bar), 10);
|
render_value_json(root, "", F_(sysPress), sysPress_, F_(bar), 10);
|
||||||
|
render_value_json(root, "", F_(boilTemp), boilTemp_, F_(degrees), 10);
|
||||||
// TODO add remaining values to web
|
render_value_json(root, "", F_(wwStorageTemp1), wwStorageTemp1_, F_(degrees), 10);
|
||||||
/*
|
render_value_json(root, "", F_(wwStorageTemp2), wwStorageTemp2_, F_(degrees), 10);
|
||||||
render_value_json(root, "", F_(heatingActive), "heatingActive", nullptr, nullptr);
|
render_value_json(root, "", F_(exhaustTemp), exhaustTemp_, F_(degrees), 10);
|
||||||
render_value_json(root, "", F_(tapwaterActive), "tapwaterActive", nullptr, nullptr);
|
render_value_json(root, "", F_(wWActivated), wWActivated_, nullptr, EMS_VALUE_BOOL);
|
||||||
render_value_json(root, "", F_(serviceCode), "serviceCode", nullptr, nullptr);
|
render_value_json(root, "", F_(wWOneTime), wWOneTime_, nullptr, EMS_VALUE_BOOL);
|
||||||
render_value_json(root, "", F_(serviceCodeNumber), "serviceCodeNumber", nullptr, nullptr);
|
render_value_json(root, "", F_(wWDisinfecting), wWDisinfecting_, nullptr, EMS_VALUE_BOOL);
|
||||||
render_value_json(root, "", F_(wWSelTemp), "wWSelTemp", F_(degrees), F_(icontemperature));
|
render_value_json(root, "", F_(wWCharging), wWCharging_, nullptr, EMS_VALUE_BOOL);
|
||||||
render_value_json(root, "", F_(wWSetTemp), "wWSetTemp", F_(degrees), F_(icontemperature));
|
render_value_json(root, "", F_(wWRecharging), wWRecharging_, nullptr, EMS_VALUE_BOOL);
|
||||||
render_value_json(root, "", F_(wWDisinfectionTemp), "wWDisinfectionTemp", F_(degrees), F_(icontemperature));
|
render_value_json(root, "", F_(wWTempOK), wWTempOK_, nullptr, EMS_VALUE_BOOL);
|
||||||
render_value_json(root, "", F_(selFlowTemp), "selFlowTemp", F_(degrees), F_(icontemperature));
|
render_value_json(root, "", F_(wWActive), wWActive_, nullptr, EMS_VALUE_BOOL);
|
||||||
render_value_json(root, "", F_(selBurnPow), "selBurnPow", F_(percent), nullptr);
|
render_value_json(root, "", F_(burnGas), burnGas_, nullptr, EMS_VALUE_BOOL);
|
||||||
render_value_json(root, "", F_(curBurnPow), "curBurnPow", F_(percent), F_(iconpercent));
|
render_value_json(root, "", F_(flameCurr), flameCurr_, F_(uA), 10);
|
||||||
render_value_json(root, "", F_(pumpMod), "pumpMod", F_(percent), F_(iconpercent));
|
render_value_json(root, "", F_(heatPump), heatPump_, nullptr, EMS_VALUE_BOOL);
|
||||||
render_value_json(root, "", F_(pumpMod2), "pumpMod2", F_(percent), F_(iconpercent));
|
render_value_json(root, "", F_(fanWork), fanWork_, nullptr, EMS_VALUE_BOOL);
|
||||||
render_value_json(root, "", F_(wWType), "wWType", nullptr, nullptr);
|
render_value_json(root, "", F_(ignWork), ignWork_, nullptr, EMS_VALUE_BOOL);
|
||||||
render_value_json(root, "", F_(wWChargeType), "wWChargeType", nullptr, nullptr);
|
render_value_json(root, "", F_(wWHeat), wWHeat_, nullptr, EMS_VALUE_BOOL);
|
||||||
render_value_json(root, "", F_(wWCircPump), "wWCircPump", nullptr, nullptr);
|
render_value_json(root, "", F_(heatingActivated), heatingActivated_, nullptr, EMS_VALUE_BOOL);
|
||||||
render_value_json(root, "", F_(wWCiPuMode), "wWCiPuMode", nullptr, nullptr);
|
render_value_json(root, "", F_(heatingTemp), heatingTemp_, F_(degrees));
|
||||||
render_value_json(root, "", F_(wWCirc), "wWCirc", nullptr, nullptr);
|
render_value_json(root, "", F_(pumpModMax), pumpModMax_, F_(percent));
|
||||||
render_value_json(root, "", F_(outdoorTemp), "outdoorTemp", F_(degrees), F_(icontemperature));
|
render_value_json(root, "", F_(pumpModMin), pumpModMin_, F_(percent));
|
||||||
render_value_json(root, "", F_(wWCurTmp), "wWCurTmp", F_(degrees), F_(icontemperature));
|
render_value_json(root, "", F_(pumpDelay), pumpDelay_, F_(min));
|
||||||
render_value_json(root, "", F_(wWCurTmp2), "wWCurTmp2", F_(degrees), F_(icontemperature));
|
render_value_json(root, "", F_(burnMinPeriod), burnMinPeriod_, F_(min));
|
||||||
render_value_json(root, "", F_(wWCurFlow), "wWCurFlow", F("l/min"), F_(icontemperature));
|
render_value_json(root, "", F_(burnMinPower), burnMinPower_, F_(percent));
|
||||||
render_value_json(root, "", F_(curFlowTemp), "curFlowTemp", F_(degrees), F_(icontemperature));
|
render_value_json(root, "", F_(burnMaxPower), burnMaxPower_, F_(percent));
|
||||||
render_value_json(root, "", F_(retTemp), "retTemp", F_(degrees), F_(icontemperature));
|
render_value_json(root, "", F_(boilHystOn), boilHystOn_, F_(degrees));
|
||||||
render_value_json(root, "", F_(switchTemp), "switchTemp", F_(degrees), F_(icontemperature));
|
render_value_json(root, "", F_(boilHystOff), boilHystOff_, F_(degrees));
|
||||||
render_value_json(root, "", F_(sysPress), "sysPress", F_(bar), nullptr);
|
render_value_json(root, "", F_(setFlowTemp), setFlowTemp_, F_(degrees));
|
||||||
render_value_json(root, "", F_(boilTemp), "boilTemp", F_(degrees), nullptr);
|
render_value_json(root, "", F_(wWSetPumpPower), wWSetPumpPower_, F_(percent));
|
||||||
render_value_json(root, "", F_(wwStorageTemp1), "wwStorageTemp1", F_(degrees), F_(icontemperature));
|
render_value_json(root, "", F_(wwMixTemperature), wwMixTemperature_, F_(degrees));
|
||||||
render_value_json(root, "", F_(wwStorageTemp2), "wwStorageTemp2", F_(degrees), F_(icontemperature));
|
render_value_json(root, "", F_(wwBufferBoilerTemperature), wwBufferBoilerTemperature_, F_(degrees));
|
||||||
render_value_json(root, "", F_(exhaustTemp), "exhaustTemp", F_(degrees), F_(icontemperature));
|
render_value_json(root, "", F_(wWStarts), wWStarts_, nullptr);
|
||||||
render_value_json(root, "", F_(wWActivated), "wWActivated", nullptr, nullptr);
|
render_value_json(root, "", F_(wWWorkM), wWWorkM_, nullptr);
|
||||||
render_value_json(root, "", F_(wWOnetime), "wWOnetime", nullptr, nullptr);
|
render_value_json(root, "", F_(setBurnPow), setBurnPow_, F_(percent));
|
||||||
render_value_json(root, "", F_(wWDisinfecting), "wWDisinfecting", nullptr, nullptr);
|
render_value_json(root, "", F_(burnStarts), burnStarts_, nullptr);
|
||||||
render_value_json(root, "", F_(wWCharge), "wWCharge", nullptr, nullptr);
|
|
||||||
render_value_json(root, "", F_(wWRecharge), "wWRecharge", nullptr, nullptr);
|
|
||||||
render_value_json(root, "", F_(wWTempOK), "wWTempOK", nullptr, nullptr);
|
|
||||||
render_value_json(root, "", F_(wWActive), "wWActive", nullptr, nullptr);
|
|
||||||
render_value_json(root, "", F_(burnGas), "burnGas", nullptr, nullptr);
|
|
||||||
render_value_json(root, "", F_(flameCurr), "flameCurr", F_(uA), nullptr);
|
|
||||||
render_value_json(root, "", F_(heatPump), "heatPump", nullptr, nullptr);
|
|
||||||
render_value_json(root, "", F_(fanWork), "fanWork", nullptr, nullptr);
|
|
||||||
render_value_json(root, "", F_(ignWork), "ignWork", nullptr, nullptr);
|
|
||||||
render_value_json(root, "", F_(wWHeat), "wWHeat", nullptr, nullptr);
|
|
||||||
render_value_json(root, "", F_(heatingActivated), "heatingActivated", nullptr, nullptr);
|
|
||||||
render_value_json(root, "", F_(heatingTemp), "heatingTemp", F_(degrees), F_(icontemperature));
|
|
||||||
render_value_json(root, "", F_(pumpModMax), "pumpModMax", F_(percent), F_(iconpercent));
|
|
||||||
render_value_json(root, "", F_(pumpModMin), "pumpModMin", F_(percent), F_(iconpercent));
|
|
||||||
render_value_json(root, "", F_(pumpDelay), "pumpDelay", F_(min), nullptr);
|
|
||||||
render_value_json(root, "", F_(burnMinPeriod), "burnMinPeriod", F_(min), nullptr);
|
|
||||||
render_value_json(root, "", F_(burnMinPower), "burnMinPower", F_(percent), F_(iconpercent));
|
|
||||||
render_value_json(root, "", F_(burnMaxPower), "burnMaxPower", F_(percent), F_(iconpercent));
|
|
||||||
render_value_json(root, "", F_(boilHystOn), "boilHystOn", F_(degrees), F_(icontemperature));
|
|
||||||
render_value_json(root, "", F_(boilHystOff), "boilHystOff", F_(degrees), F_(icontemperature));
|
|
||||||
render_value_json(root, "", F_(setFlowTemp), "setFlowTemp", F_(degrees), F_(icontemperature));
|
|
||||||
render_value_json(root, "", F_(wWSetPumpPower), "wWSetPumpPower", F_(percent), F_(iconpercent));
|
|
||||||
render_value_json(root, "", F_(wwMixTemperature), "wwMixTemperature", F_(degrees), F_(icontemperature));
|
|
||||||
render_value_json(root, "", F_(wwBufferBoilerTemperature), "wwBufferBoilerTemperature", F_(degrees), F_(icontemperature));
|
|
||||||
render_value_json(root, "", F_(wWStarts), "wWStarts", nullptr, nullptr);
|
|
||||||
render_value_json(root, "", F_(wWWorkM), "wWWorkM", nullptr, nullptr);
|
|
||||||
render_value_json(root, "", F_(setBurnPow), "setBurnPow", F_(percent), F_(iconpercent));
|
|
||||||
render_value_json(root, "", F_(burnStarts), "burnStarts", nullptr, nullptr);
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Boiler::command_info(const char * value, const int8_t id, JsonObject & output) {
|
bool Boiler::command_info(const char * value, const int8_t id, JsonObject & output) {
|
||||||
@@ -268,13 +241,13 @@ bool Boiler::export_values(JsonObject & output) {
|
|||||||
char s[10]; // for formatting strings
|
char s[10]; // for formatting strings
|
||||||
|
|
||||||
// Hot tap water bool
|
// Hot tap water bool
|
||||||
if (Helpers::hasValue(heating_active_, EMS_VALUE_BOOL)) {
|
if (Helpers::hasValue(heatingActive_, EMS_VALUE_BOOL)) {
|
||||||
output["heatingActive"] = Helpers::render_value(s, heating_active_, EMS_VALUE_BOOL);
|
output["heatingActive"] = Helpers::render_value(s, heatingActive_, EMS_VALUE_BOOL);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Central heating bool
|
// Central heating bool
|
||||||
if (Helpers::hasValue(tap_water_active_, EMS_VALUE_BOOL)) {
|
if (Helpers::hasValue(tapwaterActive_, EMS_VALUE_BOOL)) {
|
||||||
output["tapwaterActive"] = Helpers::render_value(s, tap_water_active_, EMS_VALUE_BOOL);
|
output["tapwaterActive"] = Helpers::render_value(s, tapwaterActive_, EMS_VALUE_BOOL);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Warm Water comfort setting
|
// Warm Water comfort setting
|
||||||
@@ -294,13 +267,13 @@ bool Boiler::export_values(JsonObject & output) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Warm Water set temperature
|
// Warm Water set temperature
|
||||||
if (Helpers::hasValue(wWSetTmp_)) {
|
if (Helpers::hasValue(wWSetTemp_)) {
|
||||||
output["wWSetTemp"] = wWSetTmp_;
|
output["wWSetTemp"] = wWSetTemp_;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Warm Water disinfection temperature
|
// Warm Water disinfection temperature
|
||||||
if (Helpers::hasValue(wWDisinfectTemp_)) {
|
if (Helpers::hasValue(wWDisinfectionTemp_)) {
|
||||||
output["wWDisinfectionTemp"] = wWDisinfectTemp_;
|
output["wWDisinfectionTemp"] = wWDisinfectionTemp_;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Selected flow temperature deg
|
// Selected flow temperature deg
|
||||||
@@ -354,7 +327,7 @@ bool Boiler::export_values(JsonObject & output) {
|
|||||||
// Warm Water circulation pump freq
|
// Warm Water circulation pump freq
|
||||||
if (Helpers::hasValue(wWCircPumpMode_)) {
|
if (Helpers::hasValue(wWCircPumpMode_)) {
|
||||||
if (wWCircPumpMode_ == 7) {
|
if (wWCircPumpMode_ == 7) {
|
||||||
output["wWCiPuMode"] = F("continuous");
|
output["wWCircPumpMode"] = F("continuous");
|
||||||
} else {
|
} else {
|
||||||
char s[7];
|
char s[7];
|
||||||
char buffer[2];
|
char buffer[2];
|
||||||
@@ -362,7 +335,7 @@ bool Boiler::export_values(JsonObject & output) {
|
|||||||
buffer[1] = '\0';
|
buffer[1] = '\0';
|
||||||
strlcpy(s, buffer, 7);
|
strlcpy(s, buffer, 7);
|
||||||
strlcat(s, "x3min", 7);
|
strlcat(s, "x3min", 7);
|
||||||
output["wWCiPuMode"] = s;
|
output["wWCircPumpMode"] = s;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -372,18 +345,18 @@ bool Boiler::export_values(JsonObject & output) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Outside temperature
|
// Outside temperature
|
||||||
if (Helpers::hasValue(extTemp_)) {
|
if (Helpers::hasValue(outdoorTemp_)) {
|
||||||
output["outdoorTemp"] = (float)extTemp_ / 10;
|
output["outdoorTemp"] = (float)outdoorTemp_ / 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Warm Water current temperature (intern)
|
// Warm Water current temperature (intern)
|
||||||
if (Helpers::hasValue(wWCurTmp_)) {
|
if (Helpers::hasValue(wWCurTemp_)) {
|
||||||
output["wWCurTmp"] = (float)wWCurTmp_ / 10;
|
output["wWCurTemp"] = (float)wWCurTemp_ / 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Warm Water current temperature (extern)
|
// Warm Water current temperature (extern)
|
||||||
if (Helpers::hasValue(wWCurTmp2_)) {
|
if (Helpers::hasValue(wWCurTemp2_)) {
|
||||||
output["wWCurTmp2"] = (float)wWCurTmp2_ / 10;
|
output["wWCurTemp2"] = (float)wWCurTemp2_ / 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Warm Water current tap water flow l/min
|
// Warm Water current tap water flow l/min
|
||||||
@@ -438,7 +411,7 @@ bool Boiler::export_values(JsonObject & output) {
|
|||||||
|
|
||||||
// Warm Water one time charging bool
|
// Warm Water one time charging bool
|
||||||
if (Helpers::hasValue(wWOneTime_, EMS_VALUE_BOOL)) {
|
if (Helpers::hasValue(wWOneTime_, EMS_VALUE_BOOL)) {
|
||||||
output["wWOnetime"] = Helpers::render_value(s, wWOneTime_, EMS_VALUE_BOOL);
|
output["wWOneTime"] = Helpers::render_value(s, wWOneTime_, EMS_VALUE_BOOL);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Warm Water disinfecting bool
|
// Warm Water disinfecting bool
|
||||||
@@ -448,17 +421,17 @@ bool Boiler::export_values(JsonObject & output) {
|
|||||||
|
|
||||||
// Warm water charging bool
|
// Warm water charging bool
|
||||||
if (Helpers::hasValue(wWCharging_, EMS_VALUE_BOOL)) {
|
if (Helpers::hasValue(wWCharging_, EMS_VALUE_BOOL)) {
|
||||||
output["wWCharge"] = Helpers::render_value(s, wWCharging_, EMS_VALUE_BOOL);
|
output["wWCharging"] = Helpers::render_value(s, wWCharging_, EMS_VALUE_BOOL);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Warm water recharge bool
|
// Warm water recharge bool
|
||||||
if (Helpers::hasValue(wWRecharging_, EMS_VALUE_BOOL)) {
|
if (Helpers::hasValue(wWRecharging_, EMS_VALUE_BOOL)) {
|
||||||
output["wWRecharge"] = Helpers::render_value(s, wWRecharging_, EMS_VALUE_BOOL);
|
output["wWRecharging"] = Helpers::render_value(s, wWRecharging_, EMS_VALUE_BOOL);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Warm water temperature ok bool
|
// Warm water temperature ok bool
|
||||||
if (Helpers::hasValue(wWTemperatureOK_, EMS_VALUE_BOOL)) {
|
if (Helpers::hasValue(wWTempOK_, EMS_VALUE_BOOL)) {
|
||||||
output["wWTempOK"] = Helpers::render_value(s, wWTemperatureOK_, EMS_VALUE_BOOL);
|
output["wWTempOK"] = Helpers::render_value(s, wWTempOK_, EMS_VALUE_BOOL);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Warm water active bool
|
// Warm water active bool
|
||||||
@@ -477,8 +450,8 @@ bool Boiler::export_values(JsonObject & output) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Boiler pump bool
|
// Boiler pump bool
|
||||||
if (Helpers::hasValue(heatPmp_, EMS_VALUE_BOOL)) {
|
if (Helpers::hasValue(heatPump_, EMS_VALUE_BOOL)) {
|
||||||
output["heatPump"] = Helpers::render_value(s, heatPmp_, EMS_VALUE_BOOL);
|
output["heatPump"] = Helpers::render_value(s, heatPump_, EMS_VALUE_BOOL);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fan bool
|
// Fan bool
|
||||||
@@ -497,23 +470,23 @@ bool Boiler::export_values(JsonObject & output) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// heating activated bool
|
// heating activated bool
|
||||||
if (Helpers::hasValue(heating_activated_, EMS_VALUE_BOOL)) {
|
if (Helpers::hasValue(heatingActivated_, EMS_VALUE_BOOL)) {
|
||||||
output["heatingActivated"] = Helpers::render_value(s, heating_activated_, EMS_VALUE_BOOL);
|
output["heatingActivated"] = Helpers::render_value(s, heatingActivated_, EMS_VALUE_BOOL);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Heating temperature setting on the boiler
|
// Heating temperature setting on the boiler
|
||||||
if (Helpers::hasValue(heating_temp_)) {
|
if (Helpers::hasValue(heatingTemp_)) {
|
||||||
output["heatingTemp"] = heating_temp_;
|
output["heatingTemp"] = heatingTemp_;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Boiler circuit pump modulation max power %
|
// Boiler circuit pump modulation max power %
|
||||||
if (Helpers::hasValue(pump_mod_max_)) {
|
if (Helpers::hasValue(pumpModMax_)) {
|
||||||
output["pumpModMax"] = pump_mod_max_;
|
output["pumpModMax"] = pumpModMax_;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Boiler circuit pump modulation min power %
|
// Boiler circuit pump modulation min power %
|
||||||
if (Helpers::hasValue(pump_mod_min_)) {
|
if (Helpers::hasValue(pumpModMin_)) {
|
||||||
output["pumpModMin"] = pump_mod_min_;
|
output["pumpModMin"] = pumpModMin_;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Boiler circuit pump delay time min
|
// Boiler circuit pump delay time min
|
||||||
@@ -522,28 +495,28 @@ bool Boiler::export_values(JsonObject & output) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Boiler burner min period min
|
// Boiler burner min period min
|
||||||
if (Helpers::hasValue(burnPeriod_)) {
|
if (Helpers::hasValue(burnMinPeriod_)) {
|
||||||
output["burnMinPeriod"] = burnPeriod_;
|
output["burnMinPeriod"] = burnMinPeriod_;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Boiler burner min power %
|
// Boiler burner min power %
|
||||||
if (Helpers::hasValue(burnPowermin_)) {
|
if (Helpers::hasValue(burnMinPower_)) {
|
||||||
output["burnMinPower"] = burnPowermin_;
|
output["burnMinPower"] = burnMinPower_;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Boiler burner max power %
|
// Boiler burner max power %
|
||||||
if (Helpers::hasValue(burnPowermax_)) {
|
if (Helpers::hasValue(burnMaxPower_)) {
|
||||||
output["burnMaxPower"] = burnPowermax_;
|
output["burnMaxPower"] = burnMaxPower_;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Boiler temp hysteresis on degrees
|
// Boiler temp hysteresis on degrees
|
||||||
if (Helpers::hasValue(boilTemp_on_)) {
|
if (Helpers::hasValue(boilHystOn_)) {
|
||||||
output["boilHystOn"] = boilTemp_on_;
|
output["boilHystOn"] = boilHystOn_;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Boiler temp hysteresis off degrees
|
// Boiler temp hysteresis off degrees
|
||||||
if (Helpers::hasValue(boilTemp_off_)) {
|
if (Helpers::hasValue(boilHystOff_)) {
|
||||||
output["boilHystOff"] = boilTemp_off_;
|
output["boilHystOff"] = boilHystOff_;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set Flow temperature
|
// Set Flow temperature
|
||||||
@@ -552,8 +525,8 @@ bool Boiler::export_values(JsonObject & output) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Warm Water pump set power %
|
// Warm Water pump set power %
|
||||||
if (Helpers::hasValue(setWWPumpPow_)) {
|
if (Helpers::hasValue(wWSetPumpPower_)) {
|
||||||
output["wWSetPumpPower"] = setWWPumpPow_;
|
output["wWSetPumpPower"] = wWSetPumpPower_;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Warm water mix temperature
|
// Warm water mix temperature
|
||||||
@@ -603,9 +576,9 @@ bool Boiler::export_values(JsonObject & output) {
|
|||||||
|
|
||||||
// Service Code
|
// Service Code
|
||||||
// Service Code Number
|
// Service Code Number
|
||||||
if (Helpers::hasValue(serviceCode_)) {
|
if (Helpers::hasValue(serviceCodeNumber_)) {
|
||||||
output["serviceCode"] = serviceCodeChar_;
|
output["serviceCode"] = serviceCode_;
|
||||||
output["serviceCodeNumber"] = serviceCode_;
|
output["serviceCodeNumber"] = serviceCodeNumber_;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (output.size());
|
return (output.size());
|
||||||
@@ -613,9 +586,16 @@ bool Boiler::export_values(JsonObject & output) {
|
|||||||
|
|
||||||
// publish values via MQTT
|
// publish values via MQTT
|
||||||
void Boiler::publish_values() {
|
void Boiler::publish_values() {
|
||||||
StaticJsonDocument<EMSESP_MAX_JSON_SIZE_LARGE> doc;
|
// must make sure this doesn't exist 1000. Currently (2.1.0) its 950b.
|
||||||
|
// otheerwise use DynamicJsonDocument with max size and use .shrinkToFit()
|
||||||
|
StaticJsonDocument<1024> doc;
|
||||||
JsonObject output = doc.to<JsonObject>();
|
JsonObject output = doc.to<JsonObject>();
|
||||||
if (export_values(output)) {
|
if (export_values(output)) {
|
||||||
|
// see if we need to send out HA MQTT Discovery topics
|
||||||
|
if ((Mqtt::mqtt_format() == Mqtt::Format::HA) && (!mqtt_ha_config_)) {
|
||||||
|
register_mqtt_ha_config();
|
||||||
|
mqtt_ha_config_ = true;
|
||||||
|
}
|
||||||
Mqtt::publish(F("boiler_data"), doc.as<JsonObject>());
|
Mqtt::publish(F("boiler_data"), doc.as<JsonObject>());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -658,11 +638,11 @@ void Boiler::show_values(uuid::console::Shell & shell) {
|
|||||||
print_value_json(shell, F("wWType"), F_(wWType), nullptr, output);
|
print_value_json(shell, F("wWType"), F_(wWType), nullptr, output);
|
||||||
print_value_json(shell, F("wWChargeType"), F_(wWChargeType), nullptr, output);
|
print_value_json(shell, F("wWChargeType"), F_(wWChargeType), nullptr, output);
|
||||||
print_value_json(shell, F("wWCircPump"), F_(wWCircPump), nullptr, output);
|
print_value_json(shell, F("wWCircPump"), F_(wWCircPump), nullptr, output);
|
||||||
print_value_json(shell, F("wWCiPuMode"), F_(wWCiPuMode), nullptr, output);
|
print_value_json(shell, F("wWCircPumpMode"), F_(wWCircPumpMode), nullptr, output);
|
||||||
print_value_json(shell, F("wWCirc"), F_(wWCirc), nullptr, output);
|
print_value_json(shell, F("wWCirc"), F_(wWCirc), nullptr, output);
|
||||||
print_value_json(shell, F("outdoorTemp"), F_(outdoorTemp), F_(degrees), output);
|
print_value_json(shell, F("outdoorTemp"), F_(outdoorTemp), F_(degrees), output);
|
||||||
print_value_json(shell, F("wWCurTmp"), F_(wWCurTmp), F_(degrees), output);
|
print_value_json(shell, F("wWCurTemp"), F_(wWCurTemp), F_(degrees), output);
|
||||||
print_value_json(shell, F("wWCurTmp2"), F_(wWCurTmp2), F_(degrees), output);
|
print_value_json(shell, F("wWCurTemp2"), F_(wWCurTemp2), F_(degrees), output);
|
||||||
print_value_json(shell, F("wWCurFlow"), F_(wWCurFlow), F("l/min"), output);
|
print_value_json(shell, F("wWCurFlow"), F_(wWCurFlow), F("l/min"), output);
|
||||||
print_value_json(shell, F("curFlowTemp"), F_(curFlowTemp), F_(degrees), output);
|
print_value_json(shell, F("curFlowTemp"), F_(curFlowTemp), F_(degrees), output);
|
||||||
print_value_json(shell, F("retTemp"), F_(retTemp), F_(degrees), output);
|
print_value_json(shell, F("retTemp"), F_(retTemp), F_(degrees), output);
|
||||||
@@ -673,10 +653,10 @@ void Boiler::show_values(uuid::console::Shell & shell) {
|
|||||||
print_value_json(shell, F("wwStorageTemp2"), F_(wwStorageTemp2), F_(degrees), output);
|
print_value_json(shell, F("wwStorageTemp2"), F_(wwStorageTemp2), F_(degrees), output);
|
||||||
print_value_json(shell, F("exhaustTemp"), F_(exhaustTemp), F_(degrees), output);
|
print_value_json(shell, F("exhaustTemp"), F_(exhaustTemp), F_(degrees), output);
|
||||||
print_value_json(shell, F("wWActivated"), F_(wWActivated), nullptr, output);
|
print_value_json(shell, F("wWActivated"), F_(wWActivated), nullptr, output);
|
||||||
print_value_json(shell, F("wWOnetime"), F_(wWOnetime), nullptr, output);
|
print_value_json(shell, F("wWOneTime"), F_(wWOneTime), nullptr, output);
|
||||||
print_value_json(shell, F("wWDisinfecting"), F_(wWDisinfecting), nullptr, output);
|
print_value_json(shell, F("wWDisinfecting"), F_(wWDisinfecting), nullptr, output);
|
||||||
print_value_json(shell, F("wWCharge"), F_(wWCharge), nullptr, output);
|
print_value_json(shell, F("wWCharging"), F_(wWCharging), nullptr, output);
|
||||||
print_value_json(shell, F("wWRecharge"), F_(wWRecharge), nullptr, output);
|
print_value_json(shell, F("wWRecharging"), F_(wWRecharging), nullptr, output);
|
||||||
print_value_json(shell, F("wWTempOK"), F_(wWTempOK), nullptr, output);
|
print_value_json(shell, F("wWTempOK"), F_(wWTempOK), nullptr, output);
|
||||||
print_value_json(shell, F("wWActive"), F_(wWActive), nullptr, output);
|
print_value_json(shell, F("wWActive"), F_(wWActive), nullptr, output);
|
||||||
print_value_json(shell, F("burnGas"), F_(burnGas), nullptr, output);
|
print_value_json(shell, F("burnGas"), F_(burnGas), nullptr, output);
|
||||||
@@ -730,14 +710,14 @@ void Boiler::check_active() {
|
|||||||
char s[7];
|
char s[7];
|
||||||
bool b = ((boilerState_ & 0x09) == 0x09);
|
bool b = ((boilerState_ & 0x09) == 0x09);
|
||||||
Mqtt::publish(F("heating_active"), Helpers::render_boolean(s, b));
|
Mqtt::publish(F("heating_active"), Helpers::render_boolean(s, b));
|
||||||
heating_active_ = b ? EMS_VALUE_BOOL_ON : EMS_VALUE_BOOL_OFF;
|
heatingActive_ = b ? EMS_VALUE_BOOL_ON : EMS_VALUE_BOOL_OFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((boilerState_ & 0x0A) != (last_boilerState & 0x0A)) {
|
if ((boilerState_ & 0x0A) != (last_boilerState & 0x0A)) {
|
||||||
char s[7];
|
char s[7];
|
||||||
bool b = ((boilerState_ & 0x0A) == 0x0A);
|
bool b = ((boilerState_ & 0x0A) == 0x0A);
|
||||||
Mqtt::publish(F("tapwater_active"), Helpers::render_boolean(s, b));
|
Mqtt::publish(F("tapwater_active"), Helpers::render_boolean(s, b));
|
||||||
tap_water_active_ = b ? EMS_VALUE_BOOL_ON : EMS_VALUE_BOOL_OFF;
|
tapwaterActive_ = b ? EMS_VALUE_BOOL_ON : EMS_VALUE_BOOL_OFF;
|
||||||
EMSESP::tap_water_active(b); // let EMS-ESP know, used in the Shower class
|
EMSESP::tap_water_active(b); // let EMS-ESP know, used in the Shower class
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -777,7 +757,7 @@ void Boiler::process_UBAParameterWW(std::shared_ptr<const Telegram> telegram) {
|
|||||||
changed_ |= telegram->read_value(wWCircPumpMode_, 7); // 1=1x3min... 6=6x3min, 7=continuous
|
changed_ |= telegram->read_value(wWCircPumpMode_, 7); // 1=1x3min... 6=6x3min, 7=continuous
|
||||||
changed_ |= telegram->read_value(wWChargeType_, 10); // 0 = charge pump, 0xff = 3-way valve
|
changed_ |= telegram->read_value(wWChargeType_, 10); // 0 = charge pump, 0xff = 3-way valve
|
||||||
changed_ |= telegram->read_value(wWSelTemp_, 2);
|
changed_ |= telegram->read_value(wWSelTemp_, 2);
|
||||||
changed_ |= telegram->read_value(wWDisinfectTemp_, 8);
|
changed_ |= telegram->read_value(wWDisinfectionTemp_, 8);
|
||||||
changed_ |= telegram->read_value(wWComfort_, 9);
|
changed_ |= telegram->read_value(wWComfort_, 9);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -792,7 +772,7 @@ void Boiler::process_UBAMonitorFast(std::shared_ptr<const Telegram> telegram) {
|
|||||||
changed_ |= telegram->read_bitvalue(burnGas_, 7, 0);
|
changed_ |= telegram->read_bitvalue(burnGas_, 7, 0);
|
||||||
changed_ |= telegram->read_bitvalue(fanWork_, 7, 2);
|
changed_ |= telegram->read_bitvalue(fanWork_, 7, 2);
|
||||||
changed_ |= telegram->read_bitvalue(ignWork_, 7, 3);
|
changed_ |= telegram->read_bitvalue(ignWork_, 7, 3);
|
||||||
changed_ |= telegram->read_bitvalue(heatPmp_, 7, 5);
|
changed_ |= telegram->read_bitvalue(heatPump_, 7, 5);
|
||||||
changed_ |= telegram->read_bitvalue(wWHeat_, 7, 6);
|
changed_ |= telegram->read_bitvalue(wWHeat_, 7, 6);
|
||||||
changed_ |= telegram->read_bitvalue(wWCirc_, 7, 7);
|
changed_ |= telegram->read_bitvalue(wWCirc_, 7, 7);
|
||||||
|
|
||||||
@@ -803,18 +783,19 @@ void Boiler::process_UBAMonitorFast(std::shared_ptr<const Telegram> telegram) {
|
|||||||
|
|
||||||
changed_ |= telegram->read_value(retTemp_, 13);
|
changed_ |= telegram->read_value(retTemp_, 13);
|
||||||
changed_ |= telegram->read_value(flameCurr_, 15);
|
changed_ |= telegram->read_value(flameCurr_, 15);
|
||||||
changed_ |= telegram->read_value(serviceCode_, 20);
|
|
||||||
|
|
||||||
// system pressure. FF means missing
|
// system pressure. FF means missing
|
||||||
changed_ |= telegram->read_value(sysPress_, 17); // is *10
|
changed_ |= telegram->read_value(sysPress_, 17); // is *10
|
||||||
|
|
||||||
// read the service code / installation status as appears on the display
|
// read the service code / installation status as appears on the display
|
||||||
if ((telegram->message_length > 18) && (telegram->offset == 0)) {
|
if ((telegram->message_length > 18) && (telegram->offset == 0)) {
|
||||||
changed_ |= telegram->read_value(serviceCodeChar_[0], 18);
|
changed_ |= telegram->read_value(serviceCode_[0], 18);
|
||||||
changed_ |= telegram->read_value(serviceCodeChar_[1], 19);
|
changed_ |= telegram->read_value(serviceCode_[1], 19);
|
||||||
serviceCodeChar_[2] = '\0'; // null terminate string
|
serviceCode_[2] = '\0'; // null terminate string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
changed_ |= telegram->read_value(serviceCodeNumber_, 20);
|
||||||
|
|
||||||
// at this point do a quick check to see if the hot water or heating is active
|
// at this point do a quick check to see if the hot water or heating is active
|
||||||
check_active();
|
check_active();
|
||||||
}
|
}
|
||||||
@@ -831,16 +812,16 @@ void Boiler::process_UBATotalUptime(std::shared_ptr<const Telegram> telegram) {
|
|||||||
* UBAParameters - type 0x16
|
* UBAParameters - type 0x16
|
||||||
*/
|
*/
|
||||||
void Boiler::process_UBAParameters(std::shared_ptr<const Telegram> telegram) {
|
void Boiler::process_UBAParameters(std::shared_ptr<const Telegram> telegram) {
|
||||||
changed_ |= telegram->read_value(heating_activated_, 0);
|
changed_ |= telegram->read_value(heatingActivated_, 0);
|
||||||
changed_ |= telegram->read_value(heating_temp_, 1);
|
changed_ |= telegram->read_value(heatingTemp_, 1);
|
||||||
changed_ |= telegram->read_value(burnPowermax_, 2);
|
changed_ |= telegram->read_value(burnMaxPower_, 2);
|
||||||
changed_ |= telegram->read_value(burnPowermin_, 3);
|
changed_ |= telegram->read_value(burnMinPower_, 3);
|
||||||
changed_ |= telegram->read_value(boilTemp_off_, 4);
|
changed_ |= telegram->read_value(boilHystOff_, 4);
|
||||||
changed_ |= telegram->read_value(boilTemp_on_, 5);
|
changed_ |= telegram->read_value(boilHystOn_, 5);
|
||||||
changed_ |= telegram->read_value(burnPeriod_, 6);
|
changed_ |= telegram->read_value(burnMinPeriod_, 6);
|
||||||
changed_ |= telegram->read_value(pumpDelay_, 8);
|
changed_ |= telegram->read_value(pumpDelay_, 8);
|
||||||
changed_ |= telegram->read_value(pump_mod_max_, 9);
|
changed_ |= telegram->read_value(pumpModMax_, 9);
|
||||||
changed_ |= telegram->read_value(pump_mod_min_, 10);
|
changed_ |= telegram->read_value(pumpModMin_, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -848,9 +829,9 @@ void Boiler::process_UBAParameters(std::shared_ptr<const Telegram> telegram) {
|
|||||||
* received every 10 seconds
|
* received every 10 seconds
|
||||||
*/
|
*/
|
||||||
void Boiler::process_UBAMonitorWW(std::shared_ptr<const Telegram> telegram) {
|
void Boiler::process_UBAMonitorWW(std::shared_ptr<const Telegram> telegram) {
|
||||||
changed_ |= telegram->read_value(wWSetTmp_, 0);
|
changed_ |= telegram->read_value(wWSetTemp_, 0);
|
||||||
changed_ |= telegram->read_value(wWCurTmp_, 1);
|
changed_ |= telegram->read_value(wWCurTemp_, 1);
|
||||||
changed_ |= telegram->read_value(wWCurTmp2_, 3);
|
changed_ |= telegram->read_value(wWCurTemp2_, 3);
|
||||||
changed_ |= telegram->read_value(wWCurFlow_, 9);
|
changed_ |= telegram->read_value(wWCurFlow_, 9);
|
||||||
changed_ |= telegram->read_value(wWType_, 8);
|
changed_ |= telegram->read_value(wWType_, 8);
|
||||||
|
|
||||||
@@ -861,7 +842,7 @@ void Boiler::process_UBAMonitorWW(std::shared_ptr<const Telegram> telegram) {
|
|||||||
changed_ |= telegram->read_bitvalue(wWDisinfecting_, 5, 2);
|
changed_ |= telegram->read_bitvalue(wWDisinfecting_, 5, 2);
|
||||||
changed_ |= telegram->read_bitvalue(wWCharging_, 5, 3);
|
changed_ |= telegram->read_bitvalue(wWCharging_, 5, 3);
|
||||||
changed_ |= telegram->read_bitvalue(wWRecharging_, 5, 4);
|
changed_ |= telegram->read_bitvalue(wWRecharging_, 5, 4);
|
||||||
changed_ |= telegram->read_bitvalue(wWTemperatureOK_, 5, 5);
|
changed_ |= telegram->read_bitvalue(wWTempOK_, 5, 5);
|
||||||
changed_ |= telegram->read_bitvalue(wWActive_, 5, 6);
|
changed_ |= telegram->read_bitvalue(wWActive_, 5, 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -880,9 +861,9 @@ void Boiler::process_UBAMonitorFastPlus(std::shared_ptr<const Telegram> telegram
|
|||||||
|
|
||||||
// read the service code / installation status as appears on the display
|
// read the service code / installation status as appears on the display
|
||||||
if ((telegram->message_length > 4) && (telegram->offset == 0)) {
|
if ((telegram->message_length > 4) && (telegram->offset == 0)) {
|
||||||
changed_ |= telegram->read_value(serviceCodeChar_[0], 4);
|
changed_ |= telegram->read_value(serviceCode_[0], 4);
|
||||||
changed_ |= telegram->read_value(serviceCodeChar_[1], 5);
|
changed_ |= telegram->read_value(serviceCode_[1], 5);
|
||||||
serviceCodeChar_[2] = '\0';
|
serviceCode_[2] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
// at this point do a quick check to see if the hot water or heating is active
|
// at this point do a quick check to see if the hot water or heating is active
|
||||||
@@ -897,7 +878,7 @@ void Boiler::process_UBAMonitorFastPlus(std::shared_ptr<const Telegram> telegram
|
|||||||
* 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 17 19 20 21 22 23 24
|
* 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 17 19 20 21 22 23 24
|
||||||
*/
|
*/
|
||||||
void Boiler::process_UBAMonitorSlow(std::shared_ptr<const Telegram> telegram) {
|
void Boiler::process_UBAMonitorSlow(std::shared_ptr<const Telegram> telegram) {
|
||||||
changed_ |= telegram->read_value(extTemp_, 0);
|
changed_ |= telegram->read_value(outdoorTemp_, 0);
|
||||||
changed_ |= telegram->read_value(boilTemp_, 2);
|
changed_ |= telegram->read_value(boilTemp_, 2);
|
||||||
changed_ |= telegram->read_value(exhaustTemp_, 4);
|
changed_ |= telegram->read_value(exhaustTemp_, 4);
|
||||||
changed_ |= telegram->read_value(switchTemp_, 25); // only if there is a mixing module present
|
changed_ |= telegram->read_value(switchTemp_, 25); // only if there is a mixing module present
|
||||||
@@ -920,7 +901,7 @@ void Boiler::process_UBAMonitorSlowPlus2(std::shared_ptr<const Telegram> telegra
|
|||||||
void Boiler::process_UBAMonitorSlowPlus(std::shared_ptr<const Telegram> telegram) {
|
void Boiler::process_UBAMonitorSlowPlus(std::shared_ptr<const Telegram> telegram) {
|
||||||
changed_ |= telegram->read_bitvalue(fanWork_, 2, 2);
|
changed_ |= telegram->read_bitvalue(fanWork_, 2, 2);
|
||||||
changed_ |= telegram->read_bitvalue(ignWork_, 2, 3);
|
changed_ |= telegram->read_bitvalue(ignWork_, 2, 3);
|
||||||
changed_ |= telegram->read_bitvalue(heatPmp_, 2, 5);
|
changed_ |= telegram->read_bitvalue(heatPump_, 2, 5);
|
||||||
changed_ |= telegram->read_bitvalue(wWCirc_, 2, 7);
|
changed_ |= telegram->read_bitvalue(wWCirc_, 2, 7);
|
||||||
changed_ |= telegram->read_value(burnStarts_, 10, 3); // force to 3 bytes
|
changed_ |= telegram->read_value(burnStarts_, 10, 3); // force to 3 bytes
|
||||||
changed_ |= telegram->read_value(burnWorkMin_, 13, 3); // force to 3 bytes
|
changed_ |= telegram->read_value(burnWorkMin_, 13, 3); // force to 3 bytes
|
||||||
@@ -932,13 +913,13 @@ void Boiler::process_UBAMonitorSlowPlus(std::shared_ptr<const Telegram> telegram
|
|||||||
* UBAParametersPlus - type 0xe6
|
* UBAParametersPlus - type 0xe6
|
||||||
*/
|
*/
|
||||||
void Boiler::process_UBAParametersPlus(std::shared_ptr<const Telegram> telegram) {
|
void Boiler::process_UBAParametersPlus(std::shared_ptr<const Telegram> telegram) {
|
||||||
changed_ |= telegram->read_value(heating_activated_, 0);
|
changed_ |= telegram->read_value(heatingActivated_, 0);
|
||||||
changed_ |= telegram->read_value(heating_temp_, 1);
|
changed_ |= telegram->read_value(heatingTemp_, 1);
|
||||||
changed_ |= telegram->read_value(burnPowermax_, 6);
|
changed_ |= telegram->read_value(burnMaxPower_, 6);
|
||||||
changed_ |= telegram->read_value(burnPowermin_, 7);
|
changed_ |= telegram->read_value(burnMinPower_, 7);
|
||||||
changed_ |= telegram->read_value(boilTemp_off_, 8);
|
changed_ |= telegram->read_value(boilHystOff_, 8);
|
||||||
changed_ |= telegram->read_value(boilTemp_on_, 9);
|
changed_ |= telegram->read_value(boilHystOn_, 9);
|
||||||
changed_ |= telegram->read_value(burnPeriod_, 10);
|
changed_ |= telegram->read_value(burnMinPeriod_, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 0xEA
|
// 0xEA
|
||||||
@@ -953,9 +934,9 @@ void Boiler::process_UBAParameterWWPlus(std::shared_ptr<const Telegram> telegram
|
|||||||
// 0xE9 - DHW Status
|
// 0xE9 - DHW Status
|
||||||
// e.g. 08 00 E9 00 37 01 F6 01 ED 00 00 00 00 41 3C 00 00 00 00 00 00 00 00 00 00 00 00 37 00 00 00 (CRC=77) #data=27
|
// e.g. 08 00 E9 00 37 01 F6 01 ED 00 00 00 00 41 3C 00 00 00 00 00 00 00 00 00 00 00 00 37 00 00 00 (CRC=77) #data=27
|
||||||
void Boiler::process_UBADHWStatus(std::shared_ptr<const Telegram> telegram) {
|
void Boiler::process_UBADHWStatus(std::shared_ptr<const Telegram> telegram) {
|
||||||
changed_ |= telegram->read_value(wWSetTmp_, 0);
|
changed_ |= telegram->read_value(wWSetTemp_, 0);
|
||||||
changed_ |= telegram->read_value(wWCurTmp_, 1);
|
changed_ |= telegram->read_value(wWCurTemp_, 1);
|
||||||
changed_ |= telegram->read_value(wWCurTmp2_, 3);
|
changed_ |= telegram->read_value(wWCurTemp2_, 3);
|
||||||
|
|
||||||
changed_ |= telegram->read_value(wWWorkM_, 17, 3); // force to 3 bytes
|
changed_ |= telegram->read_value(wWWorkM_, 17, 3); // force to 3 bytes
|
||||||
changed_ |= telegram->read_value(wWStarts_, 14, 3); // force to 3 bytes
|
changed_ |= telegram->read_value(wWStarts_, 14, 3); // force to 3 bytes
|
||||||
@@ -964,12 +945,12 @@ void Boiler::process_UBADHWStatus(std::shared_ptr<const Telegram> telegram) {
|
|||||||
changed_ |= telegram->read_bitvalue(wWDisinfecting_, 12, 3);
|
changed_ |= telegram->read_bitvalue(wWDisinfecting_, 12, 3);
|
||||||
changed_ |= telegram->read_bitvalue(wWCharging_, 12, 4);
|
changed_ |= telegram->read_bitvalue(wWCharging_, 12, 4);
|
||||||
changed_ |= telegram->read_bitvalue(wWRecharging_, 13, 4);
|
changed_ |= telegram->read_bitvalue(wWRecharging_, 13, 4);
|
||||||
changed_ |= telegram->read_bitvalue(wWTemperatureOK_, 13, 5);
|
changed_ |= telegram->read_bitvalue(wWTempOK_, 13, 5);
|
||||||
changed_ |= telegram->read_bitvalue(wWCircPump_, 13, 2);
|
changed_ |= telegram->read_bitvalue(wWCircPump_, 13, 2);
|
||||||
|
|
||||||
// changed_ |= telegram->read_value(wWActivated_, 20); // Activated is in 0xEA, this is something other 0/100%
|
// changed_ |= telegram->read_value(wWActivated_, 20); // Activated is in 0xEA, this is something other 0/100%
|
||||||
changed_ |= telegram->read_value(wWSelTemp_, 10);
|
changed_ |= telegram->read_value(wWSelTemp_, 10);
|
||||||
changed_ |= telegram->read_value(wWDisinfectTemp_, 9);
|
changed_ |= telegram->read_value(wWDisinfectionTemp_, 9);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 0x2A - MC10Status
|
// 0x2A - MC10Status
|
||||||
@@ -984,14 +965,14 @@ void Boiler::process_MC10Status(std::shared_ptr<const Telegram> telegram) {
|
|||||||
* UBAOutdoorTemp - type 0xD1 - external temperature EMS+
|
* UBAOutdoorTemp - type 0xD1 - external temperature EMS+
|
||||||
*/
|
*/
|
||||||
void Boiler::process_UBAOutdoorTemp(std::shared_ptr<const Telegram> telegram) {
|
void Boiler::process_UBAOutdoorTemp(std::shared_ptr<const Telegram> telegram) {
|
||||||
changed_ |= telegram->read_value(extTemp_, 0);
|
changed_ |= telegram->read_value(outdoorTemp_, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// UBASetPoint 0x1A
|
// UBASetPoint 0x1A
|
||||||
void Boiler::process_UBASetPoints(std::shared_ptr<const Telegram> telegram) {
|
void Boiler::process_UBASetPoints(std::shared_ptr<const Telegram> telegram) {
|
||||||
changed_ |= telegram->read_value(setFlowTemp_, 0); // boiler set temp from thermostat
|
changed_ |= telegram->read_value(setFlowTemp_, 0); // boiler set temp from thermostat
|
||||||
changed_ |= telegram->read_value(setBurnPow_, 1); // max output power in %
|
changed_ |= telegram->read_value(setBurnPow_, 1); // max output power in %
|
||||||
changed_ |= telegram->read_value(setWWPumpPow_, 2); // ww pump speed/power?
|
changed_ |= telegram->read_value(wWSetPumpPower_, 2); // ww pump speed/power?
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma GCC diagnostic push
|
#pragma GCC diagnostic push
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ class Boiler : public EMSdevice {
|
|||||||
|
|
||||||
uint8_t last_boilerState = 0xFF; // remember last state of heating and warm water on/off
|
uint8_t last_boilerState = 0xFF; // remember last state of heating and warm water on/off
|
||||||
bool changed_ = false;
|
bool changed_ = false;
|
||||||
|
bool mqtt_ha_config_ = false; // HA MQTT Discovery
|
||||||
|
|
||||||
static constexpr uint8_t EMS_TYPE_UBAParameterWW = 0x33;
|
static constexpr uint8_t EMS_TYPE_UBAParameterWW = 0x33;
|
||||||
static constexpr uint8_t EMS_TYPE_UBAFunctionTest = 0x1D;
|
static constexpr uint8_t EMS_TYPE_UBAFunctionTest = 0x1D;
|
||||||
@@ -71,7 +72,7 @@ class Boiler : public EMSdevice {
|
|||||||
uint8_t wWCircPump_ = EMS_VALUE_BOOL_NOTSET; // Warm Water circulation pump available
|
uint8_t wWCircPump_ = EMS_VALUE_BOOL_NOTSET; // Warm Water circulation pump available
|
||||||
uint8_t wWCircPumpMode_ = EMS_VALUE_UINT_NOTSET; // Warm Water circulation pump mode
|
uint8_t wWCircPumpMode_ = EMS_VALUE_UINT_NOTSET; // Warm Water circulation pump mode
|
||||||
uint8_t wWChargeType_ = EMS_VALUE_BOOL_NOTSET; // Warm Water charge type (pump or 3-way-valve)
|
uint8_t wWChargeType_ = EMS_VALUE_BOOL_NOTSET; // Warm Water charge type (pump or 3-way-valve)
|
||||||
uint8_t wWDisinfectTemp_ = EMS_VALUE_UINT_NOTSET; // Warm Water disinfection temperature to prevent infection
|
uint8_t wWDisinfectionTemp_ = EMS_VALUE_UINT_NOTSET; // Warm Water disinfection temperature to prevent infection
|
||||||
uint8_t wWComfort_ = EMS_VALUE_UINT_NOTSET; // WW comfort mode
|
uint8_t wWComfort_ = EMS_VALUE_UINT_NOTSET; // WW comfort mode
|
||||||
|
|
||||||
// MC10Status
|
// MC10Status
|
||||||
@@ -87,19 +88,19 @@ class Boiler : public EMSdevice {
|
|||||||
uint8_t burnGas_ = EMS_VALUE_BOOL_NOTSET; // Gas on/off
|
uint8_t burnGas_ = EMS_VALUE_BOOL_NOTSET; // Gas on/off
|
||||||
uint8_t fanWork_ = EMS_VALUE_BOOL_NOTSET; // Fan on/off
|
uint8_t fanWork_ = EMS_VALUE_BOOL_NOTSET; // Fan on/off
|
||||||
uint8_t ignWork_ = EMS_VALUE_BOOL_NOTSET; // Ignition on/off
|
uint8_t ignWork_ = EMS_VALUE_BOOL_NOTSET; // Ignition on/off
|
||||||
uint8_t heatPmp_ = EMS_VALUE_BOOL_NOTSET; // Boiler pump on/off
|
uint8_t heatPump_ = EMS_VALUE_BOOL_NOTSET; // Boiler pump on/off
|
||||||
uint8_t wWHeat_ = EMS_VALUE_BOOL_NOTSET; // 3-way valve on WW
|
uint8_t wWHeat_ = EMS_VALUE_BOOL_NOTSET; // 3-way valve on WW
|
||||||
uint8_t wWCirc_ = EMS_VALUE_BOOL_NOTSET; // Circulation on/off
|
uint8_t wWCirc_ = EMS_VALUE_BOOL_NOTSET; // Circulation on/off
|
||||||
uint8_t selBurnPow_ = EMS_VALUE_UINT_NOTSET; // Burner max power %
|
uint8_t selBurnPow_ = EMS_VALUE_UINT_NOTSET; // Burner max power %
|
||||||
uint8_t curBurnPow_ = EMS_VALUE_UINT_NOTSET; // Burner current power %
|
uint8_t curBurnPow_ = EMS_VALUE_UINT_NOTSET; // Burner current power %
|
||||||
uint16_t flameCurr_ = EMS_VALUE_USHORT_NOTSET; // Flame current in micro amps
|
uint16_t flameCurr_ = EMS_VALUE_USHORT_NOTSET; // Flame current in micro amps
|
||||||
uint8_t sysPress_ = EMS_VALUE_UINT_NOTSET; // System pressure
|
uint8_t sysPress_ = EMS_VALUE_UINT_NOTSET; // System pressure
|
||||||
char serviceCodeChar_[3] = {'\0'}; // 2 character status/service code
|
char serviceCode_[3] = {'\0'}; // 2 character status/service code
|
||||||
uint16_t serviceCode_ = EMS_VALUE_USHORT_NOTSET; // error/service code
|
uint16_t serviceCodeNumber_ = EMS_VALUE_USHORT_NOTSET; // error/service code
|
||||||
uint8_t boilerState_ = EMS_VALUE_BOOL_NOTSET; // State flag, used on HT3
|
uint8_t boilerState_ = EMS_VALUE_BOOL_NOTSET; // State flag, used on HT3
|
||||||
|
|
||||||
// UBAMonitorSlow - 0x19 on EMS1
|
// UBAMonitorSlow - 0x19 on EMS1
|
||||||
int16_t extTemp_ = EMS_VALUE_SHORT_NOTSET; // Outside temperature
|
int16_t outdoorTemp_ = EMS_VALUE_SHORT_NOTSET; // Outside temperature
|
||||||
uint16_t boilTemp_ = EMS_VALUE_USHORT_NOTSET; // Boiler temperature
|
uint16_t boilTemp_ = EMS_VALUE_USHORT_NOTSET; // Boiler temperature
|
||||||
uint16_t exhaustTemp_ = EMS_VALUE_USHORT_NOTSET; // Exhaust temperature
|
uint16_t exhaustTemp_ = EMS_VALUE_USHORT_NOTSET; // Exhaust temperature
|
||||||
uint8_t pumpMod_ = EMS_VALUE_UINT_NOTSET; // Pump modulation %
|
uint8_t pumpMod_ = EMS_VALUE_UINT_NOTSET; // Pump modulation %
|
||||||
@@ -109,16 +110,16 @@ class Boiler : public EMSdevice {
|
|||||||
uint16_t switchTemp_ = EMS_VALUE_USHORT_NOTSET; // Switch temperature
|
uint16_t switchTemp_ = EMS_VALUE_USHORT_NOTSET; // Switch temperature
|
||||||
|
|
||||||
// UBAMonitorWW
|
// UBAMonitorWW
|
||||||
uint8_t wWSetTmp_ = EMS_VALUE_UINT_NOTSET; // Warm Water set temperature
|
uint8_t wWSetTemp_ = EMS_VALUE_UINT_NOTSET; // Warm Water set temperature
|
||||||
uint16_t wWCurTmp_ = EMS_VALUE_USHORT_NOTSET; // Warm Water current temperature
|
uint16_t wWCurTemp_ = EMS_VALUE_USHORT_NOTSET; // Warm Water current temperature
|
||||||
uint16_t wWCurTmp2_ = EMS_VALUE_USHORT_NOTSET; // Warm Water current temperature storage
|
uint16_t wWCurTemp2_ = EMS_VALUE_USHORT_NOTSET; // Warm Water current temperature storage
|
||||||
uint32_t wWStarts_ = EMS_VALUE_ULONG_NOTSET; // Warm Water # starts
|
uint32_t wWStarts_ = EMS_VALUE_ULONG_NOTSET; // Warm Water # starts
|
||||||
uint32_t wWWorkM_ = EMS_VALUE_ULONG_NOTSET; // Warm Water # minutes
|
uint32_t wWWorkM_ = EMS_VALUE_ULONG_NOTSET; // Warm Water # minutes
|
||||||
uint8_t wWOneTime_ = EMS_VALUE_BOOL_NOTSET; // Warm Water one time function on/off
|
uint8_t wWOneTime_ = EMS_VALUE_BOOL_NOTSET; // Warm Water one time function on/off
|
||||||
uint8_t wWDisinfecting_ = EMS_VALUE_BOOL_NOTSET; // Warm Water disinfection on/off
|
uint8_t wWDisinfecting_ = EMS_VALUE_BOOL_NOTSET; // Warm Water disinfection on/off
|
||||||
uint8_t wWCharging_ = EMS_VALUE_BOOL_NOTSET; // Warm Water charging on/off
|
uint8_t wWCharging_ = EMS_VALUE_BOOL_NOTSET; // Warm Water charging on/off
|
||||||
uint8_t wWRecharging_ = EMS_VALUE_BOOL_NOTSET; // Warm Water recharge on/off
|
uint8_t wWRecharging_ = EMS_VALUE_BOOL_NOTSET; // Warm Water recharge on/off
|
||||||
uint8_t wWTemperatureOK_ = EMS_VALUE_BOOL_NOTSET; // Warm Water temperature ok on/off
|
uint8_t wWTempOK_ = EMS_VALUE_BOOL_NOTSET; // Warm Water temperature ok on/off
|
||||||
uint8_t wWCurFlow_ = EMS_VALUE_UINT_NOTSET; // Warm Water current flow temp in l/min
|
uint8_t wWCurFlow_ = EMS_VALUE_UINT_NOTSET; // Warm Water current flow temp in l/min
|
||||||
uint8_t wWType_ = EMS_VALUE_UINT_NOTSET; // 0-off, 1-flow, 2-flowbuffer, 3-buffer, 4-layered buffer
|
uint8_t wWType_ = EMS_VALUE_UINT_NOTSET; // 0-off, 1-flow, 2-flowbuffer, 3-buffer, 4-layered buffer
|
||||||
uint8_t wWActive_ = EMS_VALUE_BOOL_NOTSET;
|
uint8_t wWActive_ = EMS_VALUE_BOOL_NOTSET;
|
||||||
@@ -127,25 +128,25 @@ class Boiler : public EMSdevice {
|
|||||||
uint32_t UBAuptime_ = EMS_VALUE_ULONG_NOTSET; // Total UBA working hours
|
uint32_t UBAuptime_ = EMS_VALUE_ULONG_NOTSET; // Total UBA working hours
|
||||||
|
|
||||||
// UBAParameters
|
// UBAParameters
|
||||||
uint8_t heating_activated_ = EMS_VALUE_BOOL_NOTSET; // Heating activated on the boiler
|
uint8_t heatingActivated_ = EMS_VALUE_BOOL_NOTSET; // Heating activated on the boiler
|
||||||
uint8_t heating_temp_ = EMS_VALUE_UINT_NOTSET; // Heating temperature setting on the boiler
|
uint8_t heatingTemp_ = EMS_VALUE_UINT_NOTSET; // Heating temperature setting on the boiler
|
||||||
uint8_t pump_mod_max_ = EMS_VALUE_UINT_NOTSET; // Boiler circuit pump modulation max. power %
|
uint8_t pumpModMax_ = EMS_VALUE_UINT_NOTSET; // Boiler circuit pump modulation max. power %
|
||||||
uint8_t pump_mod_min_ = EMS_VALUE_UINT_NOTSET; // Boiler circuit pump modulation min. power
|
uint8_t pumpModMin_ = EMS_VALUE_UINT_NOTSET; // Boiler circuit pump modulation min. power
|
||||||
uint8_t burnPowermin_ = EMS_VALUE_UINT_NOTSET;
|
uint8_t burnMinPower_ = EMS_VALUE_UINT_NOTSET;
|
||||||
uint8_t burnPowermax_ = EMS_VALUE_UINT_NOTSET;
|
uint8_t burnMaxPower_ = EMS_VALUE_UINT_NOTSET;
|
||||||
int8_t boilTemp_off_ = EMS_VALUE_INT_NOTSET;
|
int8_t boilHystOff_ = EMS_VALUE_INT_NOTSET;
|
||||||
int8_t boilTemp_on_ = EMS_VALUE_INT_NOTSET;
|
int8_t boilHystOn_ = EMS_VALUE_INT_NOTSET;
|
||||||
uint8_t burnPeriod_ = EMS_VALUE_UINT_NOTSET;
|
uint8_t burnMinPeriod_ = EMS_VALUE_UINT_NOTSET;
|
||||||
uint8_t pumpDelay_ = EMS_VALUE_UINT_NOTSET;
|
uint8_t pumpDelay_ = EMS_VALUE_UINT_NOTSET;
|
||||||
|
|
||||||
// UBASetPoint
|
// UBASetPoint
|
||||||
uint8_t setFlowTemp_ = EMS_VALUE_UINT_NOTSET; // boiler setpoint temp
|
uint8_t setFlowTemp_ = EMS_VALUE_UINT_NOTSET; // boiler setpoint temp
|
||||||
uint8_t setBurnPow_ = EMS_VALUE_UINT_NOTSET; // max output power in %
|
uint8_t setBurnPow_ = EMS_VALUE_UINT_NOTSET; // max output power in %
|
||||||
uint8_t setWWPumpPow_ = EMS_VALUE_UINT_NOTSET; // ww pump speed/power?
|
uint8_t wWSetPumpPower_ = EMS_VALUE_UINT_NOTSET; // ww pump speed/power?
|
||||||
|
|
||||||
// other internal calculated params
|
// other internal calculated params
|
||||||
uint8_t tap_water_active_ = EMS_VALUE_BOOL_NOTSET; // Hot tap water is on/off
|
uint8_t tapwaterActive_ = EMS_VALUE_BOOL_NOTSET; // Hot tap water is on/off
|
||||||
uint8_t heating_active_ = EMS_VALUE_BOOL_NOTSET; // Central heating is on/off
|
uint8_t heatingActive_ = EMS_VALUE_BOOL_NOTSET; // Central heating is on/off
|
||||||
uint8_t pumpMod2_ = EMS_VALUE_UINT_NOTSET; // heatpump modulation from 0xE3 (heatpumps)
|
uint8_t pumpMod2_ = EMS_VALUE_UINT_NOTSET; // heatpump modulation from 0xE3 (heatpumps)
|
||||||
|
|
||||||
bool command_info(const char * value, const int8_t id, JsonObject & output);
|
bool command_info(const char * value, const int8_t id, JsonObject & output);
|
||||||
|
|||||||
@@ -138,8 +138,9 @@ void Mixing::publish_values() {
|
|||||||
Mqtt::publish(topic, doc.as<JsonObject>());
|
Mqtt::publish(topic, doc.as<JsonObject>());
|
||||||
|
|
||||||
// if we're using Home Assistant and haven't created the MQTT Discovery topics, do it now
|
// if we're using Home Assistant and haven't created the MQTT Discovery topics, do it now
|
||||||
if ((Mqtt::mqtt_format() == Mqtt::Format::HA) && (!ha_created_)) {
|
if ((Mqtt::mqtt_format() == Mqtt::Format::HA) && (!mqtt_ha_config_)) {
|
||||||
register_mqtt_ha_config(topic);
|
register_mqtt_ha_config(topic);
|
||||||
|
mqtt_ha_config_ = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -177,7 +178,6 @@ void Mixing::register_mqtt_ha_config(const char * topic) {
|
|||||||
Mqtt::register_mqtt_ha_sensor(nullptr, F_(pumpStatus), this->device_type(), "pumpStatus", nullptr, nullptr);
|
Mqtt::register_mqtt_ha_sensor(nullptr, F_(pumpStatus), this->device_type(), "pumpStatus", nullptr, nullptr);
|
||||||
Mqtt::register_mqtt_ha_sensor(nullptr, F_(tempStatus), this->device_type(), "tempStatus", nullptr, nullptr);
|
Mqtt::register_mqtt_ha_sensor(nullptr, F_(tempStatus), this->device_type(), "tempStatus", nullptr, nullptr);
|
||||||
}
|
}
|
||||||
ha_created_ = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// creates JSON doc from values
|
// creates JSON doc from values
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ class Mixing : public EMSdevice {
|
|||||||
Type type_ = Type::NONE;
|
Type type_ = Type::NONE;
|
||||||
|
|
||||||
bool changed_ = false;
|
bool changed_ = false;
|
||||||
bool ha_created_ = false; // for HA MQTT Discovery
|
bool mqtt_ha_config_ = false; // for HA MQTT Discovery
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace emsesp
|
} // namespace emsesp
|
||||||
|
|||||||
@@ -127,8 +127,9 @@ void Solar::publish_values() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// if we're using Home Assistant and haven't created the MQTT Discovery topics, do it now
|
// if we're using Home Assistant and haven't created the MQTT Discovery topics, do it now
|
||||||
if ((Mqtt::mqtt_format() == Mqtt::Format::HA) && (!ha_created_)) {
|
if ((Mqtt::mqtt_format() == Mqtt::Format::HA) && (!mqtt_ha_config_)) {
|
||||||
register_mqtt_ha_config();
|
register_mqtt_ha_config();
|
||||||
|
mqtt_ha_config_ = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -164,8 +165,6 @@ void Solar::register_mqtt_ha_config() {
|
|||||||
Mqtt::register_mqtt_ha_sensor(nullptr, F_(valveStatus), this->device_type(), "valveStatus", nullptr, nullptr);
|
Mqtt::register_mqtt_ha_sensor(nullptr, F_(valveStatus), this->device_type(), "valveStatus", nullptr, nullptr);
|
||||||
Mqtt::register_mqtt_ha_sensor(nullptr, F_(tankHeated), this->device_type(), "tankHeated", nullptr, nullptr);
|
Mqtt::register_mqtt_ha_sensor(nullptr, F_(tankHeated), this->device_type(), "tankHeated", nullptr, nullptr);
|
||||||
Mqtt::register_mqtt_ha_sensor(nullptr, F_(collectorShutdown), this->device_type(), "collectorShutdown", nullptr, nullptr);
|
Mqtt::register_mqtt_ha_sensor(nullptr, F_(collectorShutdown), this->device_type(), "collectorShutdown", nullptr, nullptr);
|
||||||
|
|
||||||
ha_created_ = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// creates JSON doc from values
|
// creates JSON doc from values
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ class Solar : public EMSdevice {
|
|||||||
uint8_t userFlag_ = EMS_VALUE_BOOL_NOTSET;
|
uint8_t userFlag_ = EMS_VALUE_BOOL_NOTSET;
|
||||||
|
|
||||||
bool changed_ = false;
|
bool changed_ = false;
|
||||||
bool ha_created_ = false; // for HA MQTT Discovery
|
bool mqtt_ha_config_ = false; // for HA MQTT Discovery
|
||||||
|
|
||||||
void process_SM10Monitor(std::shared_ptr<const Telegram> telegram);
|
void process_SM10Monitor(std::shared_ptr<const Telegram> telegram);
|
||||||
void process_SM100Monitor(std::shared_ptr<const Telegram> telegram);
|
void process_SM100Monitor(std::shared_ptr<const Telegram> telegram);
|
||||||
|
|||||||
104
src/mqtt.cpp
104
src/mqtt.cpp
@@ -514,12 +514,12 @@ std::shared_ptr<const MqttMessage> Mqtt::queue_message(const uint8_t operation,
|
|||||||
std::shared_ptr<MqttMessage> message;
|
std::shared_ptr<MqttMessage> message;
|
||||||
if ((strncmp(topic.c_str(), "homeassistant/", 13) == 0)) {
|
if ((strncmp(topic.c_str(), "homeassistant/", 13) == 0)) {
|
||||||
// leave topic as it is
|
// leave topic as it is
|
||||||
message = std::make_shared<MqttMessage>(operation, topic, std::move(payload), retain);
|
message = std::make_shared<MqttMessage>(operation, topic, payload, retain);
|
||||||
} else {
|
} else {
|
||||||
// prefix the hostname
|
// prefix the hostname
|
||||||
std::string full_topic(100, '\0');
|
std::string full_topic(100, '\0');
|
||||||
snprintf_P(&full_topic[0], full_topic.capacity() + 1, PSTR("%s/%s"), hostname_.c_str(), topic.c_str());
|
snprintf_P(&full_topic[0], full_topic.capacity() + 1, PSTR("%s/%s"), hostname_.c_str(), topic.c_str());
|
||||||
message = std::make_shared<MqttMessage>(operation, full_topic, std::move(payload), retain);
|
message = std::make_shared<MqttMessage>(operation, full_topic, payload, retain);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if the queue is full, make room but removing the last one
|
// if the queue is full, make room but removing the last one
|
||||||
@@ -565,20 +565,7 @@ void Mqtt::publish(const __FlashStringHelper * topic, const JsonObject & payload
|
|||||||
|
|
||||||
// publish json doc, only if its not empty
|
// publish json doc, only if its not empty
|
||||||
void Mqtt::publish(const std::string & topic, const JsonObject & payload) {
|
void Mqtt::publish(const std::string & topic, const JsonObject & payload) {
|
||||||
if (enabled() && payload.size()) {
|
publish_retain(topic, payload, mqtt_retain_);
|
||||||
std::string payload_text;
|
|
||||||
serializeJson(payload, payload_text); // convert json to string
|
|
||||||
queue_publish_message(topic, payload_text, mqtt_retain_);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// for booleans, which get converted to string values 1 and 0
|
|
||||||
void Mqtt::publish(const std::string & topic, bool value) {
|
|
||||||
queue_publish_message(topic, value ? "1" : "0", false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Mqtt::publish(const __FlashStringHelper * topic, bool value) {
|
|
||||||
queue_publish_message(uuid::read_flash_string(topic), value ? "1" : "0", false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// no payload
|
// no payload
|
||||||
@@ -593,6 +580,13 @@ void Mqtt::publish_retain(const __FlashStringHelper * topic, const std::string &
|
|||||||
|
|
||||||
// publish json doc, only if its not empty, using the retain flag
|
// publish json doc, only if its not empty, using the retain flag
|
||||||
void Mqtt::publish_retain(const std::string & topic, const JsonObject & payload, bool retain) {
|
void Mqtt::publish_retain(const std::string & topic, const JsonObject & payload, bool retain) {
|
||||||
|
/*
|
||||||
|
// for HA, empty payload will remove the previous config
|
||||||
|
if (retain == true) {
|
||||||
|
publish(topic);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
if (enabled() && payload.size()) {
|
if (enabled() && payload.size()) {
|
||||||
std::string payload_text;
|
std::string payload_text;
|
||||||
serializeJson(payload, payload_text); // convert json to string
|
serializeJson(payload, payload_text); // convert json to string
|
||||||
@@ -677,7 +671,9 @@ void Mqtt::process_queue() {
|
|||||||
// but add the packet_id so we can check it later
|
// but add the packet_id so we can check it later
|
||||||
if (mqtt_qos_ != 0) {
|
if (mqtt_qos_ != 0) {
|
||||||
mqtt_messages_.front().packet_id_ = packet_id;
|
mqtt_messages_.front().packet_id_ = packet_id;
|
||||||
// LOG_DEBUG(F("Setting packetID for ACK to %d"), packet_id);
|
#if defined(EMSESP_DEBUG)
|
||||||
|
LOG_DEBUG(F("Setting packetID for ACK to %d"), packet_id);
|
||||||
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -686,12 +682,11 @@ void Mqtt::process_queue() {
|
|||||||
|
|
||||||
// HA config for a binary_sensor
|
// HA config for a binary_sensor
|
||||||
void Mqtt::register_mqtt_ha_binary_sensor(const __FlashStringHelper * name, const uint8_t device_type, const char * entity) {
|
void Mqtt::register_mqtt_ha_binary_sensor(const __FlashStringHelper * name, const uint8_t device_type, const char * entity) {
|
||||||
|
|
||||||
if (mqtt_format() != Format::HA) {
|
if (mqtt_format() != Format::HA) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
StaticJsonDocument<EMSESP_MAX_JSON_SIZE_SMALL> doc;
|
DynamicJsonDocument doc(EMSESP_MAX_JSON_SIZE_MEDIUM);
|
||||||
|
|
||||||
doc["name"] = name;
|
doc["name"] = name;
|
||||||
doc["uniq_id"] = entity;
|
doc["uniq_id"] = entity;
|
||||||
@@ -719,10 +714,21 @@ void Mqtt::register_mqtt_ha_binary_sensor(const __FlashStringHelper * name, cons
|
|||||||
snprintf_P(ha_device, sizeof(ha_device), PSTR("ems-esp-%s"), EMSdevice::device_type_2_device_name(device_type).c_str());
|
snprintf_P(ha_device, sizeof(ha_device), PSTR("ems-esp-%s"), EMSdevice::device_type_2_device_name(device_type).c_str());
|
||||||
ids.add(ha_device);
|
ids.add(ha_device);
|
||||||
|
|
||||||
std::string topic(100, '\0');
|
char topic[MQTT_TOPIC_MAX_SIZE];
|
||||||
snprintf_P(&topic[0], topic.capacity() + 1, PSTR("homeassistant/binary_sensor/ems-esp/%s/config"), entity);
|
snprintf_P(topic, sizeof(topic), PSTR("homeassistant/binary_sensor/ems-esp/%s/config"), entity);
|
||||||
|
|
||||||
Mqtt::publish_retain(topic, doc.as<JsonObject>(), true); // publish the config payload with retain flag
|
// convert json to string and publish immediately with retain forced to true
|
||||||
|
doc.shrinkToFit();
|
||||||
|
std::string payload_text;
|
||||||
|
serializeJson(doc, payload_text); // convert json to string
|
||||||
|
uint16_t packet_id = mqttClient_->publish(topic, 0, true, payload_text.c_str(), payload_text.size());
|
||||||
|
if (packet_id == 0) {
|
||||||
|
LOG_ERROR(F("Failed to publish topic %s"), topic);
|
||||||
|
} else {
|
||||||
|
LOG_DEBUG(F("Publishing topic %s"), topic);
|
||||||
|
}
|
||||||
|
|
||||||
|
delay(MQTT_PUBLISH_WAIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
// HA config for a normal 'sensor' type
|
// HA config for a normal 'sensor' type
|
||||||
@@ -737,52 +743,64 @@ void Mqtt::register_mqtt_ha_sensor(const char * prefix,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
StaticJsonDocument<EMSESP_MAX_JSON_SIZE_SMALL> doc;
|
// create entity by prefixing any given prefix
|
||||||
|
char new_entity[50];
|
||||||
std::string device_name = EMSdevice::device_type_2_device_name(device_type);
|
|
||||||
|
|
||||||
char new_entity[20];
|
|
||||||
// add prefix to entity if its specified
|
|
||||||
if (prefix != nullptr) {
|
if (prefix != nullptr) {
|
||||||
snprintf_P(new_entity, sizeof(new_entity), PSTR("%s.%s"), prefix, entity);
|
snprintf_P(new_entity, sizeof(new_entity), PSTR("%s.%s"), prefix, entity);
|
||||||
} else {
|
} else {
|
||||||
strcpy(new_entity, entity);
|
strcpy(new_entity, entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
doc["name"] = name;
|
std::string device_name = EMSdevice::device_type_2_device_name(device_type);
|
||||||
|
|
||||||
// build unique identifier, replacing all . with _ as not to break HA
|
// build unique identifier, replacing all . with _ as not to break HA
|
||||||
std::string uniq(50, '\0');
|
std::string uniq(50, '\0');
|
||||||
snprintf_P(&uniq[0], uniq.capacity() + 1, PSTR("%s_%s"), device_name.c_str(), new_entity);
|
snprintf_P(&uniq[0], uniq.capacity() + 1, PSTR("%s_%s"), device_name.c_str(), new_entity);
|
||||||
std::replace(uniq.begin(), uniq.end(), '.', '_');
|
std::replace(uniq.begin(), uniq.end(), '.', '_');
|
||||||
doc["uniq_id"] = uniq;
|
|
||||||
|
|
||||||
|
// topic
|
||||||
|
char topic[MQTT_TOPIC_MAX_SIZE];
|
||||||
|
snprintf_P(topic, sizeof(topic), PSTR("homeassistant/sensor/ems-esp/%s/config"), uniq.c_str());
|
||||||
|
|
||||||
|
// state topic
|
||||||
|
char state_t[50];
|
||||||
|
snprintf_P(state_t, sizeof(state_t), PSTR("%s/%s_data"), hostname_.c_str(), device_name.c_str());
|
||||||
|
|
||||||
|
// state template
|
||||||
|
char tpl[50];
|
||||||
|
snprintf_P(tpl, sizeof(tpl), PSTR("{{value_json.%s}}"), new_entity);
|
||||||
|
|
||||||
|
// ha device
|
||||||
|
char ha_device[40];
|
||||||
|
snprintf_P(ha_device, sizeof(ha_device), PSTR("ems-esp-%s"), device_name.c_str());
|
||||||
|
|
||||||
|
DynamicJsonDocument doc(EMSESP_MAX_JSON_SIZE_MEDIUM);
|
||||||
|
doc["name"] = name;
|
||||||
|
doc["uniq_id"] = uniq;
|
||||||
if (uom != nullptr) {
|
if (uom != nullptr) {
|
||||||
doc["unit_of_meas"] = uom;
|
doc["unit_of_meas"] = uom;
|
||||||
}
|
}
|
||||||
|
|
||||||
char state_t[50];
|
|
||||||
snprintf_P(state_t, sizeof(state_t), PSTR("%s/%s_data"), hostname_.c_str(), device_name.c_str());
|
|
||||||
doc["stat_t"] = state_t;
|
doc["stat_t"] = state_t;
|
||||||
|
|
||||||
char tpl[50];
|
|
||||||
snprintf_P(tpl, sizeof(tpl), PSTR("{{value_json.%s}}"), new_entity);
|
|
||||||
doc["val_tpl"] = tpl;
|
doc["val_tpl"] = tpl;
|
||||||
|
|
||||||
if (icon != nullptr) {
|
if (icon != nullptr) {
|
||||||
doc["ic"] = icon;
|
doc["ic"] = icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
JsonObject dev = doc.createNestedObject(F("dev"));
|
JsonObject dev = doc.createNestedObject(F("dev"));
|
||||||
JsonArray ids = dev.createNestedArray(F("ids"));
|
JsonArray ids = dev.createNestedArray(F("ids"));
|
||||||
char ha_device[40];
|
|
||||||
snprintf_P(ha_device, sizeof(ha_device), PSTR("ems-esp-%s"), device_name.c_str());
|
|
||||||
ids.add(ha_device);
|
ids.add(ha_device);
|
||||||
|
|
||||||
std::string topic(100, '\0');
|
// convert json to string and publish immediately with retain forced to true
|
||||||
snprintf_P(&topic[0], topic.capacity() + 1, PSTR("homeassistant/sensor/ems-esp/%s/config"), uniq.c_str());
|
doc.shrinkToFit();
|
||||||
|
std::string payload_text;
|
||||||
|
serializeJson(doc, payload_text); // convert json to string
|
||||||
|
uint16_t packet_id = mqttClient_->publish(topic, 0, true, payload_text.c_str(), payload_text.size());
|
||||||
|
if (packet_id == 0) {
|
||||||
|
LOG_ERROR(F("Failed to publish topic %s"), topic);
|
||||||
|
} else {
|
||||||
|
LOG_DEBUG(F("Publishing topic %s"), topic);
|
||||||
|
}
|
||||||
|
|
||||||
Mqtt::publish_retain(topic, doc.as<JsonObject>(), true); // publish the config payload with retain flag
|
delay(MQTT_PUBLISH_WAIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace emsesp
|
} // namespace emsesp
|
||||||
|
|||||||
12
src/mqtt.h
12
src/mqtt.h
@@ -48,20 +48,18 @@ using mqtt_subfunction_p = std::function<bool(const char * message)>;
|
|||||||
using cmdfunction_p = std::function<bool(const char * data, const int8_t id)>;
|
using cmdfunction_p = std::function<bool(const char * data, const int8_t id)>;
|
||||||
|
|
||||||
struct MqttMessage {
|
struct MqttMessage {
|
||||||
~MqttMessage() = default;
|
|
||||||
|
|
||||||
const uint8_t operation;
|
const uint8_t operation;
|
||||||
const std::string topic;
|
const std::string topic;
|
||||||
const std::string payload;
|
const std::string payload;
|
||||||
const bool retain;
|
const bool retain;
|
||||||
|
|
||||||
// MqttMessage(const uint8_t operation, const std::string & topic, const std::string & payload, bool retain)
|
MqttMessage(const uint8_t operation, const std::string & topic, const std::string & payload, bool retain)
|
||||||
MqttMessage(const uint8_t operation, const std::string & topic, const std::string && payload, bool retain)
|
|
||||||
: operation(operation)
|
: operation(operation)
|
||||||
, topic(topic)
|
, topic(topic)
|
||||||
, payload(payload)
|
, payload(payload)
|
||||||
, retain(retain) {
|
, retain(retain) {
|
||||||
}
|
}
|
||||||
|
~MqttMessage() = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Mqtt {
|
class Mqtt {
|
||||||
@@ -89,17 +87,12 @@ class Mqtt {
|
|||||||
static void subscribe(const std::string & topic, mqtt_subfunction_p cb);
|
static void subscribe(const std::string & topic, mqtt_subfunction_p cb);
|
||||||
static void resubscribe();
|
static void resubscribe();
|
||||||
|
|
||||||
static void register_command(const uint8_t device_type, const uint8_t device_id, const __FlashStringHelper * cmd, cmdfunction_p cb);
|
|
||||||
|
|
||||||
static void publish(const std::string & topic, const std::string & payload);
|
static void publish(const std::string & topic, const std::string & payload);
|
||||||
static void publish(const __FlashStringHelper * topic, const char * payload);
|
static void publish(const __FlashStringHelper * topic, const char * payload);
|
||||||
static void publish(const std::string & topic, const JsonObject & payload);
|
static void publish(const std::string & topic, const JsonObject & payload);
|
||||||
static void publish(const __FlashStringHelper * topic, const JsonObject & payload);
|
static void publish(const __FlashStringHelper * topic, const JsonObject & payload);
|
||||||
static void publish(const __FlashStringHelper * topic, const std::string & payload);
|
static void publish(const __FlashStringHelper * topic, const std::string & payload);
|
||||||
static void publish(const std::string & topic, bool value);
|
|
||||||
static void publish(const __FlashStringHelper * topic, bool value);
|
|
||||||
static void publish(const std::string & topic);
|
static void publish(const std::string & topic);
|
||||||
|
|
||||||
static void publish_retain(const std::string & topic, const JsonObject & payload, bool retain);
|
static void publish_retain(const std::string & topic, const JsonObject & payload, bool retain);
|
||||||
static void publish_retain(const __FlashStringHelper * topic, const std::string & payload, bool retain);
|
static void publish_retain(const __FlashStringHelper * topic, const std::string & payload, bool retain);
|
||||||
static void publish_retain(const __FlashStringHelper * topic, const JsonObject & payload, bool retain);
|
static void publish_retain(const __FlashStringHelper * topic, const JsonObject & payload, bool retain);
|
||||||
@@ -111,6 +104,7 @@ class Mqtt {
|
|||||||
const char * entity,
|
const char * entity,
|
||||||
const __FlashStringHelper * uom,
|
const __FlashStringHelper * uom,
|
||||||
const __FlashStringHelper * icon);
|
const __FlashStringHelper * icon);
|
||||||
|
static void register_command(const uint8_t device_type, const uint8_t device_id, const __FlashStringHelper * cmd, cmdfunction_p cb);
|
||||||
|
|
||||||
static void show_topic_handlers(uuid::console::Shell & shell, const uint8_t device_type);
|
static void show_topic_handlers(uuid::console::Shell & shell, const uint8_t device_type);
|
||||||
static void show_mqtt(uuid::console::Shell & shell);
|
static void show_mqtt(uuid::console::Shell & shell);
|
||||||
|
|||||||
@@ -28,8 +28,9 @@ void Shower::start() {
|
|||||||
shower_alert_ = settings.shower_alert;
|
shower_alert_ = settings.shower_alert;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (Mqtt::mqtt_format() == Mqtt::Format::HA) {
|
if (shower_timer_ || shower_alert_) {
|
||||||
Mqtt::register_mqtt_ha_binary_sensor(F("Shower Active"), EMSdevice::DeviceType::BOILER, "shower_active");
|
char s[7];
|
||||||
|
Mqtt::publish(F("shower_active"), Helpers::render_boolean(s, false));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,8 +58,7 @@ void Shower::loop() {
|
|||||||
// first check to see if hot water has been on long enough to be recognized as a Shower/Bath
|
// first check to see if hot water has been on long enough to be recognized as a Shower/Bath
|
||||||
if (!shower_on_ && (time_now - timer_start_) > SHOWER_MIN_DURATION) {
|
if (!shower_on_ && (time_now - timer_start_) > SHOWER_MIN_DURATION) {
|
||||||
shower_on_ = true;
|
shower_on_ = true;
|
||||||
char s[7];
|
send_mqtt_stat(true);
|
||||||
Mqtt::publish("shower_active", Helpers::render_boolean(s, true));
|
|
||||||
LOG_DEBUG(F("[Shower] hot water still running, starting shower timer"));
|
LOG_DEBUG(F("[Shower] hot water still running, starting shower timer"));
|
||||||
}
|
}
|
||||||
// check if the shower has been on too long
|
// check if the shower has been on too long
|
||||||
@@ -79,8 +79,7 @@ void Shower::loop() {
|
|||||||
if ((timer_pause_ - timer_start_) > SHOWER_OFFSET_TIME) {
|
if ((timer_pause_ - timer_start_) > SHOWER_OFFSET_TIME) {
|
||||||
duration_ = (timer_pause_ - timer_start_ - SHOWER_OFFSET_TIME);
|
duration_ = (timer_pause_ - timer_start_ - SHOWER_OFFSET_TIME);
|
||||||
if (duration_ > SHOWER_MIN_DURATION) {
|
if (duration_ > SHOWER_MIN_DURATION) {
|
||||||
char s[7];
|
send_mqtt_stat(false);
|
||||||
Mqtt::publish(F("shower_active"), Helpers::render_boolean(s, false));
|
|
||||||
LOG_DEBUG(F("[Shower] finished with duration %d"), duration_);
|
LOG_DEBUG(F("[Shower] finished with duration %d"), duration_);
|
||||||
publish_values();
|
publish_values();
|
||||||
}
|
}
|
||||||
@@ -96,6 +95,17 @@ void Shower::loop() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Shower::send_mqtt_stat(bool state) {
|
||||||
|
// if we're in HA mode make sure we've first sent out the HA MQTT Discovery config topic
|
||||||
|
if ((Mqtt::mqtt_format() == Mqtt::Format::HA) && (!ha_config_)) {
|
||||||
|
Mqtt::register_mqtt_ha_binary_sensor(F("Shower Active"), EMSdevice::DeviceType::BOILER, "shower_active");
|
||||||
|
ha_config_ = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
char s[7];
|
||||||
|
Mqtt::publish(F("shower_active"), Helpers::render_boolean(s, state));
|
||||||
|
}
|
||||||
|
|
||||||
// turn back on the hot water for the shower
|
// turn back on the hot water for the shower
|
||||||
void Shower::shower_alert_stop() {
|
void Shower::shower_alert_stop() {
|
||||||
if (doing_cold_shot_) {
|
if (doing_cold_shot_) {
|
||||||
@@ -120,7 +130,8 @@ void Shower::shower_alert_start() {
|
|||||||
// Publish shower data
|
// Publish shower data
|
||||||
// returns true if added to MQTT queue went ok
|
// returns true if added to MQTT queue went ok
|
||||||
void Shower::publish_values() {
|
void Shower::publish_values() {
|
||||||
StaticJsonDocument<90> doc;
|
StaticJsonDocument<EMSESP_MAX_JSON_SIZE_SMALL> doc;
|
||||||
|
|
||||||
char s[50];
|
char s[50];
|
||||||
doc["shower_timer"] = Helpers::render_boolean(s, shower_timer_);
|
doc["shower_timer"] = Helpers::render_boolean(s, shower_timer_);
|
||||||
doc["shower_alert"] = Helpers::render_boolean(s, shower_alert_);
|
doc["shower_alert"] = Helpers::render_boolean(s, shower_alert_);
|
||||||
|
|||||||
@@ -65,10 +65,11 @@ class Shower {
|
|||||||
void publish_values();
|
void publish_values();
|
||||||
void shower_alert_start();
|
void shower_alert_start();
|
||||||
void shower_alert_stop();
|
void shower_alert_stop();
|
||||||
|
void send_mqtt_stat(bool state);
|
||||||
|
|
||||||
bool shower_timer_; // true if we want to report back on shower times
|
bool shower_timer_; // true if we want to report back on shower times
|
||||||
bool shower_alert_; // true if we want the alert of cold water
|
bool shower_alert_; // true if we want the alert of cold water
|
||||||
|
bool ha_config_ = false; // for HA MQTT Discovery
|
||||||
bool shower_on_;
|
bool shower_on_;
|
||||||
uint32_t timer_start_; // ms
|
uint32_t timer_start_; // ms
|
||||||
uint32_t timer_pause_; // ms
|
uint32_t timer_pause_; // ms
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
#define EMSESP_APP_VERSION "2.1.0b4"
|
#define EMSESP_APP_VERSION "2.1.0b5"
|
||||||
|
|||||||
Reference in New Issue
Block a user