From b93cb395d4769fbacc24d690e4a048b92ba3b81a Mon Sep 17 00:00:00 2001 From: "eelcob@hotmail.com" Date: Wed, 7 Apr 2021 10:12:15 +0200 Subject: [PATCH 1/3] Add support for graph type in the room-page_entities --- .../lovelace/views/main/rooms/room.yaml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/custom_components/dwains_dashboard/lovelace/views/main/rooms/room.yaml b/custom_components/dwains_dashboard/lovelace/views/main/rooms/room.yaml index 5c0e6ba3..2b8e94e7 100644 --- a/custom_components/dwains_dashboard/lovelace/views/main/rooms/room.yaml +++ b/custom_components/dwains_dashboard/lovelace/views/main/rooms/room.yaml @@ -862,9 +862,15 @@ item_classes: 'col-xs-12 col-sm-12 col-md-12 col-lg-12' {% endif %} {% for more_entity in room["page_entities"]["entities"] %} - - type: custom:button-card - entity: {{ more_entity["entity"] }} - template: room_more_entity + {% if more_entity["type"] and more_entity["type"] == 'graph' %} + - type: sensor + entity: {{ more_entity["entity"] }} + graph: line + {% else %} + - type: custom:button-card + entity: {{ more_entity["entity"] }} + template: room_more_entity + {% endif %} {% if more_entity["entity"].split('.')[0] in ('switch', 'light') %} tap_action: action: toggle From 7dd2a2fd800fa19a77eefeb07a717138d940515d Mon Sep 17 00:00:00 2001 From: "eelcob@hotmail.com" Date: Sun, 25 Apr 2021 10:33:10 +0200 Subject: [PATCH 2/3] make lights button in main menu configurable --- .../lovelace/views/main/02.lights.yaml | 351 +++++++++--------- 1 file changed, 179 insertions(+), 172 deletions(-) diff --git a/custom_components/dwains_dashboard/lovelace/views/main/02.lights.yaml b/custom_components/dwains_dashboard/lovelace/views/main/02.lights.yaml index 6737a79e..797a0b5f 100644 --- a/custom_components/dwains_dashboard/lovelace/views/main/02.lights.yaml +++ b/custom_components/dwains_dashboard/lovelace/views/main/02.lights.yaml @@ -1,172 +1,179 @@ -# dwains_dashboard - -- path: lights - icon: {{ _dd_icons.menu_lights|default('mdi:lightbulb-group') }} - title: {{ _dd_trans.all_lights.title }} - panel: true - cards: - - type: custom:dwains-wrapper-card - css: | - max-width: 1465px; - padding-bottom: 50px; - margin: 0 auto; - font-family: "Open Sans", sans-serif !important; - card: - type: vertical-stack - cards: - #Header with all lights on/off button - - type: custom:dwains-header-card - title: {{ _dd_trans.all_lights.title }} - card: - type: vertical-stack - cards: - - type: custom:button-card - template: lights_header_all_lights_toggle - icon: "{{ _dd_icons.light_on|default('mdi:lightbulb') }}" - tap_action: - haptic: light - action: call-service - service: homeassistant.turn_off - service_data: - entity_id: - #Get all lights - {% for room in _dd_config.rooms %} - {% if room["light"] %} - - {{ room["light"] }} - {% endif %} - {% endfor %} - styles: - card: - - padding-top: 16px - - display: > - [[[ - var onLights = 0; - - {% for room in _dd_config.rooms %} - //Do some things for the lights - {% if room["light"] %} - {% if room["light"].split('.')[0] == 'light' or room["light"].split('.')[0] == 'switch' %} - //This room has only 1 light - if(states['{{ room["light"] }}'] && states['{{ room["light"] }}'].state == 'on') { - onLights++; - } - {% else %} - //This room has group of lights - if(states['{{ room["light"] }}']){ - states['{{ room["light"] }}'].attributes['entity_id'].forEach(function(entity){ - if(states[entity] && states[entity].state == 'on'){ - onLights++; - } - }); - } - {% endif %} - {% endif %} - {% endfor %} - if(onLights == 0){ - return 'none'; - } else { - return 'block'; - } - ]]] - - type: custom:button-card - template: lights_header_all_lights_toggle - icon: "{{ _dd_icons.light_off|default('mdi:lightbulb-outline') }}" - tap_action: - haptic: light - action: call-service - service: homeassistant.turn_on - service_data: - entity_id: - #Get all lights - {% for room in _dd_config.rooms %} - {% if room["light"] %} - - {{ room["light"] }} - {% endif %} - {% endfor %} - styles: - card: - - display: > - [[[ - var onLights = 0; - - {% for room in _dd_config.rooms %} - //Do some things for the lights - {% if room["light"] %} - {% if room["light"].split('.')[0] == 'light' or room["light"].split('.')[0] == 'switch' %} - //This room has only 1 light - if(states['{{ room["light"] }}'] && states['{{ room["light"] }}'].state == 'on') { - onLights++; - } - {% else %} - //This room has group of lights - if(states['{{ room["light"] }}']){ - states['{{ room["light"] }}'].attributes['entity_id'].forEach(function(entity){ - if(states[entity] && states[entity].state == 'on'){ - onLights++; - } - }); - } - {% endif %} - {% endif %} - {% endfor %} - if(onLights == 0){ - return 'block'; - } else { - return 'none'; - } - ]]] - - #Start for all lights page - #All lights - - type: custom:dwains-flexbox-card - padding: true - items_classes: 'col-xs-12 col-sm-6 col-md-3 col-lg-3' - cards: - {% for room in _dd_config.rooms %} - {% if room["light"] %} - - type: vertical-stack - cards: - #Heading - - type: custom:button-card - entity: {{ room["light"] }} - name: {{ room["name"] }} - template: partials_heading - tap_action: - action: more-info - double_tap_action: - action: toggle - {% if room["light"].split('.')[0] == 'light' or room["light"].split('.')[0] == 'switch' %} - # this room has only 1 light (light or switch entity) - - type: horizontal-stack - cards: - - type: custom:button-card - template: room_light - entity: {{ room["light"] }} - {% if room["light"].split('.')[0] == 'light' %} - hold_action: - action: more-info - double_tap_action: - action: more-info - {% endif %} - {% else %} - # this room has group of lights - - type: custom:dwains-auto-entities-card - filter: - include: - - group: {{ room["light"] }} - options: - type: custom:button-card - template: room_light - hold_action: - action: more-info - double_tap_action: - action: more-info - sort: - method: name - ignore_case: true - card: - type: custom:dwains-flexbox-card - items_classes: 'col-xs-12' - {% endif %} - {% endif %} - {% endfor %} \ No newline at end of file +# dwains_dashboard + +- path: lights + {% if _dd_config.lights %} + {% if _dd_config.lights["main_menu"] and _dd_config.lights["main_menu"] == 'false' %} + visible: false + {% else %} + visible: true + {% endif %} + {% endif %} + icon: {{ _dd_icons.menu_lights|default('mdi:lightbulb-group') }} + title: {{ _dd_trans.all_lights.title }} + panel: true + cards: + - type: custom:dwains-wrapper-card + css: | + max-width: 1465px; + padding-bottom: 50px; + margin: 0 auto; + font-family: "Open Sans", sans-serif !important; + card: + type: vertical-stack + cards: + #Header with all lights on/off button + - type: custom:dwains-header-card + title: {{ _dd_trans.all_lights.title }} + card: + type: vertical-stack + cards: + - type: custom:button-card + template: lights_header_all_lights_toggle + icon: "{{ _dd_icons.light_on|default('mdi:lightbulb') }}" + tap_action: + haptic: light + action: call-service + service: homeassistant.turn_off + service_data: + entity_id: + #Get all lights + {% for room in _dd_config.rooms %} + {% if room["light"] %} + - {{ room["light"] }} + {% endif %} + {% endfor %} + styles: + card: + - padding-top: 16px + - display: > + [[[ + var onLights = 0; + + {% for room in _dd_config.rooms %} + //Do some things for the lights + {% if room["light"] %} + {% if room["light"].split('.')[0] == 'light' or room["light"].split('.')[0] == 'switch' %} + //This room has only 1 light + if(states['{{ room["light"] }}'] && states['{{ room["light"] }}'].state == 'on') { + onLights++; + } + {% else %} + //This room has group of lights + if(states['{{ room["light"] }}']){ + states['{{ room["light"] }}'].attributes['entity_id'].forEach(function(entity){ + if(states[entity] && states[entity].state == 'on'){ + onLights++; + } + }); + } + {% endif %} + {% endif %} + {% endfor %} + if(onLights == 0){ + return 'none'; + } else { + return 'block'; + } + ]]] + - type: custom:button-card + template: lights_header_all_lights_toggle + icon: "{{ _dd_icons.light_off|default('mdi:lightbulb-outline') }}" + tap_action: + haptic: light + action: call-service + service: homeassistant.turn_on + service_data: + entity_id: + #Get all lights + {% for room in _dd_config.rooms %} + {% if room["light"] %} + - {{ room["light"] }} + {% endif %} + {% endfor %} + styles: + card: + - display: > + [[[ + var onLights = 0; + + {% for room in _dd_config.rooms %} + //Do some things for the lights + {% if room["light"] %} + {% if room["light"].split('.')[0] == 'light' or room["light"].split('.')[0] == 'switch' %} + //This room has only 1 light + if(states['{{ room["light"] }}'] && states['{{ room["light"] }}'].state == 'on') { + onLights++; + } + {% else %} + //This room has group of lights + if(states['{{ room["light"] }}']){ + states['{{ room["light"] }}'].attributes['entity_id'].forEach(function(entity){ + if(states[entity] && states[entity].state == 'on'){ + onLights++; + } + }); + } + {% endif %} + {% endif %} + {% endfor %} + if(onLights == 0){ + return 'block'; + } else { + return 'none'; + } + ]]] + + #Start for all lights page + #All lights + - type: custom:dwains-flexbox-card + padding: true + items_classes: 'col-xs-12 col-sm-6 col-md-3 col-lg-3' + cards: + {% for room in _dd_config.rooms %} + {% if room["light"] %} + - type: vertical-stack + cards: + #Heading + - type: custom:button-card + entity: {{ room["light"] }} + name: {{ room["name"] }} + template: partials_heading + tap_action: + action: more-info + double_tap_action: + action: toggle + {% if room["light"].split('.')[0] == 'light' or room["light"].split('.')[0] == 'switch' %} + # this room has only 1 light (light or switch entity) + - type: horizontal-stack + cards: + - type: custom:button-card + template: room_light + entity: {{ room["light"] }} + {% if room["light"].split('.')[0] == 'light' %} + hold_action: + action: more-info + double_tap_action: + action: more-info + {% endif %} + {% else %} + # this room has group of lights + - type: custom:dwains-auto-entities-card + filter: + include: + - group: {{ room["light"] }} + options: + type: custom:button-card + template: room_light + hold_action: + action: more-info + double_tap_action: + action: more-info + sort: + method: name + ignore_case: true + card: + type: custom:dwains-flexbox-card + items_classes: 'col-xs-12' + {% endif %} + {% endif %} + {% endfor %} From 03b0cd7845a8cfdec43bcda453b57f4a77b321aa Mon Sep 17 00:00:00 2001 From: "eelcob@hotmail.com" Date: Sun, 25 Apr 2021 10:38:47 +0200 Subject: [PATCH 3/3] don't remove linebreaks --- .../lovelace/views/main/02.lights.yaml | 342 +++++++++--------- 1 file changed, 171 insertions(+), 171 deletions(-) diff --git a/custom_components/dwains_dashboard/lovelace/views/main/02.lights.yaml b/custom_components/dwains_dashboard/lovelace/views/main/02.lights.yaml index 797a0b5f..4060b4ae 100644 --- a/custom_components/dwains_dashboard/lovelace/views/main/02.lights.yaml +++ b/custom_components/dwains_dashboard/lovelace/views/main/02.lights.yaml @@ -1,6 +1,6 @@ -# dwains_dashboard - -- path: lights +# dwains_dashboard + +- path: lights {% if _dd_config.lights %} {% if _dd_config.lights["main_menu"] and _dd_config.lights["main_menu"] == 'false' %} visible: false @@ -8,172 +8,172 @@ visible: true {% endif %} {% endif %} - icon: {{ _dd_icons.menu_lights|default('mdi:lightbulb-group') }} - title: {{ _dd_trans.all_lights.title }} - panel: true - cards: - - type: custom:dwains-wrapper-card - css: | - max-width: 1465px; - padding-bottom: 50px; - margin: 0 auto; - font-family: "Open Sans", sans-serif !important; - card: - type: vertical-stack - cards: - #Header with all lights on/off button - - type: custom:dwains-header-card - title: {{ _dd_trans.all_lights.title }} - card: - type: vertical-stack - cards: - - type: custom:button-card - template: lights_header_all_lights_toggle - icon: "{{ _dd_icons.light_on|default('mdi:lightbulb') }}" - tap_action: - haptic: light - action: call-service - service: homeassistant.turn_off - service_data: - entity_id: - #Get all lights - {% for room in _dd_config.rooms %} - {% if room["light"] %} - - {{ room["light"] }} - {% endif %} - {% endfor %} - styles: - card: - - padding-top: 16px - - display: > - [[[ - var onLights = 0; - - {% for room in _dd_config.rooms %} - //Do some things for the lights - {% if room["light"] %} - {% if room["light"].split('.')[0] == 'light' or room["light"].split('.')[0] == 'switch' %} - //This room has only 1 light - if(states['{{ room["light"] }}'] && states['{{ room["light"] }}'].state == 'on') { - onLights++; - } - {% else %} - //This room has group of lights - if(states['{{ room["light"] }}']){ - states['{{ room["light"] }}'].attributes['entity_id'].forEach(function(entity){ - if(states[entity] && states[entity].state == 'on'){ - onLights++; - } - }); - } - {% endif %} - {% endif %} - {% endfor %} - if(onLights == 0){ - return 'none'; - } else { - return 'block'; - } - ]]] - - type: custom:button-card - template: lights_header_all_lights_toggle - icon: "{{ _dd_icons.light_off|default('mdi:lightbulb-outline') }}" - tap_action: - haptic: light - action: call-service - service: homeassistant.turn_on - service_data: - entity_id: - #Get all lights - {% for room in _dd_config.rooms %} - {% if room["light"] %} - - {{ room["light"] }} - {% endif %} - {% endfor %} - styles: - card: - - display: > - [[[ - var onLights = 0; - - {% for room in _dd_config.rooms %} - //Do some things for the lights - {% if room["light"] %} - {% if room["light"].split('.')[0] == 'light' or room["light"].split('.')[0] == 'switch' %} - //This room has only 1 light - if(states['{{ room["light"] }}'] && states['{{ room["light"] }}'].state == 'on') { - onLights++; - } - {% else %} - //This room has group of lights - if(states['{{ room["light"] }}']){ - states['{{ room["light"] }}'].attributes['entity_id'].forEach(function(entity){ - if(states[entity] && states[entity].state == 'on'){ - onLights++; - } - }); - } - {% endif %} - {% endif %} - {% endfor %} - if(onLights == 0){ - return 'block'; - } else { - return 'none'; - } - ]]] - - #Start for all lights page - #All lights - - type: custom:dwains-flexbox-card - padding: true - items_classes: 'col-xs-12 col-sm-6 col-md-3 col-lg-3' - cards: - {% for room in _dd_config.rooms %} - {% if room["light"] %} - - type: vertical-stack - cards: - #Heading - - type: custom:button-card - entity: {{ room["light"] }} - name: {{ room["name"] }} - template: partials_heading - tap_action: - action: more-info - double_tap_action: - action: toggle - {% if room["light"].split('.')[0] == 'light' or room["light"].split('.')[0] == 'switch' %} - # this room has only 1 light (light or switch entity) - - type: horizontal-stack - cards: - - type: custom:button-card - template: room_light - entity: {{ room["light"] }} - {% if room["light"].split('.')[0] == 'light' %} - hold_action: - action: more-info - double_tap_action: - action: more-info - {% endif %} - {% else %} - # this room has group of lights - - type: custom:dwains-auto-entities-card - filter: - include: - - group: {{ room["light"] }} - options: - type: custom:button-card - template: room_light - hold_action: - action: more-info - double_tap_action: - action: more-info - sort: - method: name - ignore_case: true - card: - type: custom:dwains-flexbox-card - items_classes: 'col-xs-12' - {% endif %} - {% endif %} + icon: {{ _dd_icons.menu_lights|default('mdi:lightbulb-group') }} + title: {{ _dd_trans.all_lights.title }} + panel: true + cards: + - type: custom:dwains-wrapper-card + css: | + max-width: 1465px; + padding-bottom: 50px; + margin: 0 auto; + font-family: "Open Sans", sans-serif !important; + card: + type: vertical-stack + cards: + #Header with all lights on/off button + - type: custom:dwains-header-card + title: {{ _dd_trans.all_lights.title }} + card: + type: vertical-stack + cards: + - type: custom:button-card + template: lights_header_all_lights_toggle + icon: "{{ _dd_icons.light_on|default('mdi:lightbulb') }}" + tap_action: + haptic: light + action: call-service + service: homeassistant.turn_off + service_data: + entity_id: + #Get all lights + {% for room in _dd_config.rooms %} + {% if room["light"] %} + - {{ room["light"] }} + {% endif %} + {% endfor %} + styles: + card: + - padding-top: 16px + - display: > + [[[ + var onLights = 0; + + {% for room in _dd_config.rooms %} + //Do some things for the lights + {% if room["light"] %} + {% if room["light"].split('.')[0] == 'light' or room["light"].split('.')[0] == 'switch' %} + //This room has only 1 light + if(states['{{ room["light"] }}'] && states['{{ room["light"] }}'].state == 'on') { + onLights++; + } + {% else %} + //This room has group of lights + if(states['{{ room["light"] }}']){ + states['{{ room["light"] }}'].attributes['entity_id'].forEach(function(entity){ + if(states[entity] && states[entity].state == 'on'){ + onLights++; + } + }); + } + {% endif %} + {% endif %} + {% endfor %} + if(onLights == 0){ + return 'none'; + } else { + return 'block'; + } + ]]] + - type: custom:button-card + template: lights_header_all_lights_toggle + icon: "{{ _dd_icons.light_off|default('mdi:lightbulb-outline') }}" + tap_action: + haptic: light + action: call-service + service: homeassistant.turn_on + service_data: + entity_id: + #Get all lights + {% for room in _dd_config.rooms %} + {% if room["light"] %} + - {{ room["light"] }} + {% endif %} + {% endfor %} + styles: + card: + - display: > + [[[ + var onLights = 0; + + {% for room in _dd_config.rooms %} + //Do some things for the lights + {% if room["light"] %} + {% if room["light"].split('.')[0] == 'light' or room["light"].split('.')[0] == 'switch' %} + //This room has only 1 light + if(states['{{ room["light"] }}'] && states['{{ room["light"] }}'].state == 'on') { + onLights++; + } + {% else %} + //This room has group of lights + if(states['{{ room["light"] }}']){ + states['{{ room["light"] }}'].attributes['entity_id'].forEach(function(entity){ + if(states[entity] && states[entity].state == 'on'){ + onLights++; + } + }); + } + {% endif %} + {% endif %} + {% endfor %} + if(onLights == 0){ + return 'block'; + } else { + return 'none'; + } + ]]] + + #Start for all lights page + #All lights + - type: custom:dwains-flexbox-card + padding: true + items_classes: 'col-xs-12 col-sm-6 col-md-3 col-lg-3' + cards: + {% for room in _dd_config.rooms %} + {% if room["light"] %} + - type: vertical-stack + cards: + #Heading + - type: custom:button-card + entity: {{ room["light"] }} + name: {{ room["name"] }} + template: partials_heading + tap_action: + action: more-info + double_tap_action: + action: toggle + {% if room["light"].split('.')[0] == 'light' or room["light"].split('.')[0] == 'switch' %} + # this room has only 1 light (light or switch entity) + - type: horizontal-stack + cards: + - type: custom:button-card + template: room_light + entity: {{ room["light"] }} + {% if room["light"].split('.')[0] == 'light' %} + hold_action: + action: more-info + double_tap_action: + action: more-info + {% endif %} + {% else %} + # this room has group of lights + - type: custom:dwains-auto-entities-card + filter: + include: + - group: {{ room["light"] }} + options: + type: custom:button-card + template: room_light + hold_action: + action: more-info + double_tap_action: + action: more-info + sort: + method: name + ignore_case: true + card: + type: custom:dwains-flexbox-card + items_classes: 'col-xs-12' + {% endif %} + {% endif %} {% endfor %}