Skip to content

Commit

Permalink
MQTT Hass: Move yield into the publish method
Browse files Browse the repository at this point in the history
  • Loading branch information
tbnobody committed Sep 24, 2024
1 parent 239a771 commit ac5a960
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions src/MqttHandleHass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ void MqttHandleHassClass::publishConfig()

publishDtuBinarySensor("Status", config.Mqtt.Lwt.Topic, config.Mqtt.Lwt.Value_Online, config.Mqtt.Lwt.Value_Offline, "connectivity", "diagnostic");

yield();

// Loop all inverters
for (uint8_t i = 0; i < Hoymiles.getNumInverters(); i++) {
auto inv = Hoymiles.getInverterByPos(i);
Expand All @@ -89,17 +87,13 @@ void MqttHandleHassClass::publishConfig()
publishInverterBinarySensor(inv, "Reachable", "status/reachable", "1", "0");
publishInverterBinarySensor(inv, "Producing", "status/producing", "1", "0");

yield();

publishInverterSensor(inv, "TX Requests", "radio/tx_request", "", "", "", "diagnostic");
publishInverterSensor(inv, "RX Success", "radio/rx_success", "", "", "", "diagnostic");
publishInverterSensor(inv, "RX Fail Receive Nothing", "radio/rx_fail_nothing", "", "", "", "diagnostic");
publishInverterSensor(inv, "RX Fail Receive Partial", "radio/rx_fail_partial", "", "", "", "diagnostic");
publishInverterSensor(inv, "RX Fail Receive Corrupt", "radio/rx_fail_corrupt", "", "", "", "diagnostic");
publishInverterSensor(inv, "TX Re-Request Fragment", "radio/tx_re_request", "", "", "", "diagnostic");

yield();

// Loop all channels
for (auto& t : inv->Statistics()->getChannelTypes()) {
for (auto& c : inv->Statistics()->getChannelsByType(t)) {
Expand All @@ -112,8 +106,6 @@ void MqttHandleHassClass::publishConfig()
}
}
}

yield();
}
}

Expand Down Expand Up @@ -335,6 +327,7 @@ void MqttHandleHassClass::publish(const String& subtopic, const String& payload)
String topic = Configuration.get().Mqtt.Hass.Topic;
topic += subtopic;
MqttSettings.publishGeneric(topic, payload, Configuration.get().Mqtt.Hass.Retain);
yield();
}

void MqttHandleHassClass::publishBinarySensor(JsonDocument& doc, const String& root_device, const String& unique_id_prefix, const String& name, const String& state_topic, const String& payload_on, const String& payload_off, const String& device_class, const String& category)
Expand Down

0 comments on commit ac5a960

Please sign in to comment.