Skip to content

Commit 6769336

Browse files
committed
Add entity category to HA Discovery topics - #1323
1 parent d37a5c5 commit 6769336

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/mqtt.cpp

+4-8
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ void Mqtt::ha_status() {
532532
doc["obj_id"] = uniq;
533533

534534
doc["stat_t"] = mqtt_basename_ + "/status";
535-
doc["name"] = "system status";
535+
doc["name"] = "System status";
536536
doc["pl_on"] = "online";
537537
doc["pl_off"] = "offline";
538538
doc["stat_cla"] = "measurement";
@@ -855,14 +855,11 @@ bool Mqtt::publish_ha_sensor_config(uint8_t type, // EMSdev
855855
case DeviceValueType::UINT:
856856
case DeviceValueType::SHORT:
857857
case DeviceValueType::USHORT:
858-
// case DeviceValueType::ULONG:
859858
if (discovery_type() == discoveryType::HOMEASSISTANT) {
860-
// Home Assistant
861859
// number - https://www.home-assistant.io/integrations/number.mqtt
862860
snprintf(topic, sizeof(topic), "number/%s", config_topic);
863861
} else {
864-
// Domoticz
865-
// Does not support number, use sensor
862+
// Domoticz does not support number, use sensor
866863
snprintf(topic, sizeof(topic), "sensor/%s", config_topic);
867864
}
868865
break;
@@ -1126,9 +1123,8 @@ bool Mqtt::publish_ha_sensor_config(uint8_t type, // EMSdev
11261123
}
11271124

11281125
// add category "diagnostic" for system entities
1129-
if (device_type == EMSdevice::DeviceType::SYSTEM) {
1130-
doc["ent_cat"] = "diagnostic";
1131-
}
1126+
// config for writeable entities, like switches. diagnostic for read only sensors.
1127+
doc["ent_cat"] = (has_cmd) ? "config" : "diagnostic";
11321128

11331129
// add the dev json object to the end
11341130
doc["dev"] = dev_json;

0 commit comments

Comments
 (0)