From feed65bea6add7b40c5124e969663b78ca3f37ba Mon Sep 17 00:00:00 2001 From: proddy Date: Mon, 7 Jun 2021 21:15:46 +0200 Subject: [PATCH] don't create HA sensor for wifi rssi if only ethernet --- src/mqtt.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/mqtt.cpp b/src/mqtt.cpp index f61cfd3a4..df8687fb5 100644 --- a/src/mqtt.cpp +++ b/src/mqtt.cpp @@ -702,15 +702,17 @@ void Mqtt::ha_status() { snprintf_P(topic, sizeof(topic), PSTR("sensor/%s/system/config"), mqtt_base_.c_str()); Mqtt::publish_ha(topic, doc.as()); // publish the config payload with retain flag - // create the sensors - // must match the MQTT payload keys - publish_mqtt_ha_sensor(DeviceValueType::INT, DeviceValueTAG::TAG_HEARTBEAT, F("WiFi RSSI"), EMSdevice::DeviceType::SYSTEM, F("rssi"), DeviceValueUOM::DBM); - publish_mqtt_ha_sensor(DeviceValueType::INT, - DeviceValueTAG::TAG_HEARTBEAT, - F("WiFi strength"), - EMSdevice::DeviceType::SYSTEM, - F("wifistrength"), - DeviceValueUOM::PERCENT); + // create the sensors - must match the MQTT payload keys + if (!EMSESP::system_.ethernet_connected()) { + publish_mqtt_ha_sensor(DeviceValueType::INT, DeviceValueTAG::TAG_HEARTBEAT, F("WiFi RSSI"), EMSdevice::DeviceType::SYSTEM, F("rssi"), DeviceValueUOM::DBM); + publish_mqtt_ha_sensor(DeviceValueType::INT, + DeviceValueTAG::TAG_HEARTBEAT, + F("WiFi strength"), + EMSdevice::DeviceType::SYSTEM, + F("wifistrength"), + DeviceValueUOM::PERCENT); + } + publish_mqtt_ha_sensor(DeviceValueType::INT, DeviceValueTAG::TAG_HEARTBEAT, F("Uptime"), EMSdevice::DeviceType::SYSTEM, F("uptime")); publish_mqtt_ha_sensor(DeviceValueType::INT, DeviceValueTAG::TAG_HEARTBEAT,