Open jcallaghan opened 4 years ago
Here is the thread on I shared on Twitter when I created this back in March.
Change these according the calendar.
{% set event_name = state_attr('calendar.florence_pickup','message') %}
{% set event_time = state_attr('sensor.calendar_florence_pickup','start_time') %}
{% set event_location = states('sensor.calendar_florence_pickup_location') %}
{% set james_time_to_event_location = states('sensor.james_to_florence_pickup_location') | int %}
{% set trip_distance = state_attr('sensor.james_to_florence_pickup_location','distance') | round(1) %}
Change these based on your preference.
{% set buffer_time = states('input_number.pick_up_reminder_buffer_time') | int %}
{% set buffer_time_tts = 10 %}
{% set buffer_time_refuel = 15 %}
{% set buffer_refuel_miles = 10 %}
It is unlikely you will need to change these.
{% set buffer_refuel_range = trip_distance + buffer_refuel_miles %}
{% set fuel_level = states('sensor.xxxxxx_fuel_level') | round(1) %}
{% set fuel_range = states('sensor.xxxxxx_range_imperial') | round(1) %}
{% set battery_level = states('sensor.xxxxxx_battery_level') | round(1) %}
{% set battery_range = states('sensor.xxxxxx_battery_range_imperial') | round(1) %}
{% set eta = (as_timestamp(now()) + ((james_time_to_event_location + buffer_time) * 60)) | timestamp_custom('%H:%M', True) %}
{% set etd_with_refuel = (as_timestamp(event_time) - (james_time_to_event_location + buffer_time + buffer_time_refuel) * 60) | timestamp_custom('%H:%M', True) %}
{% set etd = (as_timestamp(event_time) - (james_time_to_event_location + buffer_time) * 60) | timestamp_custom('%H:%M', True) %}
{% set tts_time_with_refuel = (as_timestamp(event_time) - (james_time_to_event_location + buffer_time + buffer_time_refuel + buffer_time_tts) * 60) | timestamp_custom('%H:%M', True) %}
{% set tts_time = (as_timestamp(event_time) - (james_time_to_event_location + buffer_time + buffer_time_tts) * 60) | timestamp_custom('%H:%M', True) %}
Pick-up location
{{ event_location }}
Time:
{{ states('sensor.time') }}
Pick-up date and time:
{{ event_time }}
Pick-up time:
{{ as_timestamp(event_time) | timestamp_custom('%H:%M', True) }}
James to pick up location via Waze:
{{ james_time_to_event_location }} minutes
Buffer time:
{{ buffer_time }} minutes
Leave time (pick-up time minus travel time plus slippage)
{{ (as_timestamp(event_time) - (james_time_to_event_location + buffer_time) * 60) | timestamp_custom('%H:%M', False) }}
Car fuel:
{{ fuel_level }}% ({{ fuel_range }} miles)
Car battery:
{{ battery_level }}% ({{ battery_range }} miles)
Trip info:
You need to leave for event: {{ event_name }}.
This trip is {{ trip_distance }} miles and you have a range of {{ fuel_range }} miles.
It will likely take you {{ james_time_to_event_location }} minutes. Your ETA is {{ eta }}.
Extra time to get fuel:
{% if fuel_range <= buffer_refuel_range -%}
Your fuel is at {{ fuel_level }}% so I've added 15 minutes onto your journey time to get fuel.
{%- else -%}
You have good {{ fuel_level }}% of fuel with a range of {{ fuel_range }} miles.
{%- endif %}
Leave time (pick-up time minus travel time plus slippage and time for fuel if needed)
{%- if fuel_range <= buffer_refuel_range -%}
{{ etd_with_refuel }}
{%- else %}
{{ etd }}
{%- endif %}
TTS 10 minutes ahead of time to leave
{% if fuel_level <= buffer_refuel_range -%}
{{ tts_time_with_refuel }}
{%- else %}
{{ tts_time }}
{%- endif %}
Ambient temperature:
{{ states('sensor.weather_station_temperature') }}°C
* This is at home, could look for dynamic weather based on person.james location.
In the Volvo app there is parking climate available.
Automation trigger:
{%- if fuel_range <= buffer_refuel_range -%}
{{ states('sensor.time') == tts_time_with_refuel }}
{%- else %}
{{ states('sensor.time') == tts_time }}
{%- endif %}
Pick-up location
xxxxxx, UK
Time:
16:36
Pick-up date and time:
2020-07-22 14:50:00
Pick-up time:
14:50
James to pick up location via Waze:
54 minutes
Buffer time:
10 minutes
Leave time (pick-up time minus travel time plus slippage)
12:46
Car fuel:
24.0% (110.0 miles)
Car battery:
73.0% (15.0 miles)
Trip info:
You need to leave for event: Pick-up Florence.
This trip is 27.5 miles and you have a range of 110.0 miles.
It will likely take you 54 minutes. Your ETA is 17:40.
Extra time to get fuel:
You have good 24.0% of fuel with a range of 110.0 miles.
Leave time (pick-up time minus travel time plus slippage and time for fuel if needed)
13:46
TTS 10 minutes ahead of time to leave
13:21
Ambient temperature:
18.8°C
* This is at home, could look for dynamic weather based on person.james location.
In the Volvo app there is parking climate available.
Automation trigger:
False
To help manage the variables I created some input_numer
helpers that allow me to expose these variables in the UI. This makes it much easier to change these later.
For each calendar that needs time to leave reminders on, I will duplicate following.
//TODO check if calendar query is valid after adding an OR get dynamic Waze journey time down - it is taking a longer route optimise message for the device they are being sent to check if this is working on pick-up / drop-off events
Objective
I use my calendar to remind me to travel. While the journey is often consistent, the journey time varies. I'm also an "I'd rather be an hour early than a minute late" kind of guy.
So my plan is to create an automation that integrates with my calendar and these events along with the Waze travel API to notify me when I need to leave to arrive on time given the traffic conditions.
Ideas
Related: Volvo #78