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