I’m new to Home Assistant and haven’t coded for over 10 years and am trying to get into starting my own project. I’m trying to create a few sensors which would display prayer times (which change daily).
The data is to be retrieved from a URL that I have which provides this data in JSON format.
An example of the results from the URL they supply is like so:
How would I go about, for example, creating a sensor called ‘Fajr’ which retrieves the time “03:41” from this example as it’s value? I would need the sensor to get these values daily from the URL.
You’re on the way with the Restful sensor.
Look at the examples in the docs.
Then, to get the values, you can copy and paste the results in Dev Tools/Templates.
{% set value_json = {"city":"london","date":"2019-05-06","fajr":"03:41","fajr_jamat":"03:56","sunrise":"05:21","dhuhr":"01:02","dhuhr_jamat":"01:30","asr":"05:04","asr_2":"06:09","asr_jamat":"06:24","magrib":"08:34","magrib_jamat":"08:49","isha":"09:45","isha_jamat":"10:15"} %}
{{ value_json.fajr }}
Thank you VDRainer! I have managed to create the sensors using the RESTful and template sensors. All working now and I’m actually quite impressed
I now just need to make a few tweaks to make a trigger activate when the current time matches the sensor time.
How can I add an extra 12 hours to the “sensor.elm_zuhr” value, because the time is currently in a 12-hour format and I need it to be a 24-hr format to compare against a 24-hr time sensor. So far I have this: