mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 08:19:52 +03:00
check selTemp, roomTemp visibility for climate creation
This commit is contained in:
@@ -375,7 +375,16 @@ void Thermostat::add_ha_climate(std::shared_ptr<HeatingCircuit> 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
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user