I’m wanting to drive some automation based on how many of a certain type of event occur in the coming (7) days. I planned to just run the script once a day to update the counter (input_number.bookings helper).
I have the following script that tries to do this, but the value seems to always be 0.0. So, I added code earlier to manually set it to 2 just to prove that part works, and it does. I can see the value go to 2, and then immediately to 0. Is there something wrong with my attempt to populate myevents or event_count variables. Any help please?
sequence:
- data:
entity_id: calendar.personal_events
start_date_time: '{{ now().isoformat() }}'
duration:
days: 7
response_variable: calendar_events
action: calendar.get_events
- variables:
myevents: '{{ calendar_events | selectattr("summary", "search", "Meeting") | list }}'
event_count: '{{ myevents.events | count() }}'
- data:
entity_id: input_number.bookings
value: 2
action: input_number.set_value
- data:
entity_id: input_number.bookings
value: '{{ event_count }}'
action: input_number.set_value
Thanks