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
json_attributes:
- source
- pvr_status
- power_state
- tv_mode
- volume
- channel_number
- channel_name
- program_name
scan_interval: '00:05'
- platform: template
sensors:
tv_living_source:
value_template: '{{ states.sensor.tv_living_channelinfo.attributes.source }}'
friendly_name: TV Living Source
tv_living_pvr_status:
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?
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.
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