Help using a z-wave's log information to trigger an event

I recently purchased a Dome Mouser z-wave electric mouse trap on Ebay (unopened box).

It is designed to send a notification when a mouse has been trapped so you can take care of the poor mouse once trap does its business.

Unfortunately, when a mouse is exterminated, non of the entities with that z-wave device change (although by the instructions, there is a “tripped” entity, but it isn’t changing. It only changes when you turn the power on and off.

Looking at the z-wave log for this device, I do see the following message when a mouse is caught:

Logbook
December 6, 2024

Basement Mouse Trap fired Notification CC 'notification' event 'Pest Control': 'Pest exterminated'
9:49:17 AM - 44 minutes ago

I thought device logs are stored in the system log file (home-assistant log), but I am not seeing this message there. Is there another place it is located, and is there a way to trip an automation when the above message comes in?

I saw under the system_log integration, you can create a trigger based on a message. in the description, the following is used as an example:

automation:
  - alias: "Create notifications for 'action' errors"
    triggers:
      - trigger: event
        event_type: system_log_event
    conditions:
      - condition: template
        value_template: '{{ "action" in trigger.event.data.message[0] }}'
    actions:
      - action: persistent_notification.create
        data:
          title: "Something bad happened"
          message: "{{ trigger.event.data.message[0] }}"

With me changing the above to be the following for my situation:

alias: Mouse Trap Tripped
description: ""
triggers:
  - trigger: event
    event_type: system_log_event
conditions:
  - condition: state
    entity_id: input_boolean.manual_override
    state: "off"
  - condition: template
    value_template: "{{ \"Pest exterminated\" in event.data.message[0] }}"
actions:
      - action: persistent_notification.create
        data:
          title: "Mouse has been caught"
          message: "{{ trigger.event.data.message[0] }}"
mode: single

(I actually am doing something different than above for the action, but am keeping it the same to match the example)

the above isn’t working since I am not noticing this log entry message for the device being stored there. Possibly because of the configuration I have for log files in configuration.yaml:

logger:
  default: warning
  logs:
    homeassistant.components.media_player: error
    homeassistant.components.ring: error
    homeassistant.loader: error
    denonavr.soundmode: error
    custom_components.hacs: error

If I change the logging for z-wave devices to be all, I am concerned that I would be getting too many messages. If not, would the proper syntax be:

homeassistant.components.z-wave_js: info

???

Is there a better way to act on a log message being reported by a particular z-wave device than I am outlining above (that would work)?

Any help would be much appreciated.

Trigger on zwave_js_notification.

You might also have an event entity corresponding to the notification type.

that did not work, unless I am doing it wrong. I tried the code:

trigger: event
event_type: zwave_js_notification
event_data:
  node_id: 86
id: Basement Trap
context: {}

Where node 86 is the mouse trap. The automation doesn’t trigger, ever, when any state changes for that device. Am I doing something wrong?

Also there are no entity events for the entries associated with this device. the message in the log book doesn’t appear to be associated with a specific entity

Well, as a snippet that looks correct. As a part of an automation it does not. Perhaps post the entire YAML of the automation to ensure the syntax is correct. I.e. I’m not sure why context: {} is there (I guess the UI editor can add that).

You can also use Dev Tools → Events and subscribe to zwave_js_notification event as mentioned in the docs to see if it’s being detected.

As freshcoast mentioned, in Dev tools, subscribe to the zwave_js_notification and then trigger the mouse trap. You should then see in Dev tools all kinds of event data that you can use to formulate a trigger, and you can also use the event data to make action decisions.
Here is an example:

trigger:
  - platform: event
    event_type: zwave_js_value_notification
    event_data:
      node_id: 28
      command_class_name: Central Scene

actions:  
  - choose:     
      - conditions:          
          - condition: template                 
            value_template: >-
              {{ trigger.event.data.label == 'Scene 001' and              
                 trigger.event.data.value == 'KeyPressed' }}
        sequence: 
          - action: blah blah

1 Like

Listening to zwave_js_notifications worked like a charm. I got the following information once the mouse trap was tripped and used it for an event trigger:

trigger: event
event_type: zwave_js_notification
event_data:
  domain: zwave_js
  node_id: 84
  home_id: 3591164612
  endpoint: 0
  device_id: 6bac50818c7297932506b41b014115bf
  command_class: 113
  command_class_name: Notification
  label: Pest Control
  type: 19
  event: 8
  event_label: Pest exterminated
id: Basement Trap

Worked like a charm. Thanks to everyone for the responses.