I am trying to use home assistant to pull a list of events for the next day in my calendar, then for each calendar event pull the location and calculate driving distance using Waze Travel Time, then return the one with the longest distance to determine my charge limit for my electric vehicle.
I seem to be in a egg first or chicken first dilemma… The only way I know to handle a list of calendar locations is using template within a service, like in this example
service: notify.nina
data:
title: Daily agenda for {{ now().date() }}
message: >-
Your school calendar for today:
{% for event in agenda["calendar.school_calendar"]["events"] %}
{{ event.start}}: {{ event.summary }}<br>
{% endfor %}
Your work calendar for today:
{% for event in agenda["calendar.work_calendar"]["events"] %}
{{ event.start}}: {{ event.summary }}<br>
{% endfor %}
But in order to pull the address out for Waze Travel time I have to do a service call to save it into an input_text or sensor, then somehow record the distance attribute from Waze Travel Time before moving on to the next event int he foreach loop. I simply do not know how to make all these service calls which is within a value template of another service call?
This is my pseudo-code:
- get calendar events into response variable *agenda*
- set input_number.distance to 0
- for each event in *agenda*
- use input_text.set_value to save location from *agenda*
- if Waze Travel time is greater than input_number.distance, set input_number.distance to current distance from Waze Travel Time
- when greatest input_number.distance is determined, set charge limit with a value_template of if/elseif loop to the desired value
Can someone provide some insights? Thanks!
1 post - 1 participant