mirror of
https://github.com/joBr99/nspanel-lovelace-ui.git
synced 2025-12-19 22:24:15 +01:00
implement popup on card thermo
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.70"
|
||||
version: "4.7.71"
|
||||
slug: nspanel-lovelace-ui
|
||||
description: NSPanel Lovelace UI Addon
|
||||
services:
|
||||
|
||||
@@ -460,7 +460,7 @@ class ClimateCard(HACard):
|
||||
if any(x in ["preset_modes", "swing_modes", "fan_modes"] for x in main_entity.attributes):
|
||||
detailPage = "0"
|
||||
|
||||
result = f"{self.title}~{self.gen_nav()}~{main_entity.entity_id}~{current_temp} {temperature_unit}~{dest_temp}~{state_value}~{min_temp}~{max_temp}~{step_temp}{icon_res}~{currently_translation}~{state_translation}~{action_translation}~{temperature_unit_icon}~{dest_temp2}~{detailPage}"
|
||||
result = f"{self.title}~{self.gen_nav()}~iid.{main_entity.iid}~{current_temp} {temperature_unit}~{dest_temp}~{state_value}~{min_temp}~{max_temp}~{step_temp}{icon_res}~{currently_translation}~{state_translation}~{action_translation}~{temperature_unit_icon}~{dest_temp2}~{detailPage}"
|
||||
libs.panel_cmd.entityUpd(self.panel.msg_out_queue, self.panel.sendTopic, result)
|
||||
|
||||
class AlarmCard(HACard):
|
||||
@@ -762,7 +762,30 @@ def detail_open(locale, detail_type, ha_entity_id, entity_id, msg_out_queue, sen
|
||||
|
||||
return f'{entity_id}~~{icon_color}~{switch_val}~{speed}~{speedMax}~{speed_translation}~{preset_mode}~{preset_modes}'
|
||||
case 'popupThermo' | 'climate':
|
||||
print(f"not implemented {detail_type}")
|
||||
icon_id = ha_icons.get_icon_ha("climate", state)
|
||||
icon_color = ha_colors.get_entity_color("climate", state, attributes)
|
||||
|
||||
modes_out = ""
|
||||
for mode in ["preset_modes", "swing_modes", "fan_modes"]:
|
||||
heading = get_translation(locale, f"frontend.ui.card.climate.{mode[:-1]}")
|
||||
cur_mode = attributes.get(mode[:-1], "")
|
||||
modes = attributes.get(mode, [])
|
||||
if modes is not None:
|
||||
if mode == "preset_modes":
|
||||
translated_modes = []
|
||||
for elem in modes:
|
||||
translated_modes.append(get_translation(locale, f"frontend.state_attributes.climate.preset_mode.{elem}"))
|
||||
cur_mode = get_translation(locale, f"frontend.state_attributes.climate.preset_mode.{cur_mode}")
|
||||
modes_res = "?".join(translated_modes)
|
||||
else:
|
||||
modes_res = "?".join(modes)
|
||||
if modes:
|
||||
modes_out += f"{heading}~{mode}~{cur_mode}~{modes_res}~"
|
||||
|
||||
return f"{entity_id}~{icon_id}~{icon_color}~{modes_out}"
|
||||
|
||||
|
||||
|
||||
case 'popupInSel' | 'input_select' | 'select' | 'media_player':
|
||||
hatype = ha_entity_id.split(".")[0]
|
||||
options = []
|
||||
|
||||
@@ -156,19 +156,20 @@ def handle_buttons(entity_id, btype, value, entity_config=None):
|
||||
}
|
||||
call_ha_service(entity_id, f"alarm_{btype}", service_data=service_data)
|
||||
case 'mode-preset_modes' | 'mode-swing_modes' | 'mode-fan_modes':
|
||||
attr = libs.home_assistant.get_entity_data(entity_id).get('attributes', [])
|
||||
mapping = {
|
||||
'mode-preset_modes': 'preset_modes',
|
||||
'mode-swing_modes': 'swing_modes',
|
||||
'mode-fan_modes': 'fan_mode'
|
||||
'mode-fan_modes': 'fan_modes'
|
||||
}
|
||||
if btype in mapping:
|
||||
modes = libs.home_assistant.get_entity_data(entity_id).get('attributes', []).get(mapping[btype], [])
|
||||
modes = attr.get(mapping[btype], [])
|
||||
if modes:
|
||||
mode = modes[int(value)]
|
||||
service_data = {
|
||||
mapping[btype]: mode
|
||||
mapping[btype][:-1]: mode
|
||||
}
|
||||
call_ha_service(entity_id, f"set_{mapping[btype]}", service_data=service_data)
|
||||
call_ha_service(entity_id, f"set_{mapping[btype][:-1]}", service_data=service_data)
|
||||
case 'mode-input_select' | 'mode-select':
|
||||
options = libs.home_assistant.get_entity_data(entity_id).get('attributes', []).get("options", [])
|
||||
if options:
|
||||
|
||||
@@ -129,7 +129,7 @@ class LovelaceUIPanel:
|
||||
|
||||
# send update for detail popup in case it's open
|
||||
etype = entity_id.split('.')[0]
|
||||
if etype in ['light', 'timer', 'cover', 'input_select', 'select', 'fan']:
|
||||
if etype in ['light', 'timer', 'cover', 'input_select', 'select', 'fan', 'climate']:
|
||||
# figure out iid of entity
|
||||
entity_id_iid = ""
|
||||
for e in self.current_card.entities:
|
||||
|
||||
Reference in New Issue
Block a user