#Are there any examples of automations
1 messages ยท Page 1 of 1 (latest)
I wrote an example which creates a binary sensor which is on in case there is a calendar entry the next day here: #beta message
so it triggers at midnight right ?
and every hour
in case you add an event on the calender for the next day during the day
you can increase the frequency by changing the time_pattern trigger
ok, wasn't sure how to interpret the time trigger. Does this require 2023.9 ? I saw you posted it in the beta channel. I got something working with a script which I can just fire at say 1830 the night before.
yes, it requires 2023.9
this requires 2023.9 indeed, I didn't actually look a the link properly
you can do it an an automation as well though
I will look to re-write this weekend ๐ the problem with the automation I just created is that it sends an empty message when there is no PE tomorrow
trigger:
- platform: time
at: "18:30:00"
action:
- service: calendar.list_events
target:
entity_id: calendar.test_calendar
data:
start_date_time: "{{ today_at() + timedelta(days=1) }}"
duration:
hours: 24
response_variable: events
- if: "{{ events.events is defined and events.events | count > 0 }}"
then:
- service: notify.whatever
data:
message: "There are appointments tomorrow"
this will already work now
this will not send an empty message when there are no appointments ๐
I just need to drop {%- if "Physical" in event.summary %} in the if clause right ?
no
"{{ events.events is defined and events.events | selectattr('summary', 'contains', 'Physical') | list | count > 0 }}"
yeah, just realised that would mean 2 if statements ๐
I think that should do it
I don't think you need that first part btw, it will return an empty list if there are no events
"{{ events.events | selectattr('summary', 'contains', 'Physical') | list | count > 0 }}"
that should be enough
I sometimes get confused between the {% %} syntax and the {{ }} syntax - which one is jinja2 ?
both