Created file lovelace-ui.yaml,
/config/lovelace-ui.yaml
resources:
- url: /local/decluttering-card.js
type: module
decluttering_templates:
air_purifier_control_button_template:
card:
color: 'rgba(255, 255, 255, 0)'
color_type: card
icon: 'mdi:[[icon]]'
state:
- operator: template
styles:
card:
- color: var(--primary-color)
value: |
[[[ return [[condition]] ]]]
- operator: default
styles:
card:
- color: 'rgba(150,150,150, 1.0)'
styles:
card:
- height: 50px
- color: 'rgba(150, 150, 150, 1.0)'
- box-shadow: none
tap_action:
action: call-service
service: '[[svc_name]]'
service_data: '[[svc_data]]'
type: 'custom:button-card'
air_purifier_status_button_template:
card:
color: 'rgba(255, 255, 255, 0)'
color_type: card
entity: '[[entity]]'
show_icon: false
show_name: true
show_state: true
size: 30%
styles:
card:
- height: 70px
- box-shadow: none
- padding: 8% 0px 4% 0px
grid:
- grid-template-areas: '"s" "n"'
name:
- color: var(--primary-text-color)
- font-size: 15px
- align-self: start
state:
- color: var(--primary-text-color)
- padding-left: 10px
- font-size: 20px
- font-weight: bold
- align-self: end
tap_action:
action: '[[action]]'
type: 'custom:button-card'
Сreate a manual card
cards:
- cards:
- template: air_purifier_status_button_template
type: 'custom:decluttering-card'
variables:
- entity: sensor.air_purifier_filter_remaining
- action: none
- template: air_purifier_status_button_template
type: 'custom:decluttering-card'
variables:
- entity: sensor.air_purifier_motor_speed
- action: none
type: horizontal-stack
- cards:
- template: air_purifier_control_button_template
type: 'custom:decluttering-card'
variables:
- icon: power-standby
- condition: 'states[''fan.xiaomi_miio_device''].state === ''on'''
- svc_name: fan.toggle
- svc_data:
entity_id: fan.xiaomi_miio_device
- template: air_purifier_control_button_template
type: 'custom:decluttering-card'
variables:
- icon: weather-night
- condition: 'states[''fan.xiaomi_miio_device''].attributes.speed === ''Silent'''
- svc_name: fan.set_speed
- svc_data:
entity_id: fan.xiaomi_miio_device
speed: Silent
- template: air_purifier_control_button_template
type: 'custom:decluttering-card'
variables:
- icon: circle-slice-3
- condition: >-
(states['fan.xiaomi_miio_device'].attributes.speed === 'Favorite'
&& states['fan.xiaomi_miio_device'].attributes.favorite_level ==
4)
- svc_name: script.air_purifier_set_favorite
- svc_data:
fav_level: 4
- template: air_purifier_control_button_template
type: 'custom:decluttering-card'
variables:
- icon: circle-slice-4
- condition: >-
(states['fan.xiaomi_miio_device'].attributes.speed === 'Favorite'
&& states['fan.xiaomi_miio_device'].attributes.favorite_level ==
8)
- svc_name: script.air_purifier_set_favorite
- svc_data:
fav_level: 8
- template: air_purifier_control_button_template
type: 'custom:decluttering-card'
variables:
- icon: circle-slice-6
- condition: >-
(states['fan.xiaomi_miio_device'].attributes.speed === 'Favorite'
&& states['fan.xiaomi_miio_device'].attributes.favorite_level ==
12)
- svc_name: script.air_purifier_set_favorite
- svc_data:
fav_level: 12
- template: air_purifier_control_button_template
type: 'custom:decluttering-card'
variables:
- icon: circle-slice-8
- condition: >-
(states['fan.xiaomi_miio_device'].attributes.speed === 'Favorite'
&& states['fan.xiaomi_miio_device'].attributes.favorite_level ==
16)
- svc_name: script.air_purifier_set_favorite
- svc_data:
fav_level: 16
- template: air_purifier_control_button_template
type: 'custom:decluttering-card'
variables:
- icon: brightness-auto
- condition: 'states[''fan.xiaomi_miio_device''].attributes.speed === ''Auto'''
- svc_name: fan.set_speed
- svc_data:
entity_id: fan.xiaomi_miio_device
speed: Auto
type: horizontal-stack
type: 'custom:vertical-stack-in-card'
Still no display. What am I doing wrong?