How to best identify the configuration that generates errors in the logs?

Hello all!
I’m running HA 0.94 (for now, going to upgrade it soon), but I get spammed in the log with a recurring error message every second:

2019-09-01 11:45:01 ERROR (MainThread) [homeassistant.core] Error doing job: Exception in callback <function async_track_utc_time_change.<locals>.pattern_time_change_listener at 0x7f9962cd90>
Traceback (most recent call last):
  File "uvloop/cbhandles.pyx", line 68, in uvloop.loop.Handle._run
  File "/usr/src/homeassistant/homeassistant/helpers/event.py", line 395, in pattern_time_change_listener
    calculate_next(now)
  File "/usr/src/homeassistant/homeassistant/helpers/event.py", line 380, in calculate_next
    matching_hours)
  File "/usr/src/homeassistant/homeassistant/util/dt.py", line 256, in find_next_time_expression_time
    raise ValueError("Cannot find a next time: Time expression never "
ValueError: Cannot find a next time: Time expression never matches!
2019-09-01 11:45:02 ERROR (MainThread) [homeassistant.core] Error doing job: Exception in callback <function async_track_utc_time_change.<locals>.pattern_time_change_listener at 0x7f9962cd90>
Traceback (most recent call last):
  File "uvloop/cbhandles.pyx", line 68, in uvloop.loop.Handle._run
  File "/usr/src/homeassistant/homeassistant/helpers/event.py", line 395, in pattern_time_change_listener
    calculate_next(now)
  File "/usr/src/homeassistant/homeassistant/helpers/event.py", line 380, in calculate_next
    matching_hours)
  File "/usr/src/homeassistant/homeassistant/util/dt.py", line 256, in find_next_time_expression_time
    raise ValueError("Cannot find a next time: Time expression never "
ValueError: Cannot find a next time: Time expression never matches!
                                                                                                                                                                 

What’s the best way to identify what configuration/automation item is causing it? I have a fairly large configuration/automations to dig through…

It must be something time-related…
Thanks!

Found it - it was this one (some test automations):

- id: '1564383944000'
  alias: N2 heartbeat
  trigger:
  - hours: ''
    minutes: '1'
    platform: time_pattern
    seconds: ''
  condition: []
  action:
  - data_template:
      payload: ping
      retain: true
      topic: ha/pc/heartbeat
    service: mqtt.publish

But the question remains valid - is there a method to do it without looking at every automation? I identified it because it was marked as never being triggered…

1 Like

Not really. The error logs can sometimes leave a lot to be desired.

Last night I had an error in my automations.yaml. The log pointed to the include! automations.yaml line in my configuration.yaml file. Not at all helpful.

I ended up having to comment out half my 6000 lines of automations then config check to see if the error was in the uncommented half, then halve the errored half and check again, then halve that, etc… and eventually find the error.

So divide and conquer never dies, I see :slight_smile:
Thanks - I was hoping there was a better way to do a stacktrace or something…

I searched my code for hours: '' - and that was the source of my errors too. It looks like this is caused by using the time pattern trigger through the automation UI. I think this might be a bug? Those fields should be auto-populated with 00 if left blank, or the user should not be permitted to leave them blank.

I don’t remember if I configured that automation from the web interface. I might have done it manually…

Using packages can help a little here but it can be like finding a needle in a haystack with some errors.