home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
70.48k stars 29.42k forks source link

Z-Wave JS missing alarm_type and alarm_level on lock #46000

Closed pashdown closed 3 years ago

pashdown commented 3 years ago

The problem

Z-Wave JS missing entities for alarm_type and alarm_level on a Z-Wave lock. These were present on the original Z-Wave integration and are useful for setting up sensors. The alarm_level is less important, as the jammed and battery sensors does what is needed mostly there, but the alarm_type is useful for indicating which code-slot has unlocked the door via keypad.

Environment

Problem-relevant configuration

- platform: template
  sensors:
    front_door_lock_status:
      value_template: >-
        {%- if is_state("sensor.front_door_lock_alarm_type", "19") -%}
          {%- if is_state("sensor.front_door_lock_alarm_level", "0") -%}
            Unlocked by Master Code
          {%- elif is_state("sensor.front_door_lock_alarm_level", "1") -%}
            Unlocked by Larry
          {%- elif is_state("sensor.front_door_lock_alarm_level", "2") -%}
            Unlocked by Moe
          {%- elif is_state("sensor.front_door_lock_alarm_level", "3") -%}
            Unlocked by Curly
          {%- elif is_state("sensor.front_door_lock_alarm_level", "10") -%}
            Unlocked by Guest
          {%- else -%}
            Unlocked by User {{ sensor.front_door_lock_alarm_level }}
          {%- endif %}
        {%- elif is_state("sensor.front_door_lock_alarm_type", "9") %}
          Lock Jammed
        {%- elif is_state("sensor.front_door_lock_alarm_type", "24") %}
          Locked by Home Assistant
        {%- elif is_state("sensor.front_door_lock_alarm_type", "25") %}
          Unlocked by Home Assistant
        {%- elif is_state("sensor.front_door_lock_alarm_type", "27") %}
          Auto-Relocked
        {%- elif is_state("sensor.front_door_lock_alarm_type", "21") %}
          Manually Locked
        {%- elif is_state("sensor.front_door_lock_alarm_type", "22") %}
          Manually Unlocked
        {%- elif is_state("sensor.front_door_lock_alarm_type", "161") %}
          Tampered!
        {%- elif is_state("sensor.front_door_lock_alarm_type", "167") %}
          Low Battery
        {%- elif is_state("sensor.front_door_lock_alarm_type", "168") %}
          Critical Battery
        {%- elif is_state("sensor.front_door_lock_alarm_type", "169") %}
          Battery Too Low to Operate
        {%- else -%}
          Unknown Level {{ states.sensor.front_door_lock_alarm_level.state }} Type {{ states.sensor.front_door_lock_alarm_type.state }}
        {%- endif %}
      icon_template: >-
        {%- if is_state("sensor.front_door_lock_alarm_type", "19") -%}
          mdi:lock-open
        {%- elif is_state("sensor.front_door_lock_alarm_type", "9") %}
          mdi:lock-alert
        {%- elif is_state("sensor.front_door_lock_alarm_type", "24") %}
          mdi:lock
        {%- elif is_state("sensor.front_door_lock_alarm_type", "25") %}
          mdi:lock-open
        {%- elif is_state("sensor.front_door_lock_alarm_type", "27") %}
          mdi:lock
        {%- elif is_state("sensor.front_door_lock_alarm_type", "21") %}
          mdi:lock
        {%- elif is_state("sensor.front_door_lock_alarm_type", "22") %}
          mdi:lock-open
        {%- elif is_state("sensor.front_door_lock_alarm_type", "161") %}
          mdi:alert
        {%- elif is_state("sensor.front_door_lock_alarm_type", "167") %}
          mdi:battery-10
        {%- elif is_state("sensor.front_door_lock_alarm_type", "168") %}
          mdi:battery-alert-variant-outline
        {%- elif is_state("sensor.front_door_lock_alarm_type", "169") %}
          mdi:battery-alert-variant-outline
        {%- else -%}
          mdi:lock-open
        {%- endif %}
      friendly_name: 'Front Door Lock Status'

Traceback/Error logs

Additional information

I don't know if this bug is appropriate for here or in the github for Z-Wave JS. My apologies.

MartinHjelmare commented 3 years ago

Please take a dump of your network and attach the dump as a text file here. The dump tool is available in the Z-Wave JS configuration panel that you can reach from the integrations page.

I'm not sure if these values are exposed in Z-Wave JS.

kpine commented 3 years ago

This requires zwave-js v6.1.2 and added support to the integration (it currently gets a TypeError with these new values).

probot-home-assistant[bot] commented 3 years ago

Hey there @home-assistant/z-wave, mind taking a look at this issue as its been labeled with an integration (zwave_js) you are listed as a codeowner for? Thanks! (message by CodeOwnersMention)

pashdown commented 3 years ago

@MartinHjelmare do you still need the network dump in light of what @kpine said about v6.1.2?

kpine commented 3 years ago

The dump would be helpful. The latest version of zwavejs2mqtt now includes v6.1.2.

rccoleman commented 3 years ago

Here's my network dump with Node 25 being a Kwikset deadbolt with product code 0x90/0x01/0x01 and using ZwaveJS 6.1.2 and ZWaveJS2MQTT v1.0.5. The deadbolt is an older ZW (not plus) model and was addressed with https://github.com/OpenZWave/open-zwave/pull/2326 in ozw.

zwave_js_dump.zip

I see the following in the zwjs server logs (manual unlock followed by manual lock), but no corresponding event in HA:

2021-02-05 19:27:36.256 INFO ZWAVE: Node 25: value updated: 113-0-alarmType 21 => 22
2021-02-05 19:27:36.259 INFO ZWAVE: Node 25: value updated: 113-0-alarmLevel 1 => 1
2021-02-05 19:27:38.225 INFO ZWAVE: Node 25: value updated: 113-0-alarmType 22 => 21
2021-02-05 19:27:38.226 INFO ZWAVE: Node 25: value updated: 113-0-alarmLevel 1 => 1
pashdown commented 3 years ago

Here's my dump. zwave_dump.zip