mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2026-01-26 08:39:09 +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) {
|
if (device_type == EMSdevice::DeviceType::SYSTEM) {
|
||||||
doc["ent_cat"] = "diagnostic"; // instead of 'config'
|
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
|
// 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
|
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
|
// 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
|
// 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) {
|
if (uom == DeviceValueUOM::HOURS) {
|
||||||
doc[uom_ha] = "h";
|
doc[uom_ha] = "h";
|
||||||
} else if (uom == DeviceValueUOM::MINUTES) {
|
} 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) {
|
} else if (discovery_type() != discoveryType::HOMEASSISTANT) {
|
||||||
doc[uom_ha] = " "; // Domoticz uses " " for a no-uom
|
doc[uom_ha] = " "; // Domoticz uses " " for a no-uom
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// set state and device class - always
|
// set state and device class - always
|
||||||
// see https://developers.home-assistant.io/docs/core/entity/sensor/#available-device-classes
|
// 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::NONE:
|
||||||
// DeviceValueUOM::KMIN:
|
// DeviceValueUOM::KMIN:
|
||||||
// for device entities which have numerical values, with no UOM
|
// for device entities which have numerical values, with no UOM
|
||||||
if ((type != DeviceValueType::STRING)
|
if (type == DeviceValueType::INT8 || type == DeviceValueType::UINT8 || type == DeviceValueType::INT16 || type == DeviceValueType::UINT16
|
||||||
&& (type == DeviceValueType::INT8 || type == DeviceValueType::UINT8 || type == DeviceValueType::INT16 || type == DeviceValueType::UINT16
|
|| type == DeviceValueType::UINT24 || type == DeviceValueType::UINT32) {
|
||||||
|| type == DeviceValueType::UINT24 || type == DeviceValueType::UINT32)) {
|
|
||||||
if (display_only) {
|
if (display_only) {
|
||||||
doc[ic_ha] = F_(iconnum); // set icon
|
doc[ic_ha] = F_(iconnum); // set icon
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user