RESTFUL Sensor - limit the update to once per day

Hi guys,

I have sensors which get their values from a website API.

sensor:
  - platform: rest
    name: Prayer Times 
    json_attributes:
      - fajr
      - dhuhr
      - asr
      - magrib
      - isha
    resource: https://www.somewebsite.com/api/times/?format=json&key=blank
    value_template: '{{ value_json.city }}' 
  - platform: template
    sensors:
      elm_fajr: #this will now be the official id of your sensor
        friendly_name: 'Fajr'
        value_template: '{{ state_attr("sensor.prayer_times","fajr") }}'
        device_class: timestamp
        icon_template: mdi:clock

How can I ensure that this only updates once per day (say, at 11pm).

I don’t know exactly how frequently it is updating in its present state and am worried about unnecessarily spamming the API provider’s servers unnecessarily.

Any help would be appreciated.

Thank you!

If you want it updated at a certain time you can set the scan_interval: to a really long time (say 172,000) and call the homeassistant.update_entity service in an automation that triggers at 11pm.

Thanks Tom.

I noticed that the documentation for scan_interval says: “These options are being phased out and are only available for single platform integrations.

Is it best practice to use this (and set a really long timer)?

And thank you for pointing me to homeassistant.update_entity. That’s perfect! !:slight_smile:

I don’t see how you can use the update entity service without it in this situation. This is a perplexing development and I can’t find any more information about it.