mirror of
https://github.com/joBr99/nspanel-lovelace-ui.git
synced 2025-12-21 06:54:24 +01:00
implement cardunlock
This commit is contained in:
@@ -533,6 +533,30 @@ class AlarmCard(HACard):
|
||||
result = f"{self.title}~{self.gen_nav()}~{main_entity.entity_id}{arm_buttons}~{icon}~{color}~{numpad}~{flashing}~{add_btn}"
|
||||
libs.panel_cmd.entityUpd(self.panel.sendTopic, result)
|
||||
|
||||
|
||||
class UnlockCard(HACard):
|
||||
def __init__(self, locale, config, panel):
|
||||
super().__init__(locale, config, panel)
|
||||
|
||||
def render(self):
|
||||
|
||||
color = rgb_dec565([255,0,0])
|
||||
icon = get_icon_char("lock")
|
||||
supported_modes = ["cardUnlock-unlock"]
|
||||
|
||||
entity_id = self.config.get("entity")
|
||||
|
||||
# add padding to arm buttons
|
||||
arm_buttons = ""
|
||||
for b in supported_modes:
|
||||
arm_buttons += f'~{get_translation(self.locale, "frontend.ui.card.lock.unlock")}~{b}'
|
||||
if len(supported_modes) < 4:
|
||||
arm_buttons += "~"*((4-len(supported_modes))*2)
|
||||
numpad = "enable"
|
||||
|
||||
result = f"{self.title}~{self.gen_nav()}~{entity_id}{arm_buttons}~{icon}~{color}~{numpad}~disable~"
|
||||
libs.panel_cmd.entityUpd(self.panel.sendTopic, result)
|
||||
|
||||
class Screensaver(HACard):
|
||||
def __init__(self, locale, config, panel):
|
||||
super().__init__(locale, config, panel)
|
||||
@@ -594,6 +618,8 @@ def card_factory(locale, settings, panel):
|
||||
card = ClimateCard(locale, settings, panel)
|
||||
case 'cardAlarm':
|
||||
card = AlarmCard(locale, settings, panel)
|
||||
case 'cardUnlock':
|
||||
card = UnlockCard(locale, settings, panel)
|
||||
case _:
|
||||
logging.error("card type %s not implemented", settings["type"])
|
||||
return "NotImplemented", None
|
||||
|
||||
@@ -246,6 +246,12 @@ class LovelaceUIPanel:
|
||||
# send ha stuff to ha
|
||||
case _:
|
||||
ha_control.handle_buttons(entity_id, btype, value)
|
||||
case 'cardUnlock-unlock':
|
||||
card_iid = entity_id.split(".")[1]
|
||||
if int(self.current_card.config.get("pin")) == int(value):
|
||||
self.privious_cards.append(self.current_card)
|
||||
self.current_card = self.searchCard(card_iid)
|
||||
self.render_current_page(switchPages=True)
|
||||
case _:
|
||||
ha_control.handle_buttons(entity_id, btype, value)
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@ class Card:
|
||||
def render(self):
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
class Entity:
|
||||
def __init__(self, locale, config, panel):
|
||||
self.iid = iid()
|
||||
|
||||
Reference in New Issue
Block a user