@@ -1689,23 +1689,26 @@ void EMSdevice::mqtt_ha_entity_config_create() {
1689
1689
for (auto & dv : devicevalues_) {
1690
1690
if (!strcmp (dv.short_name , FL_ (haclimate)[0 ]) && !dv.has_state (DeviceValueState::DV_API_MQTT_EXCLUDE) && dv.has_state (DeviceValueState::DV_ACTIVE)) {
1691
1691
if (*(int8_t *)(dv.value_p ) == 1 && (!dv.has_state (DeviceValueState::DV_HA_CONFIG_CREATED) || dv.has_state (DeviceValueState::DV_HA_CLIMATE_NO_RT))) {
1692
- dv.remove_state (DeviceValueState::DV_HA_CLIMATE_NO_RT);
1693
- dv.add_state (DeviceValueState::DV_HA_CONFIG_CREATED);
1694
- Mqtt::publish_ha_climate_config (dv.tag , true , false , dv.min , dv.max ); // roomTemp
1692
+ if (Mqtt::publish_ha_climate_config (dv.tag , true , false , dv.min , dv.max )) { // roomTemp
1693
+ dv.remove_state (DeviceValueState::DV_HA_CLIMATE_NO_RT);
1694
+ dv.add_state (DeviceValueState::DV_HA_CONFIG_CREATED);
1695
+ }
1695
1696
} else if (*(int8_t *)(dv.value_p ) == 0
1696
1697
&& (!dv.has_state (DeviceValueState::DV_HA_CONFIG_CREATED) || !dv.has_state (DeviceValueState::DV_HA_CLIMATE_NO_RT))) {
1697
- dv.add_state (DeviceValueState::DV_HA_CLIMATE_NO_RT);
1698
- dv.add_state (DeviceValueState::DV_HA_CONFIG_CREATED);
1699
- Mqtt::publish_ha_climate_config (dv.tag , false , false , dv.min , dv.max ); // no roomTemp
1698
+ if (Mqtt::publish_ha_climate_config (dv.tag , false , false , dv.min , dv.max )) { // no roomTemp
1699
+ dv.add_state (DeviceValueState::DV_HA_CLIMATE_NO_RT);
1700
+ dv.add_state (DeviceValueState::DV_HA_CONFIG_CREATED);
1701
+ }
1700
1702
}
1701
1703
}
1702
1704
1703
1705
if (!dv.has_state (DeviceValueState::DV_HA_CONFIG_CREATED) && (dv.type != DeviceValueType::CMD) && dv.has_state (DeviceValueState::DV_ACTIVE)
1704
1706
&& !dv.has_state (DeviceValueState::DV_API_MQTT_EXCLUDE)) {
1705
1707
// create_device_config is only done once for the EMS device. It can added to any entity, so we take the first
1706
- Mqtt::publish_ha_sensor_config (dv, name (), brand_to_char (), false , create_device_config);
1707
- dv.add_state (DeviceValueState::DV_HA_CONFIG_CREATED);
1708
- create_device_config = false ; // only create the main config once
1708
+ if (Mqtt::publish_ha_sensor_config (dv, name (), brand_to_char (), false , create_device_config)) {
1709
+ dv.add_state (DeviceValueState::DV_HA_CONFIG_CREATED);
1710
+ create_device_config = false ; // only create the main config once
1711
+ }
1709
1712
#ifndef EMSESP_STANDALONE
1710
1713
// always create minimum one config
1711
1714
if (ESP.getMaxAllocHeap () < (6 * 1024 ) || (!emsesp::EMSESP::system_.PSram () && ESP.getFreeHeap () < (65 * 1024 ))) {
0 commit comments