mirror of
https://github.com/joBr99/nspanel-lovelace-ui.git
synced 2025-12-19 22:24:15 +01:00
implement input_select and select for light effects
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# https://developers.home-assistant.io/docs/add-ons/configuration#add-on-config
|
||||
name: NSPanel Lovelace UI Addon
|
||||
version: "4.7.68"
|
||||
version: "4.7.69"
|
||||
slug: nspanel-lovelace-ui
|
||||
description: NSPanel Lovelace UI Addon
|
||||
services:
|
||||
|
||||
@@ -764,22 +764,24 @@ def detail_open(locale, detail_type, ha_entity_id, entity_id, msg_out_queue, sen
|
||||
case 'popupThermo' | 'climate':
|
||||
print(f"not implemented {detail_type}")
|
||||
case 'popupInSel' | 'input_select' | 'select' | 'media_player':
|
||||
hatype = ha_entity_id.split(".")[0]
|
||||
options = []
|
||||
icon_color = 0
|
||||
icon_color = ha_colors.get_entity_color(detail_type, state, attributes)
|
||||
state = state
|
||||
if detail_type in ["input_select", "select"]:
|
||||
if hatype in ["input_select", "select"]:
|
||||
options = attributes.get("options", [])
|
||||
elif detail_type == "light":
|
||||
elif hatype == "light":
|
||||
if options_list is not None:
|
||||
options = options_list
|
||||
else:
|
||||
options = attributes.get("effect_list", [])[:15]
|
||||
elif detail_type == "media_player":
|
||||
state = attributes.get("effect")
|
||||
elif hatype == "media_player":
|
||||
state = attributes.get("source", "")
|
||||
options = attributes.get("source_list", [])
|
||||
options = "?".join(options)
|
||||
return f"{entity_id}~~{icon_color}~{detail_type}~{state}~{options}~"
|
||||
return f"{entity_id}~~{icon_color}~{hatype}~{state}~{options}~"
|
||||
|
||||
|
||||
case 'popupTimer' | 'timer':
|
||||
|
||||
@@ -51,7 +51,7 @@ def calculate_dim_values(sleepTracking, sleepTrackingZones, sleepBrightness, scr
|
||||
else:
|
||||
return dimmode, dimValueNormal
|
||||
|
||||
def handle_buttons(entity_id, btype, value):
|
||||
def handle_buttons(entity_id, btype, value, entity_config):
|
||||
match btype:
|
||||
case 'button':
|
||||
button_press(entity_id, value)
|
||||
@@ -186,7 +186,7 @@ def handle_buttons(entity_id, btype, value):
|
||||
}
|
||||
call_ha_service(entity_id, "select_source", service_data=service_data)
|
||||
case 'mode-light':
|
||||
options = libs.home_assistant.get_entity_data(entity_id).get('attributes', []).get("effect_list", [])
|
||||
options = entity_config.get("effectList", libs.home_assistant.get_entity_data(entity_id).get('attributes', []).get("effect_list", []))
|
||||
if options:
|
||||
option = options[int(value)]
|
||||
service_data = {
|
||||
|
||||
@@ -139,10 +139,13 @@ class LovelaceUIPanel:
|
||||
effectList = None
|
||||
if etype=="light":
|
||||
effectList = e.config.get("effectList")
|
||||
if etype in ['input_select', 'media_player']:
|
||||
libs.panel_cmd.entityUpdateDetail2(self.msg_out_queue, self.sendTopic, detail_open(self.settings["locale"], etype, entity_id, entity_id_iid, self.msg_out_queue, sendTopic=self.sendTopic, options_list=effectList))
|
||||
if etype == 'light':
|
||||
libs.panel_cmd.entityUpdateDetail2(self.msg_out_queue, self.sendTopic, detail_open(self.settings["locale"], "popupInSel", entity_id, entity_id_iid, self.msg_out_queue, sendTopic=self.sendTopic, options_list=effectList))
|
||||
libs.panel_cmd.entityUpdateDetail(self.msg_out_queue, self.sendTopic, detail_open(self.settings["locale"], "popupLight", entity_id, entity_id_iid, self.msg_out_queue, sendTopic=self.sendTopic))
|
||||
elif etype in ['input_select', 'media_player']:
|
||||
libs.panel_cmd.entityUpdateDetail2(self.msg_out_queue, self.sendTopic, detail_open(self.settings["locale"], etype, entity_id, entity_id_iid, self.msg_out_queue, sendTopic=self.sendTopic))
|
||||
else:
|
||||
libs.panel_cmd.entityUpdateDetail(self.msg_out_queue, self.sendTopic, detail_open(self.settings["locale"], etype, entity_id, entity_id_iid, self.msg_out_queue, sendTopic=self.sendTopic, options_list=effectList))
|
||||
libs.panel_cmd.entityUpdateDetail(self.msg_out_queue, self.sendTopic, detail_open(self.settings["locale"], etype, entity_id, entity_id_iid, self.msg_out_queue, sendTopic=self.sendTopic))
|
||||
|
||||
involved_entities = ha_control.calculate_dim_values(
|
||||
self.settings.get("sleepTracking"),
|
||||
@@ -237,11 +240,19 @@ class LovelaceUIPanel:
|
||||
self.render_current_page(switchPages=True)
|
||||
return
|
||||
|
||||
# replace iid with real entity id
|
||||
#if entity_id.startswith("iid."):
|
||||
# iid = entity_id.split(".")[1]
|
||||
# if iid in self.entity_iids:
|
||||
# entity_id = self.entity_iids[iid]
|
||||
|
||||
# replace iid with real entity id
|
||||
if entity_id.startswith("iid."):
|
||||
iid = entity_id.split(".")[1]
|
||||
if iid in self.entity_iids:
|
||||
entity_id = self.entity_iids[iid]
|
||||
for e in self.current_card.entities:
|
||||
if e.iid == iid:
|
||||
entity_id = e.entity_id
|
||||
entity_config = e.config
|
||||
|
||||
match btype:
|
||||
case 'button':
|
||||
@@ -260,7 +271,7 @@ class LovelaceUIPanel:
|
||||
self.render_current_page(switchPages=True)
|
||||
# send ha stuff to ha
|
||||
case _:
|
||||
ha_control.handle_buttons(entity_id, btype, value)
|
||||
ha_control.handle_buttons(entity_id, btype, value, entity_config)
|
||||
case 'cardUnlock-unlock':
|
||||
card_iid = entity_id.split(".")[1]
|
||||
if int(self.current_card.config.get("pin")) == int(value):
|
||||
@@ -268,7 +279,7 @@ class LovelaceUIPanel:
|
||||
self.current_card = self.searchCard(card_iid)
|
||||
self.render_current_page(switchPages=True)
|
||||
case _:
|
||||
ha_control.handle_buttons(entity_id, btype, value)
|
||||
ha_control.handle_buttons(entity_id, btype, value, entity_config)
|
||||
|
||||
if msg[1] == "pageOpenDetail":
|
||||
entity_id = msg[3]
|
||||
@@ -281,7 +292,7 @@ class LovelaceUIPanel:
|
||||
effectList = None
|
||||
if entity_id.startswith("light"):
|
||||
effectList = e.config.get("effectList")
|
||||
if entity_id.split(".")[0] in ['input_select', 'media_player']:
|
||||
if msg[2] == "popupInSel": #entity_id.split(".")[0] in ['input_select', 'media_player']:
|
||||
libs.panel_cmd.entityUpdateDetail2(self.msg_out_queue, self.sendTopic, detail_open(self.settings["locale"], msg[2], entity_id, msg[3], self.msg_out_queue, sendTopic=self.sendTopic, options_list=effectList))
|
||||
else:
|
||||
libs.panel_cmd.entityUpdateDetail(self.msg_out_queue, self.sendTopic, detail_open(self.settings["locale"], msg[2], entity_id, msg[3], self.msg_out_queue, sendTopic=self.sendTopic))
|
||||
|
||||
Reference in New Issue
Block a user