formatting changes

This commit is contained in:
proddy
2020-10-11 17:09:26 +02:00
parent d74ebf8838
commit eaddae15a1
5 changed files with 19 additions and 25 deletions

View File

@@ -272,10 +272,10 @@ void EMSESPShell::add_console_commands() {
uint16_t type_id = Helpers::hextoint(arguments[1].c_str()); uint16_t type_id = Helpers::hextoint(arguments[1].c_str());
EMSESP::set_read_id(type_id); EMSESP::set_read_id(type_id);
if (arguments.size() == 3) { if (arguments.size() == 3) {
uint16_t offset = Helpers::hextoint(arguments.back().c_str()); uint16_t offset = Helpers::hextoint(arguments.back().c_str());
EMSESP::send_read_request(type_id, device_id, offset); EMSESP::send_read_request(type_id, device_id, offset);
} else { } else {
EMSESP::send_read_request(type_id, device_id); EMSESP::send_read_request(type_id, device_id);
} }
}); });

View File

@@ -109,7 +109,6 @@ void Boiler::register_mqtt_ha_config() {
Mqtt::register_mqtt_ha_sensor(nullptr, F_(wWSetTemp), this->device_type(), "wWSetTemp", F_(degrees), F_(icontemperature)); Mqtt::register_mqtt_ha_sensor(nullptr, F_(wWSetTemp), this->device_type(), "wWSetTemp", F_(degrees), F_(icontemperature));
Mqtt::register_mqtt_ha_sensor(nullptr, F_(wWDisinfectionTemp), this->device_type(), "wWDisinfectionTemp", F_(degrees), F_(icontemperature)); Mqtt::register_mqtt_ha_sensor(nullptr, F_(wWDisinfectionTemp), this->device_type(), "wWDisinfectionTemp", F_(degrees), F_(icontemperature));
Mqtt::register_mqtt_ha_sensor(nullptr, F_(selFlowTemp), this->device_type(), "selFlowTemp", F_(degrees), F_(icontemperature)); Mqtt::register_mqtt_ha_sensor(nullptr, F_(selFlowTemp), this->device_type(), "selFlowTemp", F_(degrees), F_(icontemperature));
Mqtt::register_mqtt_ha_sensor(nullptr, F_(selBurnPow), this->device_type(), "selBurnPow", F_(percent), nullptr); Mqtt::register_mqtt_ha_sensor(nullptr, F_(selBurnPow), this->device_type(), "selBurnPow", F_(percent), nullptr);
Mqtt::register_mqtt_ha_sensor(nullptr, F_(curBurnPow), this->device_type(), "curBurnPow", F_(percent), F_(iconpercent)); Mqtt::register_mqtt_ha_sensor(nullptr, F_(curBurnPow), this->device_type(), "curBurnPow", F_(percent), F_(iconpercent));
Mqtt::register_mqtt_ha_sensor(nullptr, F_(pumpMod), this->device_type(), "pumpMod", F_(percent), F_(iconpercent)); Mqtt::register_mqtt_ha_sensor(nullptr, F_(pumpMod), this->device_type(), "pumpMod", F_(percent), F_(iconpercent));
@@ -119,7 +118,6 @@ void Boiler::register_mqtt_ha_config() {
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_(wWCircPumpMode), this->device_type(), "wWCircPumpMode", 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);
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_(wWCurTemp), this->device_type(), "wWCurTemp", 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_(wWCurTemp2), this->device_type(), "wWCurTemp2", F_(degrees), F_(icontemperature)); Mqtt::register_mqtt_ha_sensor(nullptr, F_(wWCurTemp2), this->device_type(), "wWCurTemp2", F_(degrees), F_(icontemperature));
@@ -129,26 +127,22 @@ void Boiler::register_mqtt_ha_config() {
Mqtt::register_mqtt_ha_sensor(nullptr, F_(switchTemp), this->device_type(), "switchTemp", F_(degrees), F_(icontemperature)); Mqtt::register_mqtt_ha_sensor(nullptr, F_(switchTemp), this->device_type(), "switchTemp", F_(degrees), F_(icontemperature));
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(nullptr, 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(nullptr, 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(nullptr, 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(nullptr, 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(nullptr, 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(nullptr, 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(nullptr, 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(nullptr, 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(nullptr, 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(nullptr, 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(nullptr, 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(nullptr, 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(nullptr, F_(wWCharging), this->device_type(), "wWCharging", nullptr, nullptr); Mqtt::register_mqtt_ha_sensor(nullptr, F_(wWCharging), this->device_type(), "wWCharging", nullptr, nullptr);
Mqtt::register_mqtt_ha_sensor(nullptr, F_(wWRecharging), this->device_type(), "wWRecharging", nullptr, nullptr); Mqtt::register_mqtt_ha_sensor(nullptr, F_(wWRecharging), this->device_type(), "wWRecharging", nullptr, nullptr);
Mqtt::register_mqtt_ha_sensor(nullptr, 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(nullptr, 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(nullptr, 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(nullptr, 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(nullptr, 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));
@@ -595,10 +589,11 @@ bool Boiler::export_values(JsonObject & output) {
// publish values via MQTT // publish values via MQTT
void Boiler::publish_values(JsonObject & data) { void Boiler::publish_values(JsonObject & data) {
// must make sure this doesn't exist 1000. Currently (2.1.0) its 950b. // Warning: must make sure the json size doesn't exceed 1024 bytes (it's currently 950b with 2.1.0b6)
// otheerwise use DynamicJsonDocument with max size and use .shrinkToFit() // otherwise use should switch to using DynamicJsonDocument with max size followed by a shrinkToFit()
StaticJsonDocument<1024> doc; 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 // see if we need to send out HA MQTT Discovery topics
if ((Mqtt::mqtt_format() == Mqtt::Format::HA) && (!mqtt_ha_config_)) { if ((Mqtt::mqtt_format() == Mqtt::Format::HA) && (!mqtt_ha_config_)) {

View File

@@ -162,7 +162,6 @@ void Mixing::publish_values(JsonObject & data) {
// publish config topic for HA MQTT Discovery // publish config topic for HA MQTT Discovery
void Mixing::register_mqtt_ha_config(const char * topic) { void Mixing::register_mqtt_ha_config(const char * topic) {
// Create the Master device
StaticJsonDocument<EMSESP_MAX_JSON_SIZE_MEDIUM> doc; StaticJsonDocument<EMSESP_MAX_JSON_SIZE_MEDIUM> doc;
doc["name"] = F("EMS-ESP"); doc["name"] = F("EMS-ESP");
doc["uniq_id"] = F("mixing"); doc["uniq_id"] = F("mixing");
@@ -172,7 +171,7 @@ void Mixing::register_mqtt_ha_config(const char * topic) {
snprintf_P(stat_t, sizeof(stat_t), PSTR("%s/%s"), System::hostname().c_str(), topic); snprintf_P(stat_t, sizeof(stat_t), PSTR("%s/%s"), System::hostname().c_str(), topic);
doc["stat_t"] = stat_t; doc["stat_t"] = stat_t;
doc["val_tpl"] = F("{{value_json.pumpStatus}}"); doc["val_tpl"] = F("{{value_json.type}}"); // HA needs a single value. We take the type which is wwc or hc
JsonObject dev = doc.createNestedObject("dev"); JsonObject dev = doc.createNestedObject("dev");
dev["name"] = F("EMS-ESP Mixing"); dev["name"] = F("EMS-ESP Mixing");
dev["sw"] = EMSESP_APP_VERSION; dev["sw"] = EMSESP_APP_VERSION;
@@ -215,7 +214,7 @@ bool Mixing::export_values(uint8_t mqtt_format, JsonObject & output) {
output_hc = output.createNestedObject(hc_name); output_hc = output.createNestedObject(hc_name);
} else { } else {
output_hc = output; output_hc = output;
output["type"] = "hc"; output["type"] = F("hc");
} }
if (Helpers::hasValue(flowTemp_)) { if (Helpers::hasValue(flowTemp_)) {
output_hc["flowTemp"] = (float)flowTemp_ / 10; output_hc["flowTemp"] = (float)flowTemp_ / 10;
@@ -224,7 +223,7 @@ bool Mixing::export_values(uint8_t mqtt_format, JsonObject & output) {
output_hc["flowSetTemp"] = flowSetTemp_; output_hc["flowSetTemp"] = flowSetTemp_;
} }
if (Helpers::hasValue(pumpStatus_)) { if (Helpers::hasValue(pumpStatus_)) {
char s[5]; // for formatting strings char s[5];
output_hc["pumpStatus"] = Helpers::render_value(s, pumpStatus_, EMS_VALUE_BOOL); output_hc["pumpStatus"] = Helpers::render_value(s, pumpStatus_, EMS_VALUE_BOOL);
} }
if (Helpers::hasValue(status_)) { if (Helpers::hasValue(status_)) {
@@ -236,13 +235,13 @@ bool Mixing::export_values(uint8_t mqtt_format, JsonObject & output) {
output_hc = output.createNestedObject(hc_name); output_hc = output.createNestedObject(hc_name);
} else { } else {
output_hc = output; output_hc = output;
output["type"] = "wwc"; output["type"] = F("wwc");
} }
if (Helpers::hasValue(flowTemp_)) { if (Helpers::hasValue(flowTemp_)) {
output_hc["wwTemp"] = (float)flowTemp_ / 10; output_hc["wwTemp"] = (float)flowTemp_ / 10;
} }
if (Helpers::hasValue(pumpStatus_)) { if (Helpers::hasValue(pumpStatus_)) {
char s[5]; // for formatting strings char s[5];
output_hc["pumpStatus"] = Helpers::render_value(s, pumpStatus_, EMS_VALUE_BOOL); output_hc["pumpStatus"] = Helpers::render_value(s, pumpStatus_, EMS_VALUE_BOOL);
} }
if (Helpers::hasValue(status_)) { if (Helpers::hasValue(status_)) {

View File

@@ -1243,11 +1243,11 @@ void Thermostat::process_RC35Set(std::shared_ptr<const Telegram> telegram) {
changed_ |= telegram->read_value(hc->summertemp, 22); // is * 1 changed_ |= telegram->read_value(hc->summertemp, 22); // is * 1
changed_ |= telegram->read_value(hc->nofrosttemp, 23); // is * 1 changed_ |= telegram->read_value(hc->nofrosttemp, 23); // is * 1
if (hc->heatingtype == 3) { if (hc->heatingtype == 3) {
changed_ |= telegram->read_value(hc->designtemp, 36); // is * 1 changed_ |= telegram->read_value(hc->designtemp, 36); // is * 1
} else { } else {
changed_ |= telegram->read_value(hc->designtemp, 17); // is * 1 changed_ |= telegram->read_value(hc->designtemp, 17); // is * 1
} }
changed_ |= telegram->read_value(hc->offsettemp, 6); // is * 2 changed_ |= telegram->read_value(hc->offsettemp, 6); // is * 2
changed_ |= telegram->read_value(hc->roominfluence, 4); // is * 1 changed_ |= telegram->read_value(hc->roominfluence, 4); // is * 1
} }

View File

@@ -772,9 +772,9 @@ void Mqtt::register_mqtt_ha_sensor(const char * prefix,
char stat_t[50]; char stat_t[50];
snprintf_P(stat_t, sizeof(stat_t), PSTR("%s/%s_data"), hostname_.c_str(), device_name.c_str()); snprintf_P(stat_t, sizeof(stat_t), PSTR("%s/%s_data"), hostname_.c_str(), device_name.c_str());
// state template // value template
char tpl[50]; char val_tpl[50];
snprintf_P(tpl, sizeof(tpl), PSTR("{{value_json.%s}}"), new_entity); snprintf_P(val_tpl, sizeof(val_tpl), PSTR("{{value_json.%s}}"), new_entity);
// ha device // ha device
char ha_device[40]; char ha_device[40];
@@ -787,7 +787,7 @@ void Mqtt::register_mqtt_ha_sensor(const char * prefix,
doc["unit_of_meas"] = uom; doc["unit_of_meas"] = uom;
} }
doc["stat_t"] = stat_t; doc["stat_t"] = stat_t;
doc["val_tpl"] = tpl; doc["val_tpl"] = val_tpl;
if (icon != nullptr) { if (icon != nullptr) {
doc["ic"] = icon; doc["ic"] = icon;
} }