I want to read the attributes of a calendar at any time, not just when an event is triggered, but cannot find any direct documentation on this. There is documentation on Trigger variables and Service parameters
By experimentation in the Template Editor I found that the following work OK
Does anyone know what the ‘summary’ attribute is called?
Is this documented anywhere?
Is there a general way of reading the dictionary of attributes for an entity?
If there is no current event (calendar state ‘off’) then these attributes show the next scheduled event
If there is a current event (calendar state ‘on’) then these attributes show that event
If events overlap, i.e. a new event starts before the last one finishes, then these attributes remain those of the first scheduled event until it finishes; only then does the second event become ‘active’ in the sense of showing up in these attributes
If an overlapping event finished before the one it overlaps (the one that started first) then it will never show as active
(NEW) the ‘on’ State change lags the Start event by typically 4 seconds and the ‘off’ State change lags the End event by a similar amount, so…
(NEW) Reading directly from the Calendar (as 1 and 2 above) yields the old data at the time of the Start and End events. So if you read at the start of an event that followed an ‘off’ period, there is no data. If you read at the start of a consecutive event, then you get the data of the first rather than the second event. If you read at the end of an event, you get the data for that event, not the consecutive or next event.
Experimentally, I recommend waiting a full 30 seconds after the Start or End event before reading any data from the Calendar. Although I measured typically 4 seconds, repeated delays of 10 or 20 seconds allowed errors to persist.
Hi @pedolsky
This helped me too - so thanks a lot
I’m just curious as to how you knew this - as in are there any documentation where this could be found. Either for calendar or just in general for Home Assistant. If so I’d give that a look next time tinkering with non-GUI stuff
Several days of trial and error, I’m afraid, plus the tips in this thread.
The Calendar documentation is sadly lacking in detail.
I would like to put in a feature request that the Start event and ‘on’ status occur simultaneously and that the data read from the Calendar is current at that time. Similarly the End event and ‘off’ status should occur simultaneously, with the data set (as now) to the next event.
Also, I would prefer that the current event be the one that started latest (instead of earliest), so you could piggy-back one event on top of the other - for instance to add a temporary one-off event without having to delete the regular event. However, in the case of the Heating X2 Blueprint, I dd not regard either that or the delay important enough to write special code. My workaround is to add a 30 second delay to my start and end event triggers, then read the data. That has proven experimentally reliable. I am reading the data from the Calendar rather than the trigger data because I want to access it at any time, and adding helpers to store the information (as I did in Heating X release 1) is overcomplicated.
Hey, found this thread after playing with calendar entities for the first time.
Do you know if there’s a way of finding the event after the next one?
So, I have a meal calendar. Every day an event at 3pm and another at 11pm. I launch reminders to prepare the food several hours earlier (4.30pm etc for dinner).
But on Thursdays we prepare food to take away, so actually I would like to launch the reminder for Thursday’s lunch event on Wednesdays at 8pm or so (when the actual next event is still Wed’s dinner). I’d love to have a second sensor telling me the next event after, so I can use that sensor instead for this other reminder.
Hey. This is quite an old thread and I have since learned that it is better to use the service calendar.get_events than to read the attributes. The service response data is a list of calendar events that you can sort in a template using Jijna filters. In your case sort by start time, then take the second one | [1].