Skip to content

Instantly share code, notes, and snippets.

@allenporter
Last active September 24, 2023 23:28
Show Gist options
  • Save allenporter/587bd072908f88851e96338edbe086b0 to your computer and use it in GitHub Desktop.
Save allenporter/587bd072908f88851e96338edbe086b0 to your computer and use it in GitHub Desktop.
Calendar upcoming location sensor
- trigger:
- platform: homeassistant
event: start
- platform: time_pattern
hours: "/6"
action:
- service: calendar.list_events
target:
entity_id: calendar.personal
data:
duration:
hours: 168
minutes: 0
seconds: 0
response_variable: agenda
- alias: Find upcoming events with locations
variables:
upcoming: "{{ agenda.events | rejectattr('location', 'undefined') | list }}"
sensor:
- name: Next Location
state: >
{% if upcoming|length > 0 %}
{{ upcoming[0].location }}
{% endif %}
- name: Next Location Summary
state: >
{% if upcoming|length > 0 %}
{{ upcoming[0].summary }}
{% endif %}
- name: Next Location Start
state: >
{% if upcoming|length > 0 %}
{{ upcoming[0].start }}
{% endif %}
device_class: timestamp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment