mirror of
https://github.com/joBr99/nspanel-lovelace-ui.git
synced 2026-02-11 15:47:42 +01:00
implement #449
This commit is contained in:
@@ -385,6 +385,18 @@ class LuiController(object):
|
|||||||
msg += f"- {apis.ha_api.get_entity(e).attributes.friendly_name}\r\n"
|
msg += f"- {apis.ha_api.get_entity(e).attributes.friendly_name}\r\n"
|
||||||
self._pages_gen.send_message_page("opnSensorNotifyRes", "", msg, "", "")
|
self._pages_gen.send_message_page("opnSensorNotifyRes", "", msg, "", "")
|
||||||
|
|
||||||
|
# for cardUnlock
|
||||||
|
if button_type == "cardUnlock-unlock":
|
||||||
|
curCard = self._config.get_card_by_uuid(entity_id.replace('navigate.',''))
|
||||||
|
if curCard is not None:
|
||||||
|
if int(curCard.raw_config.get("pin")) == int(value):
|
||||||
|
dstCard = self._config.search_card(curCard.raw_config.get("destination"))
|
||||||
|
if dstCard is not None:
|
||||||
|
if dstCard.hidden:
|
||||||
|
self._previous_cards.append(self._current_card)
|
||||||
|
self._current_card = dstCard
|
||||||
|
self._pages_gen.render_card(self._current_card)
|
||||||
|
|
||||||
if button_type == "mode-preset_modes":
|
if button_type == "mode-preset_modes":
|
||||||
entity = apis.ha_api.get_entity(entity_id)
|
entity = apis.ha_api.get_entity(entity_id)
|
||||||
preset_mode = entity.attributes.preset_modes[int(value)]
|
preset_mode = entity.attributes.preset_modes[int(value)]
|
||||||
|
|||||||
@@ -121,6 +121,8 @@ class LuiPagesGen(object):
|
|||||||
self._send_mqtt_msg(f"date~{date}{addDateText}")
|
self._send_mqtt_msg(f"date~{date}{addDateText}")
|
||||||
|
|
||||||
def page_type(self, target_page):
|
def page_type(self, target_page):
|
||||||
|
if target_page == "cardUnlock":
|
||||||
|
target_page = "cardAlarm"
|
||||||
self._send_mqtt_msg(f"pageType~{target_page}")
|
self._send_mqtt_msg(f"pageType~{target_page}")
|
||||||
|
|
||||||
def update_screensaver_weather(self, theme):
|
def update_screensaver_weather(self, theme):
|
||||||
@@ -368,7 +370,7 @@ class LuiPagesGen(object):
|
|||||||
ovalue = item.value
|
ovalue = item.value
|
||||||
if ovalue is not None:
|
if ovalue is not None:
|
||||||
value = apis.ha_api.render_template(ovalue)
|
value = apis.ha_api.render_template(ovalue)
|
||||||
if 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]
|
||||||
return f"~{entityTypePanel}~{entityId}~{icon_id}~{color}~{name}~{value}"
|
return f"~{entityTypePanel}~{entityId}~{icon_id}~{color}~{name}~{value}"
|
||||||
|
|
||||||
@@ -595,6 +597,20 @@ class LuiPagesGen(object):
|
|||||||
command = f"entityUpd~{title}~{navigation}~{item}{arm_buttons}~{icon}~{color}~{numpad}~{flashing}~{add_btn}"
|
command = f"entityUpd~{title}~{navigation}~{item}{arm_buttons}~{icon}~{color}~{numpad}~{flashing}~{add_btn}"
|
||||||
self._send_mqtt_msg(command)
|
self._send_mqtt_msg(command)
|
||||||
|
|
||||||
|
def generate_unlock_page(self, navigation, item, title, destination, pin):
|
||||||
|
color = rgb_dec565([255,0,0])
|
||||||
|
icon = get_icon_id("lock")
|
||||||
|
supported_modes = ["cardUnlock-unlock"]
|
||||||
|
|
||||||
|
# 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"
|
||||||
|
command = f"entityUpd~{title}~{navigation}~{item}{arm_buttons}~{icon}~{color}~{numpad}~disable~"
|
||||||
|
self._send_mqtt_msg(command)
|
||||||
|
|
||||||
def generate_qr_page(self, navigation, heading, items, cardType, qrcode):
|
def generate_qr_page(self, navigation, heading, items, cardType, qrcode):
|
||||||
qrcode = apis.ha_api.render_template(qrcode)
|
qrcode = apis.ha_api.render_template(qrcode)
|
||||||
@@ -679,6 +695,12 @@ class LuiPagesGen(object):
|
|||||||
overwrite_supported_modes = card.raw_config.get("supportedModes")
|
overwrite_supported_modes = card.raw_config.get("supportedModes")
|
||||||
self.generate_alarm_page(navigation, card.title, card.entity, overwrite_supported_modes, alarmBtn)
|
self.generate_alarm_page(navigation, card.title, card.entity, overwrite_supported_modes, alarmBtn)
|
||||||
return
|
return
|
||||||
|
if card.cardType == "cardUnlock":
|
||||||
|
pin = card.raw_config.get("pin", 3830)
|
||||||
|
destination = card.raw_config.get("destination")
|
||||||
|
item = card.uuid
|
||||||
|
self.generate_unlock_page(navigation, item, card.title, destination, pin)
|
||||||
|
return
|
||||||
if card.cardType == "screensaver":
|
if card.cardType == "screensaver":
|
||||||
theme = card.raw_config.get("theme")
|
theme = card.raw_config.get("theme")
|
||||||
self.update_screensaver_weather(theme)
|
self.update_screensaver_weather(theme)
|
||||||
@@ -903,3 +925,4 @@ class LuiPagesGen(object):
|
|||||||
def send_message_page(self, ident, heading, msg, b1, b2):
|
def send_message_page(self, ident, heading, msg, b1, b2):
|
||||||
self._send_mqtt_msg(f"pageType~popupNotify")
|
self._send_mqtt_msg(f"pageType~popupNotify")
|
||||||
self._send_mqtt_msg(f"entityUpdateDetail~{ident}~{heading}~65535~{b1}~65535~{b2}~65535~{msg}~65535~0")
|
self._send_mqtt_msg(f"entityUpdateDetail~{ident}~{heading}~65535~{b1}~65535~{b2}~65535~{msg}~65535~0")
|
||||||
|
|
||||||
@@ -13,7 +13,7 @@ List of supported config keys of this card:
|
|||||||
|
|
||||||
key | optional | type | default | description
|
key | optional | type | default | description
|
||||||
-- | -- | -- | -- | --
|
-- | -- | -- | -- | --
|
||||||
`type` | False | string | `None` | Used by navigate items
|
`type` | False | string | `None` | Type of the card
|
||||||
`title` | True | string | `None` | Title of the Page
|
`title` | True | string | `None` | Title of the Page
|
||||||
`entity` | False | string | `None` | contains the entity of the current card
|
`entity` | False | string | `None` | contains the entity of the current card
|
||||||
`key` | True | string | `None` | Used by navigate items
|
`key` | True | string | `None` | Used by navigate items
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ List of supported config keys of this card:
|
|||||||
|
|
||||||
key | optional | type | default | description
|
key | optional | type | default | description
|
||||||
-- | -- | -- | -- | --
|
-- | -- | -- | -- | --
|
||||||
`type` | False | string | `None` | Used by navigate items
|
`type` | False | string | `None` | Type of the card
|
||||||
`title` | True | string | `None` | Title of the Page
|
`title` | True | string | `None` | Title of the Page
|
||||||
`entity` | False | string | `None` | contains the entity of the current card
|
`entity` | False | string | `None` | contains the entity of the current card
|
||||||
`entities` | False | complex | `None` | contains a list of entities shown in the bottom row, supports all entities supported by cardGrid
|
`entities` | False | complex | `None` | contains a list of entities shown in the bottom row, supports all entities supported by cardGrid
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ List of supported config keys of this card:
|
|||||||
|
|
||||||
key | optional | type | default | description
|
key | optional | type | default | description
|
||||||
-- | -- | -- | -- | --
|
-- | -- | -- | -- | --
|
||||||
`type` | False | string | `None` | Used by navigate items
|
`type` | False | string | `None` | Type of the card
|
||||||
`entities` | False | complex | `None` | contains entities of the card
|
`entities` | False | complex | `None` | contains entities of the card
|
||||||
`title` | True | string | `None` | Title of the Page
|
`title` | True | string | `None` | Title of the Page
|
||||||
`key` | True | string | `None` | Used by navigate items
|
`key` | True | string | `None` | Used by navigate items
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ List of supported config keys of this card:
|
|||||||
|
|
||||||
key | optional | type | default | description
|
key | optional | type | default | description
|
||||||
-- | -- | -- | -- | --
|
-- | -- | -- | -- | --
|
||||||
`type` | False | string | `None` | Used by navigate items
|
`type` | False | string | `None` | Type of the card
|
||||||
`entities` | False | complex | `None` | contains entities of the card, only valid on cardEntities and cardGrid and cardQR
|
`entities` | False | complex | `None` | contains entities of the card, only valid on cardEntities and cardGrid and cardQR
|
||||||
`title` | True | string | `None` | Title of the Page
|
`title` | True | string | `None` | Title of the Page
|
||||||
`key` | True | string | `None` | Used by navigate items
|
`key` | True | string | `None` | Used by navigate items
|
||||||
|
|||||||
29
docs/card-unlock.md
Normal file
29
docs/card-unlock.md
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
# Unlock Card (v4.0 and higher)
|
||||||
|
|
||||||
|
Can be used to navigate to create pin locked navigation to a hidden card.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
```yaml
|
||||||
|
cards:
|
||||||
|
- type: cardUnlock
|
||||||
|
pin: 1234
|
||||||
|
title: Admin Page
|
||||||
|
destination: navigate.adminpage
|
||||||
|
hiddenCards:
|
||||||
|
- type: cardGrid
|
||||||
|
title: Admin Page
|
||||||
|
key: adminpage
|
||||||
|
entities:
|
||||||
|
- entity: light.schreibtischlampe
|
||||||
|
```
|
||||||
|
|
||||||
|
List of supported config keys of this card:
|
||||||
|
|
||||||
|
key | optional | type | default | description
|
||||||
|
-- | -- | -- | -- | --
|
||||||
|
`type` | False | string | `None` | Type of the card
|
||||||
|
`title` | True | string | `None` | Title of the Page
|
||||||
|
`destination` | False | string | `None` | contains the navigation entity this card should navigate to on unlock
|
||||||
|
`pin` | False | string | 3830 | pin to unlock
|
||||||
|
`key` | True | string | `None` | Used by navigate items
|
||||||
BIN
docs/img/card-unlock.png
Normal file
BIN
docs/img/card-unlock.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 15 KiB |
@@ -82,6 +82,7 @@ nav:
|
|||||||
- "Alarm Card": card-alarm.md
|
- "Alarm Card": card-alarm.md
|
||||||
- "Wifi/QR Card": card-qr.md
|
- "Wifi/QR Card": card-qr.md
|
||||||
- "Power Card": card-power.md
|
- "Power Card": card-power.md
|
||||||
|
- "Unlock Card": card-unlock.md
|
||||||
- "Special Settings for Entities": entities.md
|
- "Special Settings for Entities": entities.md
|
||||||
- "Subpages": subpages.md
|
- "Subpages": subpages.md
|
||||||
- "Notifications": notifications.md
|
- "Notifications": notifications.md
|
||||||
|
|||||||
Reference in New Issue
Block a user