Skip to content

Commit

Permalink
Add entity category to HA Discovery topics - emsesp#1323
Browse files Browse the repository at this point in the history
  • Loading branch information
proddy committed Oct 15, 2023
1 parent d37a5c5 commit 6769336
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/mqtt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ void Mqtt::ha_status() {
doc["obj_id"] = uniq;

doc["stat_t"] = mqtt_basename_ + "/status";
doc["name"] = "system status";
doc["name"] = "System status";
doc["pl_on"] = "online";
doc["pl_off"] = "offline";
doc["stat_cla"] = "measurement";
Expand Down Expand Up @@ -855,14 +855,11 @@ bool Mqtt::publish_ha_sensor_config(uint8_t type, // EMSdev
case DeviceValueType::UINT:
case DeviceValueType::SHORT:
case DeviceValueType::USHORT:
// case DeviceValueType::ULONG:
if (discovery_type() == discoveryType::HOMEASSISTANT) {
// Home Assistant
// number - https://www.home-assistant.io/integrations/number.mqtt
snprintf(topic, sizeof(topic), "number/%s", config_topic);
} else {
// Domoticz
// Does not support number, use sensor
// Domoticz does not support number, use sensor
snprintf(topic, sizeof(topic), "sensor/%s", config_topic);
}
break;
Expand Down Expand Up @@ -1126,9 +1123,8 @@ bool Mqtt::publish_ha_sensor_config(uint8_t type, // EMSdev
}

// add category "diagnostic" for system entities
if (device_type == EMSdevice::DeviceType::SYSTEM) {
doc["ent_cat"] = "diagnostic";
}
// config for writeable entities, like switches. diagnostic for read only sensors.
doc["ent_cat"] = (has_cmd) ? "config" : "diagnostic";

// add the dev json object to the end
doc["dev"] = dev_json;
Expand Down

0 comments on commit 6769336

Please sign in to comment.