Cool! This will help me. How hard would it be to generate a TTS at the time of the appointment - travel time? This is basically what I’m trying to achieve at this thread here…
Aren’t you supposed to use “duration_in_traffic” instead of “duration” for a more accurate calculation?
Does this script also work for durations less than 1 hour?
That’s rather easy actualy, this is part of my script for a “morning Briefing TTS”:
commute_time_to_work:
alias: Commute time to work
sequence:
- alias: Speech Output
service: tts.google_say
entity_id: media_player.cc_audio
data_template:
message: 'Goodmorning. The outside temperature is now {{ states.sensor.dark_sky_temperature.state }} degrees celcius. The current commute time to work is {{ states.sensor.google_travel_time__driving.state }} minutes by car.'
cache: false
Next step is to give me a heads-up when I need to leave to arrive on time, based on traffic conditions.
Goal: I have set up a wake-up light automation and included a sensor in the group which shows the current alarm time set (adjustable by minutes and hour sliders).
I want to add a sensor (?) which shows to time left untill my next alarm. The problem is that it looks like that the alarmtime is seen as a string of characters instead of a timestamp. Therefore I can’t use them in calculations.
In my automation I use the following data_template as trigger for my alarm (20 minutes before wakeup time):
@GMFalka@ih8gates
Hey, I was able to make this work for < 1hour driving times! Just added a couple if statements to check if the string starts with hour(s), otherwise use only the minutes for the calculation.
{% if is_state("states.sensor.home_commute.attributes.duration_in_traffic.split(" ")[1]", "hour") or is_state("states.sensor.home_commute.attributes.duration_in_traffic.split(" ")[1]", "hours") -%}
{{ (as_timestamp(now()) + states.sensor.home_commute.attributes.duration_in_traffic.split(" ")[0] | int *3600 + states.sensor.home_commute.attributes.duration_in_traffic.split(" ")[2] | int *60 | int) | timestamp_custom("%I:%M %p")}}
{%- else -%}
{{ (as_timestamp(now()) + states.sensor.home_commute.attributes.duration_in_traffic.split(" ")[0] | int *60) | timestamp_custom("%I:%M %p")}}
{%- endif %}
I’ve been unsuccessfully trying to find the solution to this for what feels like an eternity, and this thread finally got me the results I was looking for, so THANK YOU ALL!
I am trying to do something similar, but have not found a solution so far …
I want to use a calculated delay in an automation, but have no idea how to do it …
Wonder if anyone can help me with the following I want to have a count down timer to display in (Hours : Min ) a leaving time eg: " that it looks at the traffic conditions and alters the time "sensor.google_travel_time__driving - the current time " so it outputs time to leave in 20 min,19min,18min 17min ect down to 0 min " being struggling for days if anyone has any suggestions
This is the closest i have come {{strptime(“07:15”, “%H:%M”) - strptime(states.sensor.total_travel_time_now.state, “%M”) }} that outputs 06:57:00 not the desired 20min,19min 18min ect every way i have trided just gives me no results
need some help with time please.
im trying to work out the “total time” (so end - start)
however I keep getting an error when i try and subtract the values?
maybe because the “time” is only in “hours:min”?