#Are there any examples of automations

1 messages ยท Page 1 of 1 (latest)

still dock
#

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

royal river
#

so it triggers at midnight right ?

still dock
#

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

royal river
#

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.

fair pasture
#

yes, it requires 2023.9

still dock
#

this requires 2023.9 indeed, I didn't actually look a the link properly

#

you can do it an an automation as well though

royal river
#

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

still dock
#
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 ๐Ÿ™‚

royal river
#

I just need to drop {%- if "Physical" in event.summary %} in the if clause right ?

still dock
#

no

#

"{{ events.events is defined and events.events | selectattr('summary', 'contains', 'Physical') | list | count > 0 }}"

royal river
#

yeah, just realised that would mean 2 if statements ๐Ÿ™‚

still dock
#

I think that should do it

royal river
#

very cool, i changed to 48hrs and it fired when run manually

#

(she has PE thursday)

still dock
#

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

royal river
#

I sometimes get confused between the {% %} syntax and the {{ }} syntax - which one is jinja2 ?

fair pasture
#

both