Created
September 24, 2023 22:35
-
-
Save tronikos/f357786197e05a9f2a367363fa645909 to your computer and use it in GitHub Desktop.
Calendar: Notify: family event with location
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alias: "Calendar: Notify: family event with location" | |
description: "" | |
trigger: | |
- platform: calendar | |
event: start | |
offset: "-1:31:0" | |
entity_id: calendar.family | |
id: start | |
- platform: calendar | |
event: start | |
offset: "-1:16:0" | |
entity_id: calendar.family | |
id: start | |
- platform: calendar | |
event: start | |
offset: "-1:1:0" | |
entity_id: calendar.family | |
id: start | |
- platform: calendar | |
event: start | |
offset: "-0:46:0" | |
entity_id: calendar.family | |
id: start | |
- platform: calendar | |
event: start | |
offset: "-0:31:0" | |
entity_id: calendar.family | |
id: start | |
- platform: calendar | |
event: start | |
offset: "-0:26:0" | |
entity_id: calendar.family | |
id: start | |
- platform: calendar | |
event: start | |
offset: "-0:21:0" | |
entity_id: calendar.family | |
id: start | |
- platform: calendar | |
event: start | |
offset: "-0:16:0" | |
entity_id: calendar.family | |
id: start | |
- platform: calendar | |
event: end | |
offset: "-0:10:0" | |
id: end | |
entity_id: calendar.family | |
condition: [] | |
action: | |
- choose: | |
- conditions: | |
- condition: trigger | |
id: | |
- start | |
sequence: | |
- if: | |
- condition: template | |
value_template: "{{ trigger.calendar_event.location != '' }}" | |
alias: Event has location | |
then: | |
- service: input_text.set_value | |
data: | |
value: "{{ trigger.calendar_event.location }}" | |
target: | |
entity_id: input_text.next_calendar_event_location | |
- service: homeassistant.update_entity | |
data: {} | |
target: | |
entity_id: sensor.waze_travel_time | |
- wait_for_trigger: | |
- platform: state | |
entity_id: | |
- sensor.waze_travel_time | |
timeout: | |
hours: 0 | |
minutes: 0 | |
seconds: 30 | |
milliseconds: 0 | |
- if: | |
- condition: template | |
value_template: >- | |
{{ state_attr('sensor.waze_travel_time', 'destination') == | |
trigger.calendar_event.location }} | |
alias: Waze destination == event location | |
- condition: template | |
value_template: >- | |
{{ (trigger.calendar_event.start | as_datetime | as_local | |
| as_timestamp - as_timestamp(now() + | |
timedelta(minutes=state_attr('sensor.waze_travel_time', | |
'duration')))) | abs <= 16 * 60}} | |
alias: Event start - (now + travel time) <= 16min | |
then: | |
- service: notify.google_assistant_sdk | |
data: | |
message: >- | |
{{ trigger.calendar_event.summary }} starts in {{ | |
((trigger.calendar_event.start | as_datetime | as_local | |
| as_timestamp - as_timestamp(now())) / 60) | round(0) | |
}} minutes. You need {{ | |
state_attr('sensor.waze_travel_time', 'duration') | | |
round(0) }} minutes to drive there. | |
else: | |
- if: | |
- condition: template | |
value_template: >- | |
{{ (trigger.calendar_event.start | as_datetime | | |
as_local | as_timestamp - as_timestamp(now())) <= 16 * | |
60 }} | |
alias: Event start - now <= 16min | |
then: | |
- service: notify.google_assistant_sdk | |
data: | |
message: >- | |
{{ trigger.calendar_event.summary }} starts in {{ | |
((trigger.calendar_event.start | as_datetime | | |
as_local | as_timestamp - as_timestamp(now())) / 60) | |
| round(0) }} minutes. | |
else: | |
- if: | |
- condition: template | |
value_template: >- | |
{{ (trigger.calendar_event.start | as_datetime | as_local | |
| as_timestamp - as_timestamp(now())) <= 16 * 60 }} | |
alias: Event start - now <= 16min | |
then: | |
- service: notify.google_assistant_sdk | |
data: | |
message: >- | |
{{ trigger.calendar_event.summary }} starts in {{ | |
((trigger.calendar_event.start | as_datetime | as_local | |
| as_timestamp - as_timestamp(now())) / 60) | round(0) | |
}} minutes. | |
- conditions: | |
- condition: trigger | |
id: end | |
sequence: | |
- service: notify.google_assistant_sdk | |
data: | |
message: "{{ trigger.calendar_event.summary }} ends in 10 minutes" | |
mode: queued | |
max: 10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment