Skip to content

Commit

Permalink
some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
joBr99 committed Nov 23, 2023
1 parent 5568854 commit 1b4c435
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 13 deletions.
2 changes: 1 addition & 1 deletion nspanel-lovelace-ui/config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# https://developers.home-assistant.io/docs/add-ons/configuration#add-on-config
name: NSPanel Lovelace UI Addon
version: "4.7.28"
version: "4.7.29"
slug: nspanel-lovelace-ui
description: NSPanel Lovelace UI Addon
services:
Expand Down
11 changes: 7 additions & 4 deletions nspanel-lovelace-ui/rootfs/usr/bin/mqtt-manager/ha_cards.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ def render(self, cardType=""):
if self.etype in ["delete", "navigate", "iText"]:
out = super().render()
if self.etype == "navigate" and "status" in self.config:
config["entity"] = config["status"]
self.config["entity"] = self.config.pop("status")
self.__init__(self.locale, self.config, self.panel)
status_out = self.render().split("~")
status_out[2] = out.split("~")[2]
status_out = status_out.join("~")
status_out = "~".join(status_out)
return status_out
return out

Expand All @@ -42,6 +43,8 @@ def render(self, cardType=""):
icon_char = ha_icons.get_icon_ha(self.etype, self.state, device_class=self.attributes.get("device_class", None), media_content_type=self.attributes.get("media_content_type", None), overwrite=self.config.get("icon"))
color = ha_colors.get_entity_color(
self.etype, self.state, self.attributes)
if self.color_overwrite:
color = rgb_dec565(self.color_overwrite)
name = self.config.get("name", self.attributes.get("friendly_name", "unknown"))
if self.name_overwrite:
name = self.name_overwrite
Expand Down Expand Up @@ -252,11 +255,11 @@ def gen_nav(self):
'color': [255, 255, 255],
}, self.panel
).render()[1:]
if not self.iid_prev and not self.iid_next:
if not self.iid_prev and not self.iid_next and len(self.panel.cards) != 1:
leftBtn = panel_cards.Entity(self.locale,
{
'entity': f'navigate.UP',
'icon': 'mdi:arrow-left-bold',
'icon': 'mdi:arrow-up-bold',
'color': [255, 255, 255],
}, self.panel
).render()[1:]
Expand Down
21 changes: 13 additions & 8 deletions nspanel-lovelace-ui/rootfs/usr/bin/mqtt-manager/panel_cards.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,27 @@ def __init__(self, locale, config, panel):
def render(self, cardType=""):
icon_char = self.icon_overwrite or ""
color = rgb_dec565([68, 115, 158])
if self.color_overwrite:
color = rgb_dec565(self.color_overwrite)
name = self.name_overwrite or ""
value = ""
match self.etype:
case 'delete':
return f"~delete~~~~~"
case 'navigate':
page_search_res = self.panel.searchCard(
self.entity_id.split(".")[1])
if page_search_res is not None:
if name == "":
name = page_search_res.title
value = get_translation(
self.locale, "frontend.ui.card.button.press")
card_iid = self.entity_id.split(".")[1]
if card_iid == "UP":
return f"~button~{self.entity_id}~{get_icon_char(icon_char)}~{color}~{name}~{value}"
else:
return f"~text~{self.entity_id}~{get_icon_char('mdi:alert-circle-outline')}~17299~page not found~"
page_search_res = self.panel.searchCard(card_iid)
if page_search_res is not None:
if name == "":
name = page_search_res.title
value = get_translation(
self.locale, "frontend.ui.card.button.press")
return f"~button~{self.entity_id}~{get_icon_char(icon_char)}~{color}~{name}~{value}"
else:
return f"~text~{self.entity_id}~{get_icon_char('mdi:alert-circle-outline')}~17299~page not found~"
case 'iText':
# TODO: Render as HA Template
value = self.entity_id.split(".")[1]
Expand Down

0 comments on commit 1b4c435

Please sign in to comment.