@@ -160,7 +160,7 @@ void Mqtt::resubscribe() {
160
160
161
161
// Main MQTT loop - sends out top item on publish queue
162
162
void Mqtt::loop () {
163
- // exit if MQTT is not enabled or if there is no WIFI
163
+ // exit if MQTT is not enabled or if there is no network connection
164
164
if (!connected ()) {
165
165
return ;
166
166
}
@@ -589,7 +589,7 @@ bool Mqtt::get_publish_onchange(uint8_t device_type) {
589
589
// MQTT onConnect - when an MQTT connect is established
590
590
// send out some inital MQTT messages
591
591
void Mqtt::on_connect () {
592
- if (connecting_) { // prevent duplicating connections
592
+ if (connecting_) { // prevent duplicated connections
593
593
return ;
594
594
}
595
595
@@ -611,7 +611,11 @@ void Mqtt::on_connect() {
611
611
612
612
doc[" version" ] = EMSESP_APP_VERSION;
613
613
#ifndef EMSESP_STANDALONE
614
- doc[" ip" ] = WiFi.localIP ().toString ();
614
+ if (ETH.linkUp ()) {
615
+ doc[" ip" ] = ETH.localIP ().toString ();
616
+ } else {
617
+ doc[" ip" ] = WiFi.localIP ().toString ();
618
+ }
615
619
#endif
616
620
publish (F_ (info), doc.as <JsonObject>());
617
621
@@ -672,7 +676,7 @@ void Mqtt::ha_status() {
672
676
Mqtt::publish_ha (topic, doc.as <JsonObject>()); // publish the config payload with retain flag
673
677
674
678
// create the sensors
675
- publish_mqtt_ha_sensor (DeviceValueType::INT, DeviceValueTAG::TAG_HEARTBEAT, F (" Wifi strength" ), EMSdevice::DeviceType::SYSTEM, F (" rssi" ));
679
+ publish_mqtt_ha_sensor (DeviceValueType::INT, DeviceValueTAG::TAG_HEARTBEAT, F (" WiFi strength" ), EMSdevice::DeviceType::SYSTEM, F (" rssi" ));
676
680
publish_mqtt_ha_sensor (DeviceValueType::INT, DeviceValueTAG::TAG_HEARTBEAT, F (" Uptime" ), EMSdevice::DeviceType::SYSTEM, F (" uptime" ));
677
681
publish_mqtt_ha_sensor (DeviceValueType::INT, DeviceValueTAG::TAG_HEARTBEAT, F (" Uptime (sec)" ), EMSdevice::DeviceType::SYSTEM, F (" uptime_sec" ));
678
682
publish_mqtt_ha_sensor (DeviceValueType::INT, DeviceValueTAG::TAG_HEARTBEAT, F (" Free heap memory" ), EMSdevice::DeviceType::SYSTEM, F (" freemem" ));
0 commit comments