Creating an api driven time based event

Hi there, I'm new here! I have an API that returns a time of day and would like to use it as a value to trigger an event at that time on a specific day of the week. How would I go about doing this?

You would need a custom driver or app to query the api
Does the api return data in a JSON format?

Can you give us an example of the returned data?

Sure. In this case

   "title":"São Paulo, Brazil",
      "admin1":"São Paulo",
      "city":"São Paulo",
      "asciiname":"Sao Paulo",
      "title":"São Paulo, Brazil"
         "hebrew":"ראש חודש אב",
         "title":"Rosh Chodesh Av",
         "memo":"Beginning of new Hebrew month of Av",
         "title":"Candle lighting: 5:26pm",
         "hebrew":"הדלקת נרות",

is the total payload. I would want to grab (please forgive my hacky entity extraction...) payload.items and use the value of "date" where {"category":"candles"}.

In case you're wondering, the use case is to turn the house down a few minutes before the Jewish Sabbath starts.

Not the answer to your actual question, but I would use Node-Red for that and have it trigger a virtual switch via MakerAPI. Would be very simple to setup, as Node-Red can easily fetch and parse json with little/no code at all.

I would create a virtual switch driver to query the api site with a sort of 'if today is Shabbat then turn on'


Have a look at the code in one of my weather drivers.. or better still my Holiday switch driver

1 Like

I don't know if it will help you, but there is an old SmartThings SmartApp that uses the Hebcal API to put your home into 'Shabbat mode'. Maybe the code in there can give you some ideas.

Shabbat and Holiday Modes

1 Like

Thanks! Ported to hubitat!

1 Like