From 47b4d3d933b796713a932ca5e57364a11242d722 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Lov=C3=A9n?= Date: Wed, 30 Oct 2019 14:15:45 +0100 Subject: [PATCH] Modernize lovelace code for lovelace_gen, hacs --- lovelace/coffee_card.yaml | 17 ++++++-- lovelace/floorplan.yaml | 3 ++ lovelace/resources.yaml | 18 ++++----- lovelace/timeofday_card.yaml | 6 +-- lovelace/views/dashboard_view.yaml | 63 ++---------------------------- lovelace/views/dev_view.yaml | 24 ++++++++++-- lovelace/views/diverse_view.yaml | 14 ++++--- lovelace/views/security_view.yaml | 8 ++-- 8 files changed, 64 insertions(+), 89 deletions(-) diff --git a/lovelace/coffee_card.yaml b/lovelace/coffee_card.yaml index 96095d1..94e32e0 100644 --- a/lovelace/coffee_card.yaml +++ b/lovelace/coffee_card.yaml @@ -11,9 +11,18 @@ entities: entity: switch.kaffebryggare icon: mdi:coffee items: - - input_boolean.cfe_on - - type: custom:time-input-row - entity: input_datetime.cfe_on + - entity: input_boolean.cfe_on + style: | + :host { + --paper-item-icon-color: {% if is_state(config.entity, 'on') %} var(--paper-item-active-color) {% else %} var(--paper-item-color) {% endif %}; + } + + - entity: input_datetime.cfe_on - type: section - - input_boolean.cfe_off + - entity: input_boolean.cfe_off + debug_cardmod: true + style: | + :host { + --paper-item-icon-color: {% if is_state(config.entity, 'on') %} var(--paper-item-active-color) {% else %} var(--paper-item-color) {% endif %}; + } - input_number.cfe_off diff --git a/lovelace/floorplan.yaml b/lovelace/floorplan.yaml index a3a20c8..837dcc7 100644 --- a/lovelace/floorplan.yaml +++ b/lovelace/floorplan.yaml @@ -1,3 +1,4 @@ +# lovelace_gen type: picture-elements image: !file /local/images/Bottenvåning.png elements: @@ -38,6 +39,7 @@ elements: {{ dimlamp('light.taklampa_kontoret', 82, 68) }} {{ lamp('light.kontor_fonster', 83, 87) }} {{ dimlamp('light.skrivbordslampa_1', 88, 58) }} + {{ badge('sensor.kontoret_temperature', 82, 80) }} # Lilla hallen {{ dimlamp('light.lilla_hallen', 72, 53) }} @@ -76,6 +78,7 @@ elements: {{ icon('switch.ventilation', 27, 20) }} # Utomhus + {{ badge('sensor.utomhus_temp', 5, 10) }} {{ dimlamp('light.baksida', 35, 5) }} {{ dimlamp('light.mellangang', 10, 30) }} {{ dimlamp('light.uppfart', 5, 94) }} diff --git a/lovelace/resources.yaml b/lovelace/resources.yaml index 9e32808..b8fb762 100644 --- a/lovelace/resources.yaml +++ b/lovelace/resources.yaml @@ -1,19 +1,11 @@ +# lovelace_gen + - url: !file /local/lovelace-card-tools/card-tools.js type: js -- url: !file /local/lovelace-fold-entity-row/fold-entity-row.js - type: js -- url: !file /local/lovelace-time-input-row/time-input-row.js - type: js -- url: !file /local/lovelace-popup-card/popup-card.js - type: js -- url: !file /local/lovelace-slider-entity-row/slider-entity-row.js - type: js - url: !file /local/lovelace-auto-entities/auto-entities.js type: js - url: !file /local/lovelace-layout-card/layout-card.js type: js -- url: !file /local/lovelace-useful-markdown-card/useful-markdown-card.js - type: module # Specially modified by helto # https://github.com/helto4real/hassio/tree/master/www/custom_cards @@ -22,3 +14,9 @@ - url: !file /local/more-info-card.js type: js + + # Plugins installed through HACS +- url: !file /local/community/lovelace-card-mod/card-mod.js + type: module +- url: !file /local/community/lovelace-fold-entity-row/fold-entity-row.js + type: module diff --git a/lovelace/timeofday_card.yaml b/lovelace/timeofday_card.yaml index ce19ee8..9205db9 100644 --- a/lovelace/timeofday_card.yaml +++ b/lovelace/timeofday_card.yaml @@ -6,22 +6,20 @@ entities: name: Tid - entity: sensor.date name: Datum + - entity: sensor.week + name: Vecka - type: section label: Tid på dygnet - entity: input_select.tod name: ' ' - entity: input_datetime.tod_morning name: Morgon - type: custom:time-input-row - entity: input_datetime.tod_day name: Dag - type: custom:time-input-row - entity: input_datetime.tod_evening name: Kväll - type: custom:time-input-row - entity: input_datetime.tod_night name: Natt - type: custom:time-input-row - type: section - entity: switch.tod_dark diff --git a/lovelace/views/dashboard_view.yaml b/lovelace/views/dashboard_view.yaml index 784714a..d65e481 100644 --- a/lovelace/views/dashboard_view.yaml +++ b/lovelace/views/dashboard_view.yaml @@ -2,62 +2,6 @@ title: Dashboard path: dashboard icon: mdi:home-assistant panel: true -popup_cards: - vacuum.xiaomi_vacuum_cleaner: - title: Dammsugare - card: !include vacuum_card.yaml - - binary_sensor.door_open: - title: Öppna dörrar - card: - type: vertical-stack - cards: - - type: entities - entities: &door_entities - - binary_sensor.hall_ytterdorr - - binary_sensor.tvattstuga_ytterdorr - - binary_sensor.vardagsrum_ytterdorr - - binary_sensor.sovrum_ytterdorr - - type: history-graph - entities: *door_entities - - device_tracker.thomas_presence: - title: Thomas - large: true - card: - type: vertical-stack - cards: - - type: entities - entities: &thomas_entities - - device_tracker.thomas_iphone_beta - - device_tracker.thomas_iphone_2 - - sensor.thomas_iphone_bt - - sensor.thomas_iphone_bt2 - - type: history-graph - entities: - - device_tracker.thomas_presence - - type: history-graph - entities: *thomas_entities - - device_tracker.anneli_presence: - title: Anneli - large: true - card: - type: vertical-stack - cards: - - type: entities - entities: &anneli_entities - - device_tracker.anneli_lovn - - device_tracker.anneli_loven - - sensor.anneli_iphone_bt - - sensor.anneli_iphone_bt2 - - sensor.anneli_klocka_bt - - sensor.anneli_klocka_bt2 - - type: history-graph - entities: - - device_tracker.anneli_presence - - type: history-graph - entities: *anneli_entities cards: - type: custom:layout-card layout: vertical @@ -87,7 +31,7 @@ cards: max_width: 960 layout: vertical cards: - - type: custom:useful-markdown-card + - type: markdown style: | ha-card { padding-top: 24px; @@ -95,13 +39,14 @@ cards: h1 { text-align: center; font-size: 6em; + margin-bottom: 0; } h2 { text-align: center; } content: | - # [[ sensor.time ]] - ## [[ sensor.date ]] + # {{ states("sensor.time") }} + ## {{ states("sensor.date") }} V.{{ states("sensor.week") }} - type: custom:weather-card entity: weather.smhi_home icons: /local/weather_icons/ diff --git a/lovelace/views/dev_view.yaml b/lovelace/views/dev_view.yaml index fdd9885..a51190e 100644 --- a/lovelace/views/dev_view.yaml +++ b/lovelace/views/dev_view.yaml @@ -6,10 +6,9 @@ cards: - type: custom:layout-card rebuild: 1000 cards: - - !include dev_card.yaml - - !include timeofday_card.yaml + - !include ../timeofday_card.yaml - type: custom:browser-player - - !include local_services.hidden.yaml + - !include ../local_services.hidden.yaml - type: custom:auto-entities card: type: entities @@ -17,6 +16,9 @@ cards: filter: include: - state: "unavailable" + exclude: + - attributes: + type: browser_mod - type: custom:auto-entities card: type: entities @@ -51,6 +53,9 @@ cards: - domain: switch options: secondary_info: entity-id + exclude: + - attributes: + type: browser_mod - type: custom:auto-entities card: type: entities @@ -61,6 +66,19 @@ cards: device_class: "battery" options: secondary_info: entity-id + style: | + {% if state_attr(config.entity, 'unit_of_measurement') == "%" %} + :host { + --paper-item-icon-color: + {% if states(config.entity)|float < 25 %} + red + {% elif states(config.entity)|float < 40 %} + orange + {% else %} + var(--text-light-color) + {% endif %}; + } + {% endif %} - type: custom:auto-entities card: type: entities diff --git a/lovelace/views/diverse_view.yaml b/lovelace/views/diverse_view.yaml index f0b44be..bf94c78 100644 --- a/lovelace/views/diverse_view.yaml +++ b/lovelace/views/diverse_view.yaml @@ -1,8 +1,12 @@ title: Diverse icon: mdi:home-assistant cards: - - !include floorplan.yaml {"no_other":"true"} - - !include floorplan.yaml {"no_light":"true"} - - !include coffee_card.yaml - - !include temperatures_card.yaml - - !include power_card.yaml + - !include + - /config/lovelace/floorplan.yaml + - {"no_other":"true"} + - !include + - /config/lovelace/floorplan.yaml + - {"no_light":"true"} + - !include /config/lovelace/coffee_card.yaml + - !include /config/lovelace/temperatures_card.yaml + - !include /config/lovelace/power_card.yaml diff --git a/lovelace/views/security_view.yaml b/lovelace/views/security_view.yaml index 5ef1552..15c706d 100644 --- a/lovelace/views/security_view.yaml +++ b/lovelace/views/security_view.yaml @@ -1,10 +1,10 @@ title: Security icon: mdi:shield-home cards: - - !include cameras/barnrum.yaml - - !include cameras/kontor.yaml - - !include cameras/vardagsrum.yaml - - !include cameras/hallen.yaml + - !include /config/lovelace/cameras/barnrum.yaml + - !include /config/lovelace/cameras/kontor.yaml + - !include /config/lovelace/cameras/vardagsrum.yaml + - !include /config/lovelace/cameras/hallen.yaml - type: entities entities: - type: custom:hui-glance-card