I have the following button on my dashboard.
Pressing it activates a specific scene. that scene is also triggered by time. (scene.living_room_scene_3)
The time the trigger is activated is defined in a time helper (input_datetime.starttime_scene3)
type: custom:config-template-card
variables:
- "'Scene 3 ('"
- states['input_datetime.starttime_scene3'].state
- "')'"
entities:
- scene.living_room_scene_3
card:
type: tile
tap_action:
action: toggle
entity: scene.living_room_scene_3
name: ${vars[0] + vars[1] + vars[2]}
hold_action:
action: none
icon: mdi:lamps-outline
vertical: false
hide_state: true
In the button I want to show what time the scene will be activated: Scene 3 (21:00:00)
This works, but shows the time in hh:mm:ss. I want to hide the seconds.
I have been trying to achieve this by changing the template, but this breaks the yaml.
state_attr('input_datetime.starttime_scene3', 'timestamp') | timestamp_custom('%H:%M', false)
Is this even possible to do?
There may be other ways, but you could always template the timestamp as a sensor.
Example with my devices
type: custom:config-template-card
variables:
- "'Scene 3 ('"
- states['sensor.time_sensor'].state
- "')'"
entities:
- scene.living_room_scene_3
card:
type: tile
tap_action:
action: toggle
entity: scene.living_room_scene_3
name: ${vars[0] + vars[1] + vars[2]}
hold_action:
action: none
icon: mdi:lamps-outline
vertical: false
hide_state: true
LiQuid_cOOled:
sensor.time_sensor
Should be added to “entities” too. Otherwise will not be “monitored”.
1 Like
Thank you, forgot about that…
Also, there is no need to place static strings into variables.
Ildar’s advice is correct
variables:
- states['sensor.time_sensor'].state
name: ${"Scene 3 ("+ vars[0]+ ")"}
I’d also look into Mushroom Cards that are Tile based.
type: custom:mushroom-template-card
primary: >-
Scene 3 ({{state_attr('input_datetime.test', 'timestamp') |
timestamp_custom('%H:%M', false)}})
secondary: ""
icon: mdi:timelapse
icon_color: green
Also, in latest beta it should be possible using
name: Scene 3 (${vars[0]})
I tried to template the time helper as a sensor. but this returned ‘false’ when I try to add the new template to the button
i see it in my entities when i added the helper template? So what do you exactly mean with add to entities?
Did you go to Helpers and select Template?
Then template a Sensor
Then enter
state_attr('input_datetime.starttime_scene3', 'timestamp') | timestamp_custom('%H:%M', false)
Thanks so much, this works! Seems I accidentally selected ‘binary sensor’ instead of ‘sensor’. Lesson learned: Never program before coffee
1 Like