nasgul
April 7, 2019, 7:18am
1
I am trying to setup a glance card with a dynamic title which would reflect state of an entity.
The entity is input_select.status and can have Values Normal or Away.
I would like the Card title to be. Home Status : Away
The code below is not getting me anywhere
- type: glance
title: $('home status' + {{'state.input_select.status'}} )
show_name: true
show_state: false
columns: 6
entities:
- entity: input_select.status
name: Normal
icon: mdi:car
tap_action:
action: call-service
service: script.set_normal_mode
- entity: input_select.status
name: Away
tap_action:
action: call-service
service: script.set_away_mode
tom_l
April 7, 2019, 7:23am
2
You’re going to need a custom card (card-modder): https://github.com/thomasloven/lovelace-card-modder#templates
Not sure if this applies to the title but see no reason why it shouldn’t.
The custom template card might do it too.
theOrakle
(The Orakle)
April 26, 2019, 2:12am
4
Did you ever find a solution?
Here is what I did for mine - but would love to have the title say what is currently set.
type: entity-filter
card:
type: glance
title: Presence
show_state: false
entities:
- type: entity-button
name: "Set to home"
icon: mdi:home-account
entity: script.home
tap_action:
action: call-service
service: script.turn_on
service_data:
entity_id: script.home
- type: entity-button
name: "Set to night"
icon: mdi:weather-night
entity: script.night
tap_action:
action: call-service
service: script.turn_on
service_data:
entity_id: script.night
- type: entity-button
name: "Set to away"
icon: mdi:car
entity: script.away
tap_action:
action: call-service
service: script.turn_on
service_data:
entity_id: script.away
state_filter:
- "off"
Then, the scripts look like this:
home:
alias: Home
sequence:
- service: switch.turn_off
entity_id: switch.syno_mode
- service: rest_command.set_vera_home
- delay: '00:01:00'
- wait_template: "{{ not is_state('sensor.vera_mode', '1') }}"
away:
alias: Away
sequence:
- service: light.turn_off
entity_id:
- light.b_hue_counter
- light.b_hue_trophy
- light.k_hue_sink
- service: rest_command.set_vera_away
- delay: '00:05:00'
- service: switch.turn_on
entity_id: switch.syno_mode
- wait_template: "{{ not is_state('sensor.vera_mode', '2') }}"
night:
alias: Night
sequence:
- service: light.turn_off
entity_id:
- light.b_hue_counter
- light.b_hue_trophy
- light.k_hue_sink
- service: rest_command.set_vera_night
- delay: '00:05:00'
- service: switch.turn_on
entity_id: switch.syno_mode
- wait_template: "{{ not is_state('sensor.vera_mode', '3') }}"
While a bit convoluted (and only viable for smaller things) it could be done without a script by using Conditional cards.
By smaller things I mean, stuff where you don’t need the exact state value, but rather want to display something based on that value. Example: If state = away display Card with title ‘Status: Away’ and hide the others.
Here’s 3 buttons, the middle button changes title (and what it does) based on vacuum’s state. It should give you a rough idea.
cards:
- entity: vacuum.xiaomi_vacuum_cleaner
name: Spot Clean
show_icon: true
show_name: true
tap_action:
action: call-service
service: vacuum.clean_spot
type: entity-button
- card:
entity: vacuum.xiaomi_vacuum_cleaner
name: Resume Cleaning
show_icon: true
show_name: true
tap_action:
action: call-service
service: vacuum.start
type: entity-button
conditions:
- entity: vacuum.xiaomi_vacuum_cleaner
state_not: cleaning
- entity: vacuum.xiaomi_vacuum_cleaner
state_not: docked
- entity: vacuum.xiaomi_vacuum_cleaner
state_not: error
- entity: vacuum.xiaomi_vacuum_cleaner
state_not: returning
type: conditional
- card:
entity: vacuum.xiaomi_vacuum_cleaner
name: Pause
show_icon: true
show_name: true
tap_action:
action: call-service
service: vacuum.pause
type: entity-button
conditions:
- entity: vacuum.xiaomi_vacuum_cleaner
state_not: paused
- entity: vacuum.xiaomi_vacuum_cleaner
state_not: docked
- entity: vacuum.xiaomi_vacuum_cleaner
state_not: idle
- entity: vacuum.xiaomi_vacuum_cleaner
state_not: error
type: conditional
- card:
entity: vacuum.xiaomi_vacuum_cleaner
show_icon: true
show_name: false
tap_action:
action: null
type: entity-button
conditions:
- entity: vacuum.xiaomi_vacuum_cleaner
state_not: cleaning
- entity: vacuum.xiaomi_vacuum_cleaner
state_not: returning
- entity: vacuum.xiaomi_vacuum_cleaner
state_not: paused
- entity: vacuum.xiaomi_vacuum_cleaner
state_not: idle
type: conditional
- entity: vacuum.xiaomi_vacuum_cleaner
name: Dock
show_icon: true
show_name: true
tap_action:
action: call-service
service: vacuum.return_to_base
type: entity-button
type: horizontal-stack