mirror of
https://github.com/joBr99/nspanel-lovelace-ui.git
synced 2026-02-13 16:38:17 +01:00
implements #431
This commit is contained in:
@@ -18,12 +18,64 @@ weather_mapping = {
|
|||||||
'windy-variant': 'weather-windy-variant'
|
'windy-variant': 'weather-windy-variant'
|
||||||
}
|
}
|
||||||
|
|
||||||
sensor_mapping_on = {
|
sensor_mapping_off = {
|
||||||
"door": "door-open",
|
"battery": "battery",
|
||||||
|
"battery_charging": "battery",
|
||||||
|
"carbon_monoxide": "smoke-detector",
|
||||||
|
"cold": "thermometer",
|
||||||
|
"connectivity": "close-network-outline",
|
||||||
|
"door": "door-closed",
|
||||||
|
"garage_door": "garage",
|
||||||
|
"power": "power-plug-off",
|
||||||
|
"gas": "checkbox-marked-circle",
|
||||||
|
"problem": "checkbox-marked-circle",
|
||||||
|
"safety": "checkbox-marked-circle",
|
||||||
|
"tamper": "check-circle",
|
||||||
|
"smoke": "smoke-detector-variant",
|
||||||
|
"heat": "thermometer",
|
||||||
|
"light": "brightness-5",
|
||||||
|
"lock": "lock",
|
||||||
|
"moisture": "water-off",
|
||||||
|
"motion": "motion-sensor-off",
|
||||||
|
"occupancy": "home-outline",
|
||||||
|
"opening": "square",
|
||||||
|
"plug": "power-plug-off",
|
||||||
|
"presence": "home-outline",
|
||||||
|
"running": "stop",
|
||||||
|
"sound": "music-note-off",
|
||||||
|
"update": "package",
|
||||||
|
"vibration": "crop-portrait",
|
||||||
|
"window": "window-closed",
|
||||||
}
|
}
|
||||||
|
|
||||||
sensor_mapping_off = {
|
sensor_mapping_on = {
|
||||||
"door": "door-closed",
|
"battery": "battery-outline",
|
||||||
|
"battery_charging": "battery-charging",
|
||||||
|
"carbon_monoxide": "smoke-detector-alert",
|
||||||
|
"cold": "snowflake",
|
||||||
|
"connectivity": "check-network-outline",
|
||||||
|
"door": "door-open",
|
||||||
|
"garage_door": "garage-open",
|
||||||
|
"power": "power-plug",
|
||||||
|
"gas": "alert-circle",
|
||||||
|
"problem": "alert-circle",
|
||||||
|
"safety": "alert-circle",
|
||||||
|
"tamper": "alert-circle",
|
||||||
|
"smoke": "smoke-detector-variant-alert",
|
||||||
|
"heat": "fire",
|
||||||
|
"light": "brightness-7",
|
||||||
|
"lock": "lock-open",
|
||||||
|
"moisture": "water",
|
||||||
|
"motion": "motion-sensor",
|
||||||
|
"occupancy": "home",
|
||||||
|
"opening": "square-outline",
|
||||||
|
"plug": "power-plug",
|
||||||
|
"presence": "home",
|
||||||
|
"running": "play",
|
||||||
|
"sound": "music-note",
|
||||||
|
"update": "package-up",
|
||||||
|
"vibration": "vibrate",
|
||||||
|
"window": "window-open",
|
||||||
}
|
}
|
||||||
|
|
||||||
sensor_mapping = {
|
sensor_mapping = {
|
||||||
@@ -109,12 +161,19 @@ def map_to_mdi_name(ha_type, state=None, device_class="_", cardType=None):
|
|||||||
elif ha_type == "lock":
|
elif ha_type == "lock":
|
||||||
return "lock-open" if state == "unlocked" else "lock"
|
return "lock-open" if state == "unlocked" else "lock"
|
||||||
elif ha_type == "sensor":
|
elif ha_type == "sensor":
|
||||||
if state == "on" and device_class in sensor_mapping_on:
|
return sensor_mapping[device_class] if device_class in sensor_mapping else "alert-circle-outline"
|
||||||
return sensor_mapping_on[device_class]
|
elif ha_type == "binary_sensor":
|
||||||
elif state == "off" and device_class in sensor_mapping_off:
|
if state == "on":
|
||||||
return sensor_mapping_off[device_class]
|
if device_class in sensor_mapping_on:
|
||||||
|
return sensor_mapping_on[device_class]
|
||||||
|
else:
|
||||||
|
return "checkbox-marked-circle"
|
||||||
else:
|
else:
|
||||||
return sensor_mapping[device_class] if device_class in sensor_mapping else "alert-circle-outline"
|
if device_class in sensor_mapping_off:
|
||||||
|
return sensor_mapping_off[device_class]
|
||||||
|
else:
|
||||||
|
return "radiobox-blank"
|
||||||
|
|
||||||
elif ha_type == "alarm-arm-fail":
|
elif ha_type == "alarm-arm-fail":
|
||||||
return "progress-alert"
|
return "progress-alert"
|
||||||
elif ha_type == "alarm_control_panel":
|
elif ha_type == "alarm_control_panel":
|
||||||
|
|||||||
@@ -296,7 +296,7 @@ class LuiPagesGen(object):
|
|||||||
if icon_id[-1] == ".":
|
if icon_id[-1] == ".":
|
||||||
icon_id = icon_id[:-1]
|
icon_id = icon_id[:-1]
|
||||||
else:
|
else:
|
||||||
icon_id = get_icon_id_ha("sensor", state=entity.state, device_class=device_class, overwrite=icon)
|
icon_id = get_icon_id_ha(entityType, state=entity.state, device_class=device_class, overwrite=icon)
|
||||||
elif entityType in ["button", "input_button"]:
|
elif entityType in ["button", "input_button"]:
|
||||||
entityTypePanel = "button"
|
entityTypePanel = "button"
|
||||||
value = get_translation(self._locale, "frontend.ui.card.button.press")
|
value = get_translation(self._locale, "frontend.ui.card.button.press")
|
||||||
|
|||||||
Reference in New Issue
Block a user