If anybody wants to make use of all available information of the mqtt “lockActionEvent” described in the MQTT API Specification v1.4, e.g. to react on Nuki Lock Button click or double-click, this can be accomplished by adding the following to your configuration.yaml manually (replace the “3Axxxxxx” with your own Nuki-ID of course):
configuration.yaml:
mqtt: !include mqtt.yaml
mqtt.yaml:
- event:
state_topic: "nuki/3Axxxxxx/lockActionEvent"
name: "Nuki Zuhause lockActionEvent"
icon: mdi:state-machine
unique_id: nuki_zuhause_lockActionEvent
device:
identifiers: '[3AXXXXXX]'
event_types:
- "unlock"
- "lock"
- "unlatch"
- "lock ‘n’ go"
- "lock ‘n’ go"
- "full lock"
- "fob (without action)"
- "button (without action)"
- "other"
### lock_action
# 1 unlock
# 2 lock
# 3 unlatch
# 4 lock ‘n’ go
# 5 lock ‘n’ go
# 6 full lock
# 80 fob (without action)
# 90 button (without action)
### trigger
# 0 system / bluetooth command
# 1 (reserved)
# 2 button
# 3 automatic (e.g. time control)
# 6 auto lock
# 171 HomeKit
# 172 MQTT
### auth_id: Auth-ID of the user
### code_id: ID of the Keypad code, 0 = unknown
### mode: Auto-Unlock (0 or 1) or
# number of button presses (only button & fob actions) or
# Keypad source (0 = back key, 1 = code, 2 = fingerprint)
value_template: |
{% set value_list = value.split(',')|map('int')|list %}
{% if value_list[0] <= 6 %}
{% set event_type =
("unlock", "lock", "unlatch", "lock ‘n’ go", "lock ‘n’ go", "full lock")[value_list[0]-1]
%}
{% elif value_list[0] == 80 %}
{% set event_type = "fob (without action)" %}
{% elif value_list[0] == 90 %}
{% set event_type = "button (without action)" %}
{% else %}
{% set event_type = "other" %}
{% endif %}
{
"event_type": "{{event_type}}",
"lock_action": {{ value_list[0] }},
"trigger": {{ value_list[1] }},
"auth_id": {{ value_list[2] }},
"code_id": {{ value_list[3] }},
"mode": {{ value_list[4] }}
}
availability_topic: "nuki/3Axxxxxx/connected"
payload_not_available: 'false'
payload_available: 'true'
this can afterwards be used in an automation like this:
alias: Nuki Event
description: ""
triggers:
- trigger: state
entity_id:
- event.zuhause_nuki_zuhause_lockactionevent
conditions: []
actions:
- choose:
- conditions:
- condition: template
value_template: >-
{{ state_attr("event.zuhause_nuki_zuhause_lockactionevent",
"trigger") == 2 and
state_attr("event.zuhause_nuki_zuhause_lockactionevent", "mode")
== 1 }}
sequence: []
alias: Nuki Button click
- conditions:
- condition: template
value_template: >-
{{ state_attr("event.zuhause_nuki_zuhause_lockactionevent",
"trigger") == 2 and
state_attr("event.zuhause_nuki_zuhause_lockactionevent", "mode")
== 2 }}
sequence: []
alias: Nuki Button double-click
mode: single