implement effect fav list

This commit is contained in:
joBr99
2023-02-01 21:25:50 +01:00
parent ff338fdd71
commit 0ca1982ebc
2 changed files with 31 additions and 19 deletions

View File

@@ -194,6 +194,9 @@ class LuiController(object):
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} ")
if entity_id.startswith('uuid'):
entity_config = self._config._config_entites_table.get(entity_id)
entity_id = entity_config.entityId
# internal buttons
if entity_id == "screensaver" and button_type == "bExit":
# get default card if there is one
@@ -226,14 +229,6 @@ class LuiController(object):
if button_type == "bExit":
self._pages_gen.render_card(self._current_card)
#if button_type == "bHome":
# if self._previous_cards:
# self._current_card = self._previous_cards[0]
# self._previous_cards.clear()
# else:
# self._current_card = self._config.getCard(0)
# self._pages_gen.render_card(self._current_card)
elif entity_id == "updateDisplayNoYes" and value == "no":
self._pages_gen.render_card(self._current_card)
@@ -275,10 +270,6 @@ class LuiController(object):
if button_type == "button":
if entity_id.startswith('uuid'):
le = self._config._config_entites_table.get(entity_id)
entity_id = le.entityId
if entity_id.startswith('navigate'):
# internal navigation for next/prev
if entity_id.startswith('navigate.uuid'):
@@ -320,7 +311,7 @@ class LuiController(object):
else:
apis.ha_api.get_entity(entity_id).call_service("return_to_base")
elif entity_id.startswith('service'):
apis.ha_api.call_service(entity_id.replace('service.', '', 1).replace('.','/', 1), **le.data)
apis.ha_api.call_service(entity_id.replace('service.', '', 1).replace('.','/', 1), **entity_config.data)
# for media page
if button_type == "media-next":
@@ -419,8 +410,12 @@ class LuiController(object):
if button_type == "mode-light":
entity = apis.ha_api.get_entity(entity_id)
options_list = entity_config.entity_input_config.get("effectList")
if options_list is not None:
option = options_list[int(value)]
else:
option = entity.attributes.effect_list[int(value)]
entity.call_service("select_effect", option=option)
entity.call_service("turn_on", effect=option)
if button_type == "mode-media_player":
entity = apis.ha_api.get_entity(entity_id)

View File

@@ -382,6 +382,9 @@ class LuiPagesGen(object):
value = apis.ha_api.render_template(ovalue)
if self._locale == "he_IL" and any("\u0590" <= c <= "\u05EA" for c in name):
name = name[::-1]
# use uuid instead for some types and probably expand on this in future
if entityType in ["light"]:
entityId = uuid
return f"~{entityTypePanel}~{entityId}~{icon_id}~{color}~{name}~{value}"
def generate_entities_page(self, navigation, heading, items, cardType, tempUnit):
@@ -719,6 +722,10 @@ class LuiPagesGen(object):
return
def generate_light_detail_page(self, entity_id, is_open_detail=False):
if entity_id.startswith('uuid'):
entity_config = self._config._config_entites_table.get(entity_id)
entity = apis.ha_api.get_entity(entity_config.entityId)
else:
entity = apis.ha_api.get_entity(entity_id)
switch_val = 1 if entity.state == "on" else 0
icon_color = self.get_entity_color(entity)
@@ -874,15 +881,25 @@ class LuiPagesGen(object):
self._send_mqtt_msg(f"entityUpdateDetail~{entity_id}~{icon_id}~{icon_color}~{modes_out}", force=is_open_detail)
def generate_input_select_detail_page(self, entity_id, is_open_detail=False):
options_list = None
if entity_id.startswith('uuid'):
entity_config = self._config._config_entites_table.get(entity_id)
entity = apis.ha_api.get_entity(entity_config.entityId)
ha_type = entity_config.entityId.split(".")[0]
options_list = entity_config.entity_input_config.get("effectList")
else:
entity = apis.ha_api.get_entity(entity_id)
ha_type = entity_id.split(".")[0]
options = []
icon_color = 0
ha_type = entity_id.split(".")[0]
icon_color = self.get_entity_color(entity, ha_type=ha_type)
state = entity.state
if ha_type in ["input_select", "select"]:
options = entity.attributes.get("options", [])
elif ha_type == "light":
if options_list is not None:
options = options_list
else:
options = entity.attributes.get("effect_list", [])[:15]
elif ha_type == "media_player":
state = entity.attributes.get("source", "")