I'm writing an API that's very similar to the one at Sunset and sunrise times API - Sunrise-Sunset.org , but is a bit different/custom for my own needs. I want to be able to write automations like "at the end of astronomical twilight, switch to the nighttime mode" or "at the start of civil twilight, turn this light on". Can someone please point me to documentation or examples on how to query my API from the Hubitat system (presumably Rule Machine) so I can use it as a trigger for rules like these?
(Note that the built-in sunrise/sunset feature won't meet my needs.)
Presumably, you'd have two of these, one for each of your values. Or you can use one and pass in a value through the url, which ends up in %value%. %value% can be put into a variable, and then tested in Conditional Actions....
Another way to do it is to create a virtual device of some sort, and set its value with Maker API. You would POST to Maker API to issue the device command, thus setting the device attribute state. That device could be used in automations as appropriate.
Yes, HTTP RESTful. See the link I provided as an example; I'm mimicking that closely, but returning additional info. Planning to return JSON response, but I can do whatever's best for Hubitat. I'm happy to use a custom driver or app if that's best; I know what I want to do but not how to do it!
Thanks. I'm going to have to read your examples a few more times to make sure I'm following. But I'm not following your question here, which is "your system" and which is "an endpoint"? My goal, if possible, is for Hubitat to call an API (like the one I linked), and not for an external service to call a Hubitat API.
If you want Hubitat to query your API, a custom driver seems like the right path. If you didn't control the API server implementation (for example, if you were using the stock sunrise-sunset API), this would possibly be the only option.
However, as @bravenel pointed out, if you have the ability to have your API server push specific updates to Hubitat, there are multiple ways that you could achieve that without custom code on Hubitat. You might prefer that path for various reasons.