Update icons.py

This commit is contained in:
illuzn
2022-05-22 22:17:40 +09:30
committed by GitHub
parent d206c4ee94
commit 7a5725d16f

View File

@@ -86,7 +86,46 @@ cover_mapping_closed = {
"window": "window-closed"
}
def map_to_mdi_name(ha_type, state=None, device_class=None):
cover_mapping_action_open = {
"awning": "arrow-up",
"blind": "arrow-up",
"curtain": "arrow-expand-horizontal",
"damper": "arrow-up",
"door": "arrow-expand-horizontal",
"garage": "arrow-up",
"gate": "arrow-expand-horizontal",
"shade": "arrow-up",
"shutter": "arrow-up",
"window": "arrow-up"
}
cover_mapping_action_close = {
"awning": "arrow-down",
"blind": "arrow-down",
"curtain": "arrow-collapse-horizontal",
"damper": "arrow-down",
"door": "arrow-collapse-horizontal",
"garage": "arrow-down",
"gate": "arrow-collapse-horizontal",
"shade": "arrow-down",
"shutter": "arrow-down",
"window": "arrow-down"
}
cover_mapping_action_stop = {
"awning": "stop",
"blind": "stop",
"curtain": "stop",
"damper": "stop",
"door": "stop",
"garage": "stop",
"gate": "stop",
"shade": "stop",
"shutter": "stop",
"window": "stop"
}
def map_to_mdi_name(ha_type, state=None, device_class=None, cardType=None):
if ha_type == "weather":
return weather_mapping[state] if state in weather_mapping else "alert-circle-outline"
if ha_type == "button":
@@ -129,3 +168,22 @@ def get_icon_id_ha(ha_name, state=None, device_class=None, overwrite=None):
if overwrite is not None:
return get_icon_id(overwrite)
return get_icon_id(map_to_mdi_name(ha_name, state, device_class))
def get_action_id_ha(ha_type, action, device_class=None, overwrite=None):
if overwrite is not None:
return get_icon_id(overwrite)
if ha_type == "cover":
if device_class is None:
device_class = "window"
if action == "open":
actionicon = cover_mapping_action_open[device_class] if device_class in cover_mapping_action_open else "alert-circle-outline"
elif action == "close":
actionicon = cover_mapping_action_close[device_class] if device_class in cover_mapping_action_close else "alert-circle-outline"
elif action == "stop":
actionicon = cover_mapping_action_stop[device_class] if device_class in cover_mapping_action_stop else "alert-circle-outline"
else:
actionicon = "alert-circle-outline"
else:
actionicon = "alert-circle-outline"
return get_icon_id(actionicon)