I have written an Python API which downloads a static timetable and allows the client to query it for UTC timestamps. This is a very straightforward look up, and apart from the initial download everything is done locally.
I wish to use these times to generate both states and triggers in HA, similar to how the Sun component works.
I have read the documentation but it talks in quite abstract terms about creating components for devices, but since this is a static look up I will not have events per se. But neither is it appropriate to poll.
I’ve tried looking at how the Sun component works, but it seems to use helpers outside of its component code. Rather than recreate it verbatim, I thought I’d ask some advice here.
-
I think I need to at the very least generate some kind of scheduled event. How can I do this based on a UTC time?
-
What comes first, states or triggers? Once I’ve determined a state change, do I generate a trigger? Or do I schedule a trigger and cause the state change then? Or does the event from 1) do both? When do attributes get updated?
-
How are further events generated? Should I constantly generate the day’s events (ie every night at 00:05) or should an event generate the next one as part of its firing?