From cfedcce654f318e945c66a4540e1eeb571f4e6ac Mon Sep 17 00:00:00 2001 From: Giorgio Ravera Date: Tue, 11 Jan 2022 22:26:02 +0100 Subject: [PATCH] Added automation selector --- .storage/lovelace.lovelace_settings | 183 +++++++++++++++++++++++++- input_select/automation_selector.yaml | 17 +++ 2 files changed, 197 insertions(+), 3 deletions(-) create mode 100644 input_select/automation_selector.yaml diff --git a/.storage/lovelace.lovelace_settings b/.storage/lovelace.lovelace_settings index 61800d52..5e12413a 100644 --- a/.storage/lovelace.lovelace_settings +++ b/.storage/lovelace.lovelace_settings @@ -33,13 +33,13 @@ { "entities": [ { - "entity": "automation.startup_restart_on_error" + "entity": "automation.home_assistant_startup_restart_on_error" }, { "entity": "automation.modalita_vacanza_gestione_tapparelle" }, { - "entity": "automation.startup_google_sync" + "entity": "automation.home_assistant_startup_google_sync" }, { "entity": "automation.risveglio_giorgio" @@ -173,8 +173,185 @@ "hours_to_show": 6 } ] + }, + { + "title": "Automazioni", + "path": "automations", + "icon": "mdi:cogs", + "type": "panel", + "badges": [], + "cards": [ + { + "type": "custom:layout-card", + "layout_type": "custom:grid-layout", + "layout": { + "grid-template-columns": "100px auto" + }, + "cards": [ + { + "type": "vertical-stack", + "cards": [ + { + "type": "custom:button-card", + "template": "generic_themed_input_select", + "entity": "input_select.automation_selector", + "variables": { + "value_select": "Allarmi" + }, + "icon": "mdi:alarm" + }, + { + "type": "custom:button-card", + "template": "generic_themed_input_select", + "entity": "input_select.automation_selector", + "variables": { + "value_select": "Guardia" + }, + "icon": "mdi:shield-home" + }, + { + "type": "custom:button-card", + "template": "generic_themed_input_select", + "entity": "input_select.automation_selector", + "variables": { + "value_select": "Home Assistant" + }, + "icon": "mdi:home-assistant" + }, + { + "type": "custom:button-card", + "template": "generic_themed_input_select", + "entity": "input_select.automation_selector", + "variables": { + "value_select": "Luci" + }, + "icon": "mdi:lightbulb" + }, + { + "type": "custom:button-card", + "template": "generic_themed_input_select", + "entity": "input_select.automation_selector", + "variables": { + "value_select": "Termosifoni" + }, + "icon": "mdi:radiator" + }, + { + "type": "custom:button-card", + "template": "generic_themed_input_select", + "entity": "input_select.automation_selector", + "variables": { + "value_select": "Shelly" + }, + "icon": "mdi:alpha-s-box" + }, + { + "type": "custom:button-card", + "template": "generic_themed_input_select", + "entity": "input_select.automation_selector", + "variables": { + "value_select": "Vacanza" + }, + "icon": "mdi:airplane" + }, + { + "type": "custom:button-card", + "template": "generic_themed_input_select", + "entity": "input_select.automation_selector", + "variables": { + "value_select": "Zigbee2MQTT" + }, + "icon": "mdi:zigbee" + } + ] + }, + { + "type": "custom:auto-entities", + "show_icon": false, + "show_header_toggle": true, + "card": { + "type": "entities", + "title": "Automazioni", + "state_color": true + }, + "filter": { + "template": "[ {% for auto in states.automation %}\n {% if states['input_select.automation_selector'].state.upper().replace(\" \",\"_\") in auto.entity_id.upper() %}\n {'entity': '{{ auto.entity_id }}', 'secondary_info': 'last-triggered'},\n {% endif %}\n {% endfor %} ]\n" + }, + "sort": { + "method": "name", + "reverse": false + } + } + ] + } + ] + } + ], + "button_card_templates": { + "generic_themed_input_select": { + "color_type": "icon", + "variables": { + "value_select": "" + }, + "show_name": true, + "name": "[[[ return variables.value_select ]]]\n", + "styles": { + "card": [ + { + "font-size": "11pt" + }, + { + "color": "var(--primary-text-color)" + }, + { + "background": "linear-gradient(var(--secondary-background-color), var(--primary-background-color))" + }, + { + "border": "rgba(115, 115, 115, 0.75) 0.5px solid" + }, + { + "border-radius": "0.8vw" + }, + { + "box-shadow": "none" + }, + { + "transition": "0.5s" + }, + { + "height": "95px" + }, + { + "border-color": "[[[\n if (variables.value_select && entity.state==variables.value_select)\n return 'DeepSkyBlue'\n]]] \n" + } + ], + "name": [ + { + "font-size": "11px" + } + ], + "icon": [ + { + "width": "30px" + }, + { + "color": "[[[\n if (variables.value_select && entity.state==variables.value_select)\n return 'var(--switch-checked-button-color)'\n else\n return 'lightgray'\n]]] \n" + } + ] + }, + "hold_action": { + "action": "more-info" + }, + "tap_action": { + "action": "call-service", + "service": "input_select.select_option", + "service_data": { + "entity_id": "[[[ return entity.entity_id ]]]", + "option": "[[[ return variables.value_select ]]]" + } + } } - ] + } } } } \ No newline at end of file diff --git a/input_select/automation_selector.yaml b/input_select/automation_selector.yaml new file mode 100644 index 00000000..2b5ea19c --- /dev/null +++ b/input_select/automation_selector.yaml @@ -0,0 +1,17 @@ +###################################################################### +# Input Select: Automation Selector for lovelace panel +###################################################################### + +automation_selector: + name: Selettore Automazioni + options: + - Allarmi + - Luci + - Guardia + - Home Assistant + - Termosifoni + - Shelly + - Vacanza + - Zigbee2MQTT + initial: Luci + icon: mdi:cogs -- 2.47.3