mirror of
https://github.com/joBr99/nspanel-lovelace-ui.git
synced 2025-12-23 07:54:25 +01:00
Merge pull request #208 from illuzn/illuzn-patch-1
Make sensors useful in cardGrid
This commit is contained in:
@@ -116,7 +116,7 @@ class LuiPagesGen(object):
|
|||||||
|
|
||||||
self._send_mqtt_msg(f"weatherUpdate~{icon_cur}~{text_cur}{weather_res}{altLayout}")
|
self._send_mqtt_msg(f"weatherUpdate~{icon_cur}~{text_cur}{weather_res}{altLayout}")
|
||||||
|
|
||||||
def generate_entities_item(self, entity):
|
def generate_entities_item(self, entity, cardType):
|
||||||
entityId = entity.entityId
|
entityId = entity.entityId
|
||||||
icon = entity.iconOverride
|
icon = entity.iconOverride
|
||||||
name = entity.nameOverride
|
name = entity.nameOverride
|
||||||
@@ -170,9 +170,12 @@ class LuiPagesGen(object):
|
|||||||
return f"~switch~{entityId}~{icon_id}~{icon_color}~{name}~{switch_val}"
|
return f"~switch~{entityId}~{icon_id}~{icon_color}~{name}~{switch_val}"
|
||||||
if entityType in ["sensor", "binary_sensor"]:
|
if entityType in ["sensor", "binary_sensor"]:
|
||||||
device_class = entity.attributes.get("device_class", "")
|
device_class = entity.attributes.get("device_class", "")
|
||||||
icon_id = get_icon_id_ha("sensor", state=entity.state, device_class=device_class, overwrite=icon)
|
|
||||||
unit_of_measurement = entity.attributes.get("unit_of_measurement", "")
|
unit_of_measurement = entity.attributes.get("unit_of_measurement", "")
|
||||||
value = entity.state + " " + unit_of_measurement
|
value = entity.state + " " + unit_of_measurement
|
||||||
|
if cardType == "cardGrid":
|
||||||
|
icon_id = entity.state
|
||||||
|
else:
|
||||||
|
icon_id = get_icon_id_ha("sensor", state=entity.state, device_class=device_class, overwrite=icon)
|
||||||
icon_color = self.get_entity_color(entity)
|
icon_color = self.get_entity_color(entity)
|
||||||
return f"~text~{entityId}~{icon_id}~{icon_color}~{name}~{value}"
|
return f"~text~{entityId}~{icon_id}~{icon_color}~{name}~{value}"
|
||||||
if entityType in ["button", "input_button"]:
|
if entityType in ["button", "input_button"]:
|
||||||
@@ -207,11 +210,11 @@ class LuiPagesGen(object):
|
|||||||
return f"~text~{entityId}~{icon_id}~17299~{name}~{value}"
|
return f"~text~{entityId}~{icon_id}~17299~{name}~{value}"
|
||||||
return f"~text~{entityId}~{get_icon_id('alert-circle-outline')}~17299~error~"
|
return f"~text~{entityId}~{get_icon_id('alert-circle-outline')}~17299~error~"
|
||||||
|
|
||||||
def generate_entities_page(self, navigation, heading, items):
|
def generate_entities_page(self, navigation, heading, items, cardType):
|
||||||
command = f"entityUpd~{heading}~{navigation}"
|
command = f"entityUpd~{heading}~{navigation}"
|
||||||
# Get items and construct cmd string
|
# Get items and construct cmd string
|
||||||
for item in items:
|
for item in items:
|
||||||
command += self.generate_entities_item(item)
|
command += self.generate_entities_item(item, cardType)
|
||||||
self._send_mqtt_msg(command)
|
self._send_mqtt_msg(command)
|
||||||
|
|
||||||
def generate_thermo_page(self, navigation, entity, temp_unit):
|
def generate_thermo_page(self, navigation, entity, temp_unit):
|
||||||
@@ -380,7 +383,7 @@ class LuiPagesGen(object):
|
|||||||
self.page_type(card.cardType)
|
self.page_type(card.cardType)
|
||||||
|
|
||||||
if card.cardType in ["cardEntities", "cardGrid"]:
|
if card.cardType in ["cardEntities", "cardGrid"]:
|
||||||
self.generate_entities_page(navigation, card.title, card.entities)
|
self.generate_entities_page(navigation, card.title, card.entities, card.cardType)
|
||||||
return
|
return
|
||||||
if card.cardType == "cardThermo":
|
if card.cardType == "cardThermo":
|
||||||
temp_unit = card.raw_config.get("temperatureUnit", "celsius")
|
temp_unit = card.raw_config.get("temperatureUnit", "celsius")
|
||||||
|
|||||||
Reference in New Issue
Block a user