I have a template light depending on another template binary sensor.
The former entity generates an error whenever template entities configuration reloads.
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 598, in _async_add_entities
await coro
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 912, in _async_add_entity
await entity.add_to_platform_finish()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1365, in add_to_platform_finish
await self.async_added_to_hass()
File "/usr/src/homeassistant/homeassistant/components/template/template_entity.py", line 545, in async_added_to_hass
async_at_start(self.hass, self._async_template_startup)
File "/usr/src/homeassistant/homeassistant/helpers/start.py", line 71, in async_at_start
return _async_at_core_state(
^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/start.py", line 36, in _async_at_core_state
hass.async_run_hass_job(at_start_job, hass)
File "/usr/src/homeassistant/homeassistant/core.py", line 938, in async_run_hass_job
hassjob.target(*args)
File "/usr/src/homeassistant/homeassistant/components/template/template_entity.py", line 486, in _async_template_startup
result_info.async_refresh()
File "/usr/src/homeassistant/homeassistant/helpers/event.py", line 1108, in async_refresh
self._refresh(None)
File "/usr/src/homeassistant/homeassistant/helpers/event.py", line 1294, in _refresh
self.hass.async_run_hass_job(self._job, event, updates)
File "/usr/src/homeassistant/homeassistant/core.py", line 938, in async_run_hass_job
hassjob.target(*args)
File "/usr/src/homeassistant/homeassistant/components/template/template_entity.py", line 430, in _handle_results
template_attr.handle_result(
File "/usr/src/homeassistant/homeassistant/components/template/template_entity.py", line 217, in handle_result
self.on_update(result)
File "/usr/src/homeassistant/homeassistant/components/template/light.py", line 712, in _update_effect
if effect not in self._effect_list:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: argument of type 'NoneType' is not iterable
The problem only happens when loading and it works any other time.
I have added event_template_reloaded
trigger but it does not work.
How could I update the template to avoid the error message?
Here is the simplified configuration of both template entities:
- platform: template
lights:
bedroom_light_effect:
value_template: "{{ states('light.bedroom_light') }}"
effect_list_template: "{{ state_attr('binary_sensor.light_effect', 'options') }}"
effect_template: "{{ 'Holiday' if is_state('binary_sensor.light_effect','on') else 'Nothing' }}"
- trigger:
- id: other-triggers
...
- id: reload
platform: event
event_type: event_template_reloaded
binary_sensor:
- name: Light effect
state: "..."
attributes:
options: "{{ ['Nothing', 'Holiday'] }}"