Missing Z-wave related events (zwave.network_start, zwave.node_event etc)

Hi!

I’m running HA, currently on 100.3. I have a Aeon z-stick, and a number of Z-Wave devices that works more or less perfectly.

I bought a ID Lock with a Z-Wave module, which I’ve installed and successfully included into my Z-wave network. I can control the device, and I get some updates back. So far so good.

I’m trying to get who opened the door, but I can’t find that information in my entities. According to the documentation (pdf) the notification type 0x06 is updated as the entity sensor.id_lock_as_150_access_control works great. How ever, I need to get the event parameter as well; because that’s where the user ID is stored (I know that part works; I see the ID:s in the OZW_log.txt).

I figured that I check the zwave.node_event event, but I can’t get HA to listen to that topic. I’ve tested to add a listener through the developer tools, but it does not show any events.

EDIT: I’ve also tested to add this automation, but it made no difference.

automation:
        - alias: "Log any Z-wave activity"
          trigger:
            platform: event
            event_type: zwave.node_event
          action:
           service: logbook.log
           data:
             name: "Zwave event"
             message: "{{ trigger.event.data }}"

Do you have any ideas of what to do to get those events?

Thank you!
Zyber

You need to have a device that sends a Basic Set command. That’s the only thing that triggers the event. Usually you would want to avoid using this event if other means are possible. A notification is different than a Basic Set.

See Basic Command Class.

Also, OZW 1.4 doesn’t support V4 of the notification command class, so you wouldn’t be able to get the event data. You will have to wait for OZW 1.6.

Oh, that’s too bad. I may do a hack then that reads the OZW_log then (as I get the notifications as raw data). Thanks for your answers @freshcoast !.

Have you got this working now? Im interested in the same and got the same lock.

Kinda. I wrote a very simple python script that tails the OZW_log file for all the events I’m interested in (who unlocks the door, if the door is in away mode) and then sends that on the MQTT bus into HA. I can probably share the script, but it’s really ugly.

Please share anyway :slight_smile:

I have done the same (ugly) thing using grep, but it always useful to see other’s solutions.

Example from my implementation:

- platform: command_line
  name: 'idlock150_last_notification_event'
  command: 'grep "Node050, Decrypted Packet: 0x00, 0x71, 0x05, 0x00, 0x00, 0x00, 0xff, 0x06, " "/config/OZW_Log.txt" | tail -1 |  cut -c108-111'
  scan_interval: 86400

- platform: command_line
  name: 'idlock150_last_notification_parameter_length'
  command: 'grep "Node050, Decrypted Packet: 0x00, 0x71, 0x05, 0x00, 0x00, 0x00, 0xff, 0x06, " "/config/OZW_Log.txt" | tail -1 |  cut -c114-117'
  scan_interval: 86400

- platform: command_line
  name: 'idlock150_last_notification_parameter_1'
  command: 'grep "Node050, Decrypted Packet: 0x00, 0x71, 0x05, 0x00, 0x00, 0x00, 0xff, 0x06, " "/config/OZW_Log.txt" | tail -1 |  cut -c120-123'
  scan_interval: 86400

- platform: command_line
  name: 'idlock150_last_event'
  command: 'grep "Node050, Decrypted Packet: 0x00, 0x71, 0x05, 0x00, 0x00, 0x00, 0xff, 0x06, " "/config/OZW_Log.txt" | tail -1 |  cut -c108-111'
  scan_interval: 86400

All sensors are updated from an automation:

trigger:
  platform: state
  entity_id: lock.id_lock_as_150_locked
action:
  - service: homeassistant.update_entity
    data:
      entity_id: sensor.idlock150_last_manual_lock_time
...

Then I check for codes and translate to user code/tags.

- platform: template
  sensors:
    idlock150_last_rf_unlock_id_description:
      friendly_name: 'Last unlock by tag'
      icon_template: mdi:clock
      entity_id: sensor.idlock150_last_rf_unlock_id
      value_template: >-
        {% if is_state('sensor.idlock150_last_rf_unlock_id', '0x00') %}
          Z-Wave / Home Assistant
        {% elif is_state('sensor.idlock150_last_rf_unlock_id', '0x1a') %}
          My tag # RFID slot 1
...

Here is my script:

You run it with the path to the OZW_log-file as the argument.

It parses the log file, and publishes the events on an MQTT bus. Then I have the following binary sensors declared:

binary_sensor:
  - platform: mqtt
    state_topic: "maindoor/mode"
    name: "Away mode"
    payload_off: "away"
    payload_on: "home"
    device_class: presence 
  - platform: mqtt
    state_topic: "maindoor/lock"
    name: "Lock status"
    value_template: "{{ value_json.status }}"
    payload_on: "unlocked"
    payload_off: "locked"
    json_attributes_topic: "maindoor/lock"
    device_class: lock

Who unlocks and locks the door is in the user attribute of lock_status, so I have an automation like this to trigger if it’s me who unlocks the door, and not my partner:

automation:
  - alias: "When Fritiof gets home transfer Spotify" 
    trigger:
    - platform: template 
      value_template: "{{ is_state_attr('binary_sensor.lock_status', 'user', 'User1') }}"

I run the program in a screen session, to keep it running even when I disconnect from the home assistant server.

Just let me know if there is any questions :slight_smile:

Your script certainly is better structured and a better solution!

It took me a while to realize that HA really needed the python filename in lowercase.
It just would run until I changed it to “parseozw.py” from “parseOZW.py”.
The OZW Log file however, is in mixed upper- and lowercase, and that works.
filename: "/config/OZW_Log.txt"

Anyway: I don’t know Python at all (yet), but i can follow the code and parsing pretty good.

I get a warning (below), but I run the Mosquitto add-on and this seems to require paho , so I guess I need to change the imports to… something else.
Or install the paho client perhaps?

import paho.mqtt.client as mqttc
import paho.mqtt.publish as mqttp

Log:

2020-01-27 16:28:32 INFO (SyncWorker_19) [homeassistant.components.python_script] Executing parseozw.py: {'filename': '/config/OZW_Log.txt'}
2020-01-27 16:28:32 ERROR (SyncWorker_19) [homeassistant.components.python_script.parseozw.py] Error executing script: __import__ not found
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/python_script/__init__.py", line 196, in execute
    exec(compiled.code, restricted_globals)
  File "parseozw.py", line 2, in <module>
ImportError: __import__ not found

Thanks!

Yeah, you need to install the packages. Either you install the packages globally; on debian-ish systems you can apt-get install python3-paho-mqtt, or run pip3 install paho-mqtt.

I think the issue is that you’re running the script using the python script component, when reading the documentation it says:

It is not possible to use Python imports with this integration. If you want to do more advanced scripts, you can take a look at AppDaemon

I’m only running the script “on the side” using screen and calling the python script from there.

Sounds right. I did read that. Just didn’t understand it :slight_smile:

The screen part? I’ve only skimmed through https://linuxize.com/post/how-to-use-linux-screen/ but it seems about right.

  1. Read the link
  2. create a screen session (by running screen)
  3. navigate to script, and run it (python3 ./parseOZW.py /home/homeassistant/.homeassistant/OZW_Log.txt)
  4. make sure it starts
  5. detach the console (press ctrl-a and then ctrl-d). Now you need to to this again if your server reboots… :slight_smile:

Good luck!

1 Like