mirror of
https://github.com/joBr99/nspanel-lovelace-ui.git
synced 2025-12-22 15:34:26 +01:00
Add support for alarm_control_panel and sun
This commit is contained in:
@@ -115,6 +115,22 @@ def map_to_mdi_name(ha_type, state=None, device_class="_", cardType=None):
|
|||||||
return sensor_mapping[device_class] if device_class in sensor_mapping else "alert-circle-outline"
|
return sensor_mapping[device_class] if device_class in sensor_mapping else "alert-circle-outline"
|
||||||
elif ha_type == "alarm-arm-fail":
|
elif ha_type == "alarm-arm-fail":
|
||||||
return "progress-alert"
|
return "progress-alert"
|
||||||
|
elif ha_type == "alarm_control_panel":
|
||||||
|
if state == "disarmed":
|
||||||
|
return "shield-off"
|
||||||
|
if state == "armed_home":
|
||||||
|
return "shield-home"
|
||||||
|
if state == "armed_away":
|
||||||
|
return "shield-lock"
|
||||||
|
if state == "armed_night":
|
||||||
|
return "weather-night"
|
||||||
|
if state == "armed_vacation":
|
||||||
|
return "shield-airplane"
|
||||||
|
elif ha_type == "sun":
|
||||||
|
if state == "above_horizon":
|
||||||
|
return "weather-sunset-up"
|
||||||
|
if state == "below_horizon":
|
||||||
|
return "weather-sunset-down"
|
||||||
else:
|
else:
|
||||||
return "alert-circle-outline"
|
return "alert-circle-outline"
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ class LuiPagesGen(object):
|
|||||||
self._locale = config.get("locale")
|
self._locale = config.get("locale")
|
||||||
self._send_mqtt_msg = send_mqtt_msg
|
self._send_mqtt_msg = send_mqtt_msg
|
||||||
|
|
||||||
def get_entity_color(self, entity, overwrite=None):
|
def get_entity_color(self, entity, ha_type=None, overwrite=None):
|
||||||
if overwrite is not None:
|
if overwrite is not None:
|
||||||
if type(overwrite) is list:
|
if type(overwrite) is list:
|
||||||
return rgb_dec565(overwrite)
|
return rgb_dec565(overwrite)
|
||||||
@@ -35,7 +35,19 @@ class LuiPagesGen(object):
|
|||||||
attr = entity.attributes
|
attr = entity.attributes
|
||||||
default_color_on = rgb_dec565([253, 216, 53])
|
default_color_on = rgb_dec565([253, 216, 53])
|
||||||
default_color_off = rgb_dec565([68, 115, 158])
|
default_color_off = rgb_dec565([68, 115, 158])
|
||||||
icon_color = default_color_on if entity.state in ["on", "unlocked"] else default_color_off
|
icon_color = default_color_on if entity.state in ["on", "unlocked", "above_horizon"] else default_color_off
|
||||||
|
|
||||||
|
if ha_type == "alarm_control_panel":
|
||||||
|
if entity.state == "disarmed":
|
||||||
|
icon_color = rgb_dec565([13,160,53])
|
||||||
|
if entity.state == "armed_home":
|
||||||
|
icon_color = rgb_dec565([223,76,30])
|
||||||
|
if entity.state == "armed_away":
|
||||||
|
icon_color = rgb_dec565([223,76,30])
|
||||||
|
if entity.state == "armed_night":
|
||||||
|
icon_color = rgb_dec565([223,76,30])
|
||||||
|
if entity.state == "armed_vacation":
|
||||||
|
icon_color = rgb_dec565([223,76,30])
|
||||||
|
|
||||||
if "rgb_color" in attr:
|
if "rgb_color" in attr:
|
||||||
color = attr.rgb_color
|
color = attr.rgb_color
|
||||||
@@ -307,6 +319,16 @@ class LuiPagesGen(object):
|
|||||||
else:
|
else:
|
||||||
text = "Return"
|
text = "Return"
|
||||||
return f"~button~{entityId}~{icon_id}~17299~{name}~{text}"
|
return f"~button~{entityId}~{icon_id}~17299~{name}~{text}"
|
||||||
|
if entityType == "alarm_control_panel":
|
||||||
|
icon_color = self.get_entity_color(entity, ha_type=entityType, overwrite=colorOverride)
|
||||||
|
icon_id = get_icon_id_ha(entityType, state=entity.state, overwrite=icon)
|
||||||
|
text = get_translation(self._locale, f"frontend.state_badge.alarm_control_panel.{entity.state}")
|
||||||
|
return f"~text~{entityId}~{icon_id}~{icon_color}~{name}~{text}"
|
||||||
|
if entityType == "sun":
|
||||||
|
icon_color = self.get_entity_color(entity, overwrite=colorOverride)
|
||||||
|
icon_id = get_icon_id_ha(entityType, state=entity.state, overwrite=icon)
|
||||||
|
text = get_translation(self._locale, f"backend.component.sun.state._.{entity.state}")
|
||||||
|
return f"~text~{entityId}~{icon_id}~{icon_color}~{name}~{text}"
|
||||||
return f"~text~{entityId}~{get_icon_id('alert-circle-outline')}~17299~unsupported~"
|
return f"~text~{entityId}~{get_icon_id('alert-circle-outline')}~17299~unsupported~"
|
||||||
|
|
||||||
def generate_entities_page(self, navigation, heading, items, cardType):
|
def generate_entities_page(self, navigation, heading, items, cardType):
|
||||||
|
|||||||
Reference in New Issue
Block a user