After one of recent updates (I did not noticed when exactly this happened) one of my template sensor no longer update on HA restart. It is sensor that reads Weatherbit alerts and presents it in more readible form. Here is the code for sensor:
All template values resolve properly in Template Editor. Probably since weather alert is not updating frequently, it also causes my sensor not to update after resart and stay in unknown mode. In principle sensor works fine, as I can force update by reloading Template Entities (from Configuration->Server Controls) and this causes sensor to update its value:
As there are not too many alerts recently, I can’t verify if sensor would update properly once source data is changing. Is there any solution to get such template sensor to properly update its state after HA restart?
Thanks Tom! I was actually thinking about similar solution, though it looks a bit strange that only one of my template sensors behavies this way…
Anyhow I implemented this and no success… Difference is that now I see error in log file:
2021-08-07 17:55:28 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.weather_alert fails
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 446, in async_update_ha_state
await self.async_device_update()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 654, in async_device_update
raise exc
File "/usr/src/homeassistant/homeassistant/components/template/template_entity.py", line 277, in async_update
self._async_update()
TypeError: 'NoneType' object is not callable
I thought it might be linked with Weatherbit integration not being ready so I added some delay in automation and even tried to call the service manually… same error At the same time reloading template entities afterwards work like charm… I feel lost.
The only drawback is that new template platform does not support friendly name to be defined as attribute and seems to take it from sensor name directly, but this is manageable.