mirror of
https://github.com/joBr99/nspanel-lovelace-ui.git
synced 2025-12-27 18:04:24 +01:00
fix for device_class in sensor item
This commit is contained in:
@@ -345,14 +345,19 @@ class NsPanelLovelaceUI:
|
||||
|
||||
if item_type == "sensor":
|
||||
icon_id = 0
|
||||
unit_of_measurement = ""
|
||||
icon_mapping = {
|
||||
"temperature": 2,
|
||||
"power": 4
|
||||
}
|
||||
if entity.attributes.device_class in icon_mapping:
|
||||
icon_id = icon_mapping[entity.attributes.device_class]
|
||||
if "device_class" in entity.attributes:
|
||||
if entity.attributes.device_class in icon_mapping:
|
||||
icon_id = icon_mapping[entity.attributes.device_class]
|
||||
|
||||
value = entity.state + " " + entity.attributes.unit_of_measurement
|
||||
if "unit_of_measurement" in entity.attributes:
|
||||
unit_of_measurement = entity.attributes.unit_of_measurement
|
||||
|
||||
value = entity.state + " " + unit_of_measurement
|
||||
return "entityUpd,{0},{1},{2},{3},{4},{5}".format(item_nr, "text", item, icon_id, name, value)
|
||||
|
||||
if item_type == "button" or item_type == "input_button":
|
||||
@@ -484,4 +489,4 @@ class NsPanelLovelaceUI:
|
||||
sat = r
|
||||
hsv = (math.degrees(math.atan2(y, x))%360/360, sat, 1)
|
||||
rgb = self.hsv2rgb(hsv[0],hsv[1],hsv[2])
|
||||
return rgb
|
||||
return rgb
|
||||
|
||||
Reference in New Issue
Block a user