I have a template sensor which retrieves its data via rest call.
The rest api is configured to be called once per day.
This all works fine:-
This is the extract from my sensors.yaml:-
- platform: rest
name: bin_collection_restful
resource: https://somewebsite
timeout: 15
scan_interval: 86400
json_attributes:
- label
- Results
value_template: 'OK'
And this is the template sensor based off that:-
- sensor:
- name: "Black Bin Collection Date"
unique_id: black_bin_collection_date
state: >
{% set blackbin_date = states.sensor.bin_collection_restful.attributes["Results"].split('Your rubbish')[1].split('<br/>')[1].split('</em>')[0] %}
{{blackbin_date}}
The problem is that the sensor loses its value when HA restarts.
I’ve tried this in dev tools, but nothing happens:-
service: homeassistant.update_entity
data: {}
target:
entity_id:
- sensor.black_bin_collection_date
I was hoping I could use trigger this service call in an automation triggered by HA start, but as it does nothing in dev tools, I’m stuck.
Help!