Depechie
(Glenn Versweyveld)
1
I want to try to use out the waze travel time in a notification message.
So the Duration attributes ( which is in minutes and has decimals ).
I tried:
data_template:
title: "Home Assistant"
message: "{{ states('sensor.work_to_home.duration') }}"
But I get unknown and
data_template:
title: "Home Assistant"
message: "{{ states('sensor.work_to_home.duration') | int | timestamp_custom('%H:%M:%S', 0) }}"
Always gives 00 00
So any tips or examples on how to get the data and nicely format this?
The states()
function takes one parameter, which is an entity_id. sensor.work_to_home.duration
is not a valid entity_id. sensor.work_to_home
is.
You can do:
data_template:
title: "Home Assistant"
message: "{{ states('sensor.work_to_home') }}"
or:
data_template:
title: "Home Assistant"
message: "{{ state_attr('sensor.work_to_home', 'duration') }}"
Both will show minutes. If you want HH:MM, then:
data_template:
title: "Home Assistant"
message: "{{ states('sensor.work_to_home')|int|multiply(60)|timestamp_custom('%H:%M', false) }}"
or:
data_template:
title: "Home Assistant"
message: "{{ state_attr('sensor.work_to_home', 'duration')|multiply(60)|timestamp_custom('%H:%M', false) }}"
Depechie
(Glenn Versweyveld)
3
Haa I see! Ok thx @pnbruckner for the clarification! Will try your samples as soon as I’m back at my home assistant