mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2026-01-26 16:49:11 +03:00
Compare commits
2 Commits
48f7b48216
...
b4036bf8cd
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b4036bf8cd | ||
|
|
4b457d6cdb |
@@ -1132,6 +1132,9 @@ void Mqtt::add_ha_classes(JsonObject doc, const uint8_t device_type, const uint8
|
||||
if (device_type == EMSdevice::DeviceType::SYSTEM) {
|
||||
doc["ent_cat"] = "diagnostic"; // instead of 'config'
|
||||
}
|
||||
if (type == DeviceValueType::BOOL) {
|
||||
return;
|
||||
}
|
||||
|
||||
// For display_only, we don't use the aliases, also we don't display the icon
|
||||
const char * dc_ha = display_only ? "device_class" : "dev_cla"; // device class, dev_cla
|
||||
@@ -1146,7 +1149,6 @@ void Mqtt::add_ha_classes(JsonObject doc, const uint8_t device_type, const uint8
|
||||
|
||||
// set uom, unless boolean - as HA is fussy with the naming and is case sensitive
|
||||
// map too HA uom specific codes from https://github.com/home-assistant/core/blob/dev/homeassistant/const.py
|
||||
if (type != DeviceValueType::BOOL) {
|
||||
if (uom == DeviceValueUOM::HOURS) {
|
||||
doc[uom_ha] = "h";
|
||||
} else if (uom == DeviceValueUOM::MINUTES) {
|
||||
@@ -1164,7 +1166,6 @@ void Mqtt::add_ha_classes(JsonObject doc, const uint8_t device_type, const uint8
|
||||
} else if (discovery_type() != discoveryType::HOMEASSISTANT) {
|
||||
doc[uom_ha] = " "; // Domoticz uses " " for a no-uom
|
||||
}
|
||||
}
|
||||
|
||||
// set state and device class - always
|
||||
// see https://developers.home-assistant.io/docs/core/entity/sensor/#available-device-classes
|
||||
@@ -1280,9 +1281,8 @@ void Mqtt::add_ha_classes(JsonObject doc, const uint8_t device_type, const uint8
|
||||
// DeviceValueUOM::NONE:
|
||||
// DeviceValueUOM::KMIN:
|
||||
// for device entities which have numerical values, with no UOM
|
||||
if ((type != DeviceValueType::STRING)
|
||||
&& (type == DeviceValueType::INT8 || type == DeviceValueType::UINT8 || type == DeviceValueType::INT16 || type == DeviceValueType::UINT16
|
||||
|| type == DeviceValueType::UINT24 || type == DeviceValueType::UINT32)) {
|
||||
if (type == DeviceValueType::INT8 || type == DeviceValueType::UINT8 || type == DeviceValueType::INT16 || type == DeviceValueType::UINT16
|
||||
|| type == DeviceValueType::UINT24 || type == DeviceValueType::UINT32) {
|
||||
if (display_only) {
|
||||
doc[ic_ha] = F_(iconnum); // set icon
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user