Force refresh a REST platform object on demand

I have a rest platform that gathers data from my smart tv and a few template sensors that parses the gathered data into individual entities. It looks like this:

  - platform: rest
    resource: !secret samygo_tv_living_channelinfo
    method: GET
    name: TV Living ChannelInfo
      - source
      - pvr_status
      - power_state
      - tv_mode
      - volume
      - channel_number
      - channel_name
      - program_name
    scan_interval: '00:05'
  - platform: template
        value_template: '{{ states.sensor.tv_living_channelinfo.attributes.source }}'
        friendly_name: TV Living Source
        value_template: '{{ states.sensor.tv_living_channelinfo.attributes.pvr_status }}'
        friendly_name: TV Living PVR Status

The scan_interval is set to 5 minutes which is generally fine, but sometimes I want to trigger the rest platform to re-read the data (e.g. I’m planning on adding an automation that is triggered from outside the system via HA API whenever the TV turns off or on).

What I don’t know is - how do I refresh the “TV Living ChannelInfo” object from inside an automation? Any ideas?

From the 0.81 Release Notes:

  • We have a new service homeassistant.update_entity to request the update of an entity, rather than waiting for the next scheduled update. This means you can set a really long scan_interval in the platform_options and then update on demand, ideal for those services where you have low API limit.

Wow, that is awsome! I missed the release notes, thanks for pointing it out.

Is there any log you can check to see that it is being executed? Because I see no change

Which integration are you asking about? The RESTful Sensor, or something else?

yes, the restful sensor. It’s kind of a black box. I execute the service and see no visual feedback or anything. Then if I check the sensor it still says last updated 9 minutes ago

You can enable debug (per below), restart HA, then look in home-assistant.log for the details.

  default: info
  logs: debug

That is very handy. Thanks for the tip!

1 Like

updating the rest sensor using that homeassistant.update_entity doesnt work
I need a way to reload like the one in configurations menu


I have the same need and I’m not able to force an update on demand for a rest sensor. Can somebody help?