Merge pull request #378 from MichaelDvP:dev_

check selTemp, roomTemp visibility for climate creation
This commit is contained in:
Proddy
2022-02-26 17:58:53 +01:00
committed by GitHub
3 changed files with 22 additions and 2 deletions

View File

@@ -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

View File

@@ -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) {

View File

@@ -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();