I’m running OH 3.0 via Docker on Raspbian, with a pending upgrade to 3.1
I’m adding tide tracking functionality to my OH, where I use an API to get times of upcoming tides (high/low) for the next day. I plan to create “next High” and “next Low” tide items, as well as current status (rising, falling) from this information.
I currently have a rule running a (JS) script at midnight to make the API call, parse the data, and do the calculations, but I’d like to fire it again at each high/low tide event to update the “next” and status items. I see a couple options, and appreciate input from the OH3 gurus on best approach:
- Run at midnight, get the day’s data via API, and schedule a timer for the next high/low event. Timer action updates whatever is needed, and schedules a new timer for the next event (if there are any remaining for the day). This would run 3 or 4 times in a day. Seems pretty efficient, but does have a timer hanging out there at all times.
- Roughly the same, except run every 15 minutes via cron to do the updates. Gets rid of the hanging timer, but now runs and does unnecessary work 92 out of 96 runs/day.
- Some way I haven’t yet discovered to set the “next run time” for a rule.
I’m hoping to make this fairly generic so I can share it when done.