How do I log events without leaving a browser window open?

I’m trying to troubleshoot some intermittent issues with some of my zigbee devices, and I suspect it’s a sometimes-malformed message. However, I’m having a lot of trouble reproducing it because it seems to happen at random (or at least hard-to-predict) times.

The easiest way to test this would be to see a playbook of the log that I get when I go to Developer tools->Events, and fill in “zha_event” and hit “start listening”. If I could just get that for ~1 day in some sort of log format without needing to keep a browser window open, that would be perfect. Is there any way to do this with home assistant, or am I stuck trying to hack together something that acts like the dev tools javascript?

You could log all zha_events to a file using an automation and the file notification platform:

You can timestamp them too.

Oh, whoa, that’s a great simple idea. Thanks @tom_l !

For anyone who might happen upon this in the future, here’s my configuration.yaml snippet to solve the above:

notify:
  - name: events_file_logger
    platform: file
    filename: events_log.txt
    timestamp: true

automation:
  - alias: "Log Events"
    trigger:
      - platform: event
        event_type: zha_event
        # Uncomment this to lower the noise if needed with whichever is the correct cluster for your application
        #event_data:
        #  cluster_id: 8
    action:
      - service: notify.events_file_logger
        data:
          message: '{{ trigger.event }}'
1 Like