add basic implementation for showing modes on popupThermo

This commit is contained in:
Johannes
2022-10-23 18:51:45 +02:00
parent 6ced2a5772
commit eb2926b771
2 changed files with 21 additions and 1 deletions

View File

@@ -178,7 +178,9 @@ class LuiController(object):
self._pages_gen.generate_light_detail_page(entity_id)
if detail_type == "popupFan":
self._pages_gen.generate_fan_detail_page(entity_id)
if detail_type == "popupThermo":
self._pages_gen.generate_thermo_detail_page(entity_id)
def button_press(self, entity_id, button_type, value):
apis.ha_api.log(f"Button Press Event; entity_id: {entity_id}; button_type: {button_type}; value: {value} ")
# internal buttons

View File

@@ -775,6 +775,24 @@ class LuiPagesGen(object):
self._send_mqtt_msg(f"entityUpdateDetail~{entity_id}~~{icon_color}~{switch_val}~{speed}~{speedMax}~{speed_translation}~{preset_mode}~{preset_modes}")
def generate_thermo_detail_page(self, entity_id):
entity = apis.ha_api.get_entity(entity_id)
icon_id = get_icon("climate", state=entity.state)
icon_color = self.get_entity_color(entity, ha_type="climate")
modes_res = ""
for mode_type in ["preset_modes", "swing_modes", "fan_modes"]:
heading = mode_type
mode = entity.attributes.get(mode_type[:-1], "")
modes = entity.attributes.get(mode_type, [])
if modes is not None:
modes = "?".join(modes)
else:
modes = ""
modes_res += f"{heading}~{mode_type}~{mode}~{modes}~"
self._send_mqtt_msg(f"entityUpdateDetail~{entity_id}~{icon_id}~{icon_color}~{modes_res}")
def send_message_page(self, ident, heading, msg, b1, b2):
self._send_mqtt_msg(f"pageType~popupNotify")
self._send_mqtt_msg(f"entityUpdateDetail~{ident}~{heading}~65535~{b1}~65535~{b2}~65535~{msg}~65535~0")