updated comments, remove DV_HA_CONFIG_RECREATE

This commit is contained in:
Proddy
2023-02-22 19:45:56 +01:00
parent 11ad4d8a0f
commit 6746c9a2d3
3 changed files with 14 additions and 13 deletions

View File

@@ -1676,7 +1676,7 @@ void EMSdevice::mqtt_ha_entity_config_remove() {
if (dv.has_state(DeviceValueState::DV_HA_CONFIG_CREATED)
&& ((dv.has_state(DeviceValueState::DV_API_MQTT_EXCLUDE)) || (!dv.has_state(DeviceValueState::DV_ACTIVE)))) {
dv.remove_state(DeviceValueState::DV_HA_CONFIG_CREATED);
dv.remove_state(DeviceValueState::DV_HA_CONFIG_RECREATE);
// dv.remove_state(DeviceValueState::DV_HA_CONFIG_RECREATE); // TODO remove
if (dv.short_name == FL_(climate)[0]) {
Mqtt::publish_ha_climate_config(dv.tag, false, true); // delete topic (remove = true)
@@ -1696,10 +1696,11 @@ void EMSdevice::mqtt_ha_entity_config_create() {
// create climate if roomtemp is visible
// create the discovery topic if if hasn't already been created, not a command (like reset) and is active and visible
for (auto & dv : devicevalues_) {
if (dv.has_state(DeviceValueState::DV_HA_CONFIG_RECREATE)) {
dv.remove_state(DeviceValueState::DV_HA_CONFIG_CREATED);
dv.remove_state(DeviceValueState::DV_HA_CONFIG_RECREATE);
}
// TODO removed
// if (dv.has_state(DeviceValueState::DV_HA_CONFIG_RECREATE)) {
// dv.remove_state(DeviceValueState::DV_HA_CONFIG_CREATED);
// dv.remove_state(DeviceValueState::DV_HA_CONFIG_RECREATE);
// }
if ((dv.short_name == FL_(climate)[0]) && !dv.has_state(DeviceValueState::DV_API_MQTT_EXCLUDE) && dv.has_state(DeviceValueState::DV_ACTIVE)) {
if (*(int8_t *)(dv.value_p) == 1 && (!dv.has_state(DeviceValueState::DV_HA_CONFIG_CREATED) || dv.has_state(DeviceValueState::DV_HA_CLIMATE_NO_RT))) {
@@ -1729,7 +1730,7 @@ void EMSdevice::mqtt_ha_entity_config_create() {
// remove all config topics in HA
void EMSdevice::ha_config_clear() {
for (auto & dv : devicevalues_) {
dv.add_state(DeviceValueState::DV_HA_CONFIG_RECREATE);
// dv.add_state(DeviceValueState::DV_HA_CONFIG_RECREATE); // TODO removed
if (ha_config_firstrun()) {
dv.add_state(DeviceValueState::DV_HA_CONFIG_CREATED); // make sure it is removed if not active
}

View File

@@ -124,7 +124,7 @@ class DeviceValue {
DV_ACTIVE = (1 << 0), // 1 - has a validated real value
DV_HA_CONFIG_CREATED = (1 << 1), // 2 - set if the HA config topic has been created
DV_HA_CLIMATE_NO_RT = (1 << 2), // 4 - climate created without roomTemp
DV_HA_CONFIG_RECREATE = (1 << 3), // 8 - set on reconnect to recreate HA config topic
DV_HA_CONFIG_RECREATE = (1 << 3), // 8 - set on reconnect to recreate HA config topic // TODO remove
// high nibble as mask for exclusions & special functions
DV_WEB_EXCLUDE = (1 << 4), // 16 - not shown on web

View File

@@ -667,7 +667,6 @@ void Mqtt::ha_status() {
}
// add sub or pub task to the queue.
// returns a pointer to the message created
// the base is not included in the topic
void Mqtt::queue_message(const uint8_t operation, const std::string & topic, const std::string & payload, bool retain) {
if (topic.empty()) {
@@ -690,12 +689,15 @@ void Mqtt::queue_message(const uint8_t operation, const std::string & topic, con
#ifndef EMSESP_STANDALONE
// TODO to look at with @MichaelDvP ...
// TODO also reduce the time to process the queue so it empties quicker? I changed MQTT_PUBLISH_WAIT from 100 to 75
// TODO or call process_queue() to process the front of queue immediately?
// TODO because it takes 10 seconds (default publish interval) before the queue gets published
// TODO and does returning with mqtt_messages_.pop_front() have any negative side affects?
// anything below 65MB available free heap is dangerously low
if (ESP.getFreeHeap() < (65 * 1024)) {
// mqtt_messages_.pop_front();
LOG_WARNING("Queue overflow");
LOG_WARNING("Queue overflow (size %d)", mqtt_messages_.size());
mqtt_publish_fails_++;
return; // TODO - don't add top queue. Check will this have negative side affects?
return; // don't add to top of queue
}
#endif
@@ -818,9 +820,7 @@ void Mqtt::process_queue() {
// if this has already been published and we're waiting for an ACK, don't publish again
// it will have a real packet ID
if (mqtt_message.packet_id_ > 0) {
#if defined(EMSESP_DEBUG)
LOG_DEBUG("Waiting for QOS-ACK");
#endif
// if we don't get the ack within 10 minutes, republish with new packet_id
if (uuid::get_uptime_sec() - last_publish_queue_ < 600) {
return;