mirror of
https://github.com/joBr99/nspanel-lovelace-ui.git
synced 2026-02-03 03:48:55 +01:00
implement effect fav list
This commit is contained in:
@@ -194,6 +194,9 @@ class LuiController(object):
|
|||||||
|
|
||||||
def button_press(self, entity_id, button_type, value):
|
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} ")
|
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
|
# internal buttons
|
||||||
if entity_id == "screensaver" and button_type == "bExit":
|
if entity_id == "screensaver" and button_type == "bExit":
|
||||||
# get default card if there is one
|
# get default card if there is one
|
||||||
@@ -226,14 +229,6 @@ class LuiController(object):
|
|||||||
|
|
||||||
if button_type == "bExit":
|
if button_type == "bExit":
|
||||||
self._pages_gen.render_card(self._current_card)
|
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":
|
elif entity_id == "updateDisplayNoYes" and value == "no":
|
||||||
self._pages_gen.render_card(self._current_card)
|
self._pages_gen.render_card(self._current_card)
|
||||||
@@ -275,10 +270,6 @@ class LuiController(object):
|
|||||||
|
|
||||||
|
|
||||||
if button_type == "button":
|
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'):
|
if entity_id.startswith('navigate'):
|
||||||
# internal navigation for next/prev
|
# internal navigation for next/prev
|
||||||
if entity_id.startswith('navigate.uuid'):
|
if entity_id.startswith('navigate.uuid'):
|
||||||
@@ -320,7 +311,7 @@ class LuiController(object):
|
|||||||
else:
|
else:
|
||||||
apis.ha_api.get_entity(entity_id).call_service("return_to_base")
|
apis.ha_api.get_entity(entity_id).call_service("return_to_base")
|
||||||
elif entity_id.startswith('service'):
|
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
|
# for media page
|
||||||
if button_type == "media-next":
|
if button_type == "media-next":
|
||||||
@@ -419,8 +410,12 @@ class LuiController(object):
|
|||||||
|
|
||||||
if button_type == "mode-light":
|
if button_type == "mode-light":
|
||||||
entity = apis.ha_api.get_entity(entity_id)
|
entity = apis.ha_api.get_entity(entity_id)
|
||||||
option = entity.attributes.effect_list[int(value)]
|
options_list = entity_config.entity_input_config.get("effectList")
|
||||||
entity.call_service("select_effect", option=option)
|
if options_list is not None:
|
||||||
|
option = options_list[int(value)]
|
||||||
|
else:
|
||||||
|
option = entity.attributes.effect_list[int(value)]
|
||||||
|
entity.call_service("turn_on", effect=option)
|
||||||
|
|
||||||
if button_type == "mode-media_player":
|
if button_type == "mode-media_player":
|
||||||
entity = apis.ha_api.get_entity(entity_id)
|
entity = apis.ha_api.get_entity(entity_id)
|
||||||
|
|||||||
@@ -382,6 +382,9 @@ class LuiPagesGen(object):
|
|||||||
value = apis.ha_api.render_template(ovalue)
|
value = apis.ha_api.render_template(ovalue)
|
||||||
if self._locale == "he_IL" and any("\u0590" <= c <= "\u05EA" for c in name):
|
if self._locale == "he_IL" and any("\u0590" <= c <= "\u05EA" for c in name):
|
||||||
name = name[::-1]
|
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}"
|
return f"~{entityTypePanel}~{entityId}~{icon_id}~{color}~{name}~{value}"
|
||||||
|
|
||||||
def generate_entities_page(self, navigation, heading, items, cardType, tempUnit):
|
def generate_entities_page(self, navigation, heading, items, cardType, tempUnit):
|
||||||
@@ -719,7 +722,11 @@ class LuiPagesGen(object):
|
|||||||
return
|
return
|
||||||
|
|
||||||
def generate_light_detail_page(self, entity_id, is_open_detail=False):
|
def generate_light_detail_page(self, entity_id, is_open_detail=False):
|
||||||
entity = apis.ha_api.get_entity(entity_id)
|
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
|
switch_val = 1 if entity.state == "on" else 0
|
||||||
icon_color = self.get_entity_color(entity)
|
icon_color = self.get_entity_color(entity)
|
||||||
brightness = "disable"
|
brightness = "disable"
|
||||||
@@ -874,16 +881,26 @@ class LuiPagesGen(object):
|
|||||||
self._send_mqtt_msg(f"entityUpdateDetail~{entity_id}~{icon_id}~{icon_color}~{modes_out}", force=is_open_detail)
|
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):
|
def generate_input_select_detail_page(self, entity_id, is_open_detail=False):
|
||||||
entity = apis.ha_api.get_entity(entity_id)
|
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 = []
|
options = []
|
||||||
icon_color = 0
|
icon_color = 0
|
||||||
ha_type = entity_id.split(".")[0]
|
|
||||||
icon_color = self.get_entity_color(entity, ha_type=ha_type)
|
icon_color = self.get_entity_color(entity, ha_type=ha_type)
|
||||||
state = entity.state
|
state = entity.state
|
||||||
if ha_type in ["input_select", "select"]:
|
if ha_type in ["input_select", "select"]:
|
||||||
options = entity.attributes.get("options", [])
|
options = entity.attributes.get("options", [])
|
||||||
elif ha_type == "light":
|
elif ha_type == "light":
|
||||||
options = entity.attributes.get("effect_list", [])[:15]
|
if options_list is not None:
|
||||||
|
options = options_list
|
||||||
|
else:
|
||||||
|
options = entity.attributes.get("effect_list", [])[:15]
|
||||||
elif ha_type == "media_player":
|
elif ha_type == "media_player":
|
||||||
state = entity.attributes.get("source", "")
|
state = entity.attributes.get("source", "")
|
||||||
options = entity.attributes.get("source_list", [])
|
options = entity.attributes.get("source_list", [])
|
||||||
|
|||||||
Reference in New Issue
Block a user