From cde761fadd6280707663c09a82e0a3fcbc9adc56 Mon Sep 17 00:00:00 2001 From: MichaelDvP Date: Sat, 26 Feb 2022 17:15:42 +0100 Subject: [PATCH] check selTemp, roomTemp visibility for climate creation --- src/devices/thermostat.cpp | 11 ++++++++++- src/emsdevice.cpp | 10 ++++++++++ src/emsdevice.h | 3 ++- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/devices/thermostat.cpp b/src/devices/thermostat.cpp index 3d4ea2eb2..e426728e1 100644 --- a/src/devices/thermostat.cpp +++ b/src/devices/thermostat.cpp @@ -375,7 +375,16 @@ void Thermostat::add_ha_climate(std::shared_ptr hc) { hc->climate = EMS_VALUE_UINT_NOTSET; return; } - hc->climate = Helpers::hasValue(hc->roomTemp) ? 1 : Helpers::hasValue(hc->selTemp) ? 0 : EMS_VALUE_UINT_NOTSET; + + if (Helpers::hasValue(hc->selTemp) && is_visible(&hc->selTemp)) { + if (Helpers::hasValue(hc->roomTemp) && is_visible(&hc->roomTemp)) { + hc->climate = 1; + } else { + hc->climate = 0; + } + } else { + hc->climate = EMS_VALUE_UINT_NOTSET; + } } // decodes the thermostat mode for the heating circuit based on the thermostat type diff --git a/src/emsdevice.cpp b/src/emsdevice.cpp index 9d3183772..ab411413a 100644 --- a/src/emsdevice.cpp +++ b/src/emsdevice.cpp @@ -524,6 +524,16 @@ void EMSdevice::register_device_value(uint8_t tag, register_device_value(tag, value_p, type, options, name, uom, nullptr, 0, 0); } +// check if value is visiible +bool EMSdevice::is_visible(void * value_p) { + for (auto & dv : devicevalues_) { + if (dv.value_p == value_p && dv.has_state(DeviceValueState::DV_VISIBLE)) { + return true; + } + } + return false; +} + // publish a single value on change void EMSdevice::publish_value(void * value_p) { if (!Mqtt::publish_single() || value_p == nullptr) { diff --git a/src/emsdevice.h b/src/emsdevice.h index 721cf3010..8487e056a 100644 --- a/src/emsdevice.h +++ b/src/emsdevice.h @@ -242,7 +242,8 @@ class EMSdevice { void read_command(const uint16_t type_id, uint8_t offset = 0, uint8_t length = 0); - void publish_value(void * value); + bool is_visible(void * value_p); + void publish_value(void * value_p); void publish_all_values(); void mqtt_ha_entity_config_create();