add config for temp unit on climate card

This commit is contained in:
Johannes
2022-05-15 10:42:29 +02:00
parent 3935616cb2
commit 34cdc8b4e9
2 changed files with 15 additions and 5 deletions

View File

@@ -198,14 +198,23 @@ class LuiPagesGen(object):
command += self.generate_entities_item(item)
self._send_mqtt_msg(command)
def generate_thermo_page(self, navigation, entity):
def generate_thermo_page(self, navigation, entity, temp_unit):
item = entity.entityId
if(temp_unit == "celsius"):
temperature_unit_icon = get_icon_id("temperature-celsius")
temperature_unit = "°C"
else:
temperature_unit_icon = get_icon_id("temperature-celsius")
temperature_unit = "°F"
if not self._ha_api.entity_exists(item):
command = f"entityUpd~{heading}~{navigation}~{item}~220~220~Not found~150~300~5"
else:
entity = self._ha_api.get_entity(item)
heading = entity.attributes.friendly_name
current_temp = int(get_attr_safe(entity, "current_temperature", 0)*10)
current_temp = get_attr_safe(entity, "current_temperature", "")
dest_temp = int(get_attr_safe(entity, "temperature", 0)*10)
status = get_attr_safe(entity, "hvac_action", "")
status = get_translation(self._locale,status)
@@ -243,9 +252,8 @@ class LuiPagesGen(object):
len_hvac_modes = len(hvac_modes)
padding_len = 8-len_hvac_modes
icon_res = icon_res + "~"*4*padding_len
temperature_unit = get_icon_id("temperature-celsius")
command = f"entityUpd~{heading}~{navigation}~{item}~{current_temp}~{dest_temp}~{status}~{min_temp}~{max_temp}~{step_temp}{icon_res}~Currently~State~Action~{temperature_unit}"
command = f"entityUpd~{heading}~{navigation}~{item}~{current_temp} {temperature_unit}~{dest_temp}~{status}~{min_temp}~{max_temp}~{step_temp}{icon_res}~Currently~State~Action~{temperature_unit_icon}"
self._send_mqtt_msg(command)
def generate_media_page(self, navigation, entity):
@@ -359,7 +367,8 @@ class LuiPagesGen(object):
self.generate_entities_page(navigation, card.title, card.entities)
return
if card.cardType == "cardThermo":
self.generate_thermo_page(navigation, card.entity)
temp_unit = card.raw_config.get("temperatureUnit", "celsius")
self.generate_thermo_page(navigation, card.entity, temp_unit)
if card.cardType == "cardMedia":
self.generate_media_page(navigation, card.entity)
if card.cardType == "cardAlarm":