Restful template sensor data - auto reload on HA restart

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
    - 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] %}

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: {}
    - 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.


Looks like the issue was actually with my entity name. It had somehow got confused with an identical copy but named sensor.black_bin_collection_date2

That revealed 2 things:-

The restful sensor data wasn’t getting lost on an HA restart.
And yes, infact that service call does work!