From cd564f0c5429ba3a2e8cd5cab5008a593ea3d688 Mon Sep 17 00:00:00 2001 From: Proddy Date: Sat, 4 Nov 2023 11:46:42 +0100 Subject: [PATCH] no commands for nrgheat & nrgww - #1382 --- src/mqtt.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/mqtt.cpp b/src/mqtt.cpp index dc5b3f133..1cb53908a 100644 --- a/src/mqtt.cpp +++ b/src/mqtt.cpp @@ -753,7 +753,8 @@ bool Mqtt::publish_ha_sensor_config(DeviceValue & dv, const char * model, const // determine if we're creating the command topics which we use special HA configs // unless the entity has been marked as read-only and so it'll default to using the sensor/ type - bool has_cmd = dv.has_cmd && !dv.has_state(DeviceValueState::DV_READONLY); + // or we're dealing with Energy sensors that must have "diagnostic" as an entity category (e.g. negheat & nrgww) + bool has_cmd = dv.has_cmd && !dv.has_state(DeviceValueState::DV_READONLY) && (dv.uom != DeviceValueUOM::KWH); return publish_ha_sensor_config(dv.type, dv.tag, @@ -1080,11 +1081,11 @@ bool Mqtt::publish_ha_sensor_config(uint8_t type, // EMSdev } else { doc[sc_ha] = F_(measurement); } - doc[dc_ha] = "energy"; // no icon needed + doc[dc_ha] = "energy"; break; case DeviceValueUOM::KWH: doc[sc_ha] = F_(total_increasing); - doc[dc_ha] = "energy"; // no icon needed + doc[dc_ha] = "energy"; break; case DeviceValueUOM::UA: doc[ic_ha] = F_(iconua); @@ -1128,8 +1129,9 @@ bool Mqtt::publish_ha_sensor_config(uint8_t type, // EMSdev } } - // add category "diagnostic" for system entities - // config for writeable entities, like switches. diagnostic for read only sensors. + // add category + // "config" for writeable entities, like switch, number, text, select + // "diagnostic" for read only sensors doc["ent_cat"] = (has_cmd) ? "config" : "diagnostic"; // add the dev json object to the end