Error every night

Hi, I get this error every night at different times.
I have definitely no idea where to look for the bug.
Can somebody push me into the right direction.

Protokolldetails ( ERROR )
Logger: homeassistant
Source: components/template/trigger.py:55
First occurred: 2:51:00 (1 occurrences)
Last logged: 2:51:00

Error doing job: Exception in callback async_track_point_in_utc_time.<locals>.run_action() at /usr/src/homeassistant/homeassistant/helpers/event.py:1137
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/asyncio/events.py", line 81, in _run
    self._context.run(self._callback, *self._args)
  File "/usr/src/homeassistant/homeassistant/helpers/event.py", line 1156, in run_action
    hass.async_run_hass_job(job, utc_point_in_time)
  File "/usr/src/homeassistant/homeassistant/core.py", line 434, in async_run_hass_job
    hassjob.target(*args)
  File "/usr/src/homeassistant/homeassistant/helpers/event.py", line 1362, in pattern_time_change_listener
    hass.async_run_hass_job(job, dt_util.as_local(now) if local else now)
  File "/usr/src/homeassistant/homeassistant/core.py", line 434, in async_run_hass_job
    hassjob.target(*args)
  File "/usr/src/homeassistant/homeassistant/helpers/event.py", line 811, in _refresh_from_time
    self._refresh(None, track_templates=track_templates)
  File "/usr/src/homeassistant/homeassistant/helpers/event.py", line 960, in _refresh
    self.hass.async_run_hass_job(self._job, event, updates)
  File "/usr/src/homeassistant/homeassistant/core.py", line 434, in async_run_hass_job
    hassjob.target(*args)
  File "/usr/src/homeassistant/homeassistant/components/template/trigger.py", line 55, in template_listener
    entity_id = event.data.get("entity_id")
AttributeError: 'NoneType' object has no attribute 'data'

I have around 30 triggers with platform template. But all of them doing fine without errors.

One of your template triggers relies solely on now() to update, causing the error. It’s been reported to github already.

Ah, thank you. Then it’s ok.
@mf_social I checked this and the only template triger with now() is this one:

value_template: "{{ is_state('input_boolean.holiday_mode','on')  and (now().hour | int >= 2) }}"

But this is not solely. Does this meet the case as well?

I may have been wrong with ‘solely’, I think the error is because the template should have updated to true/false based on time at 3am (which you got the error just before).

I may be wrong but the error message is the same as the one in the issue on github so I’d wager its certainly connected, if not exactly the same issue.

ok, thanks

1 Like

Hi. From yesterday updating to latest HA I also started having same error because of similar usage of now :slight_smile:

    trigger:
      platform: template
      value_template: >
        {{ is_state('sensor.time', '19:00') and now().weekday() in (0,1,2,3,4) 
        or (is_state('sensor.time', '20:00') and now().weekday() in (5,6)) }}

Link to github issue: https://github.com/home-assistant/core/issues/44293

I had the same problem, but I managed to solve it by changing my triggers to this:

{{ is_state('sensor.time', '07:30' if is_state('binary_sensor.workday_sensor', 'off') else '07:00') }}

It does require the workday to be activated.

Issue solved with 2020.12.2