Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Several Basic and Advanced Settings, Event logs, Last Unlock User #59

Merged
merged 25 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/example-project-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ esphome:
- Preferences
- https://github.com/h2zero/NimBLE-Arduino#1.4.0
- Crc16
- https://github.com/uriyacovy/NukiBleEsp32#dev
- https://github.com/I-Connect/NukiBleEsp32

esp32:
framework:
Expand Down
2 changes: 1 addition & 1 deletion .github/example-project-main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ esphome:
- Preferences
- https://github.com/h2zero/NimBLE-Arduino#1.4.0
- Crc16
- https://github.com/uriyacovy/NukiBleEsp32
- https://github.com/I-Connect/NukiBleEsp32#93e7da927171c8973b7ef857c7fa644c174ed47d

esp32:
framework:
Expand Down
70 changes: 64 additions & 6 deletions .github/shared-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,74 @@ external_components:

lock:
- platform: nuki_lock
name: My Nuki Lock
name: Nuki Lock

is_connected:
name: "Nuki Connected"
is_paired:
name: "Nuki Paired"
battery_critical:
name: "Nuki Battery Critical"
battery_level:
name: "Nuki Battery Level"
is_connected:
name: "Nuki Connected"
door_sensor:
name: "Nuki Door Sensor"

battery_level:
name: "Nuki Battery Level"

door_sensor_state:
name: "Nuki Door Sensor State"
name: "Nuki Door Sensor: State"
last_unlock_user:
name: "Nuki Last Unlock User"

unpair:
name: "Nuki Unpair Device"

pairing_mode:
name: "Nuki Pairing Mode"
auto_unlatch:
name: "Nuki Auto unlatch"
button_enabled:
name: "Nuki Button: Locking operations"
led_enabled:
name: "Nuki LED Signal"
night_mode_enabled:
name: "Nuki Night Mode"
night_mode_auto_lock_enabled:
name: "Nuki Night Mode: Auto Lock"
night_mode_auto_unlock_disabled:
name: "Nuki Night Mode: Reject Auto Unlock"
night_mode_immediate_lock_on_start_enabled:
name: "Nuki Night Mode: Lock at Start Time"
auto_lock_enabled:
name: "Nuki Auto Lock"
auto_unlock_disabled:
name: "Nuki Auto Unlock: Disable"
immediate_auto_lock_enabled:
name: "Nuki Auto Lock: Immediately"
auto_update_enabled:
name: "Nuki Automatic Updates"

led_brightness:
name: "Nuki LED Brightness"

single_buton_press_action:
name: "Nuki Single Button Press Action"
double_buton_press_action:
name: "Nuki Double Button Press Action"
fob_action_1:
name: "Nuki Fob Action 1"
fob_action_2:
name: "Nuki Fob Action 2"
fob_action_3:
name: "Nuki Fob Action 3"

security_pin: 1234
pairing_mode_timeout: 300s
event: "nuki"

on_pairing_mode_on_action:
- lambda: ESP_LOGI("nuki_lock", "Pairing mode turned on");
on_pairing_mode_off_action:
- lambda: ESP_LOGI("nuki_lock", "Pairing mode turned off");
on_paired_action:
- lambda: ESP_LOGI("nuki_lock", "Paired sucessfuly");
151 changes: 129 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,10 @@
# Nuki Lock for ESPHome (ESP32)
[![Build Component](https://github.com/uriyacovy/ESPHome_nuki_lock/actions/workflows/build.yaml/badge.svg)](https://github.com/uriyacovy/ESPHome_nuki_lock/actions/workflows/build.yaml)
# ESPHome Nuki Lock Component (ESP32) [![Build Component](https://github.com/uriyacovy/ESPHome_nuki_lock/actions/workflows/build.yaml/badge.svg)](https://github.com/uriyacovy/ESPHome_nuki_lock/actions/workflows/build.yaml)

This module builds an ESPHome lock platform for Nuki Smartlock (nuki_lock) that creates 9 new entities in Home Assistant:
- Lock
- Binary Sensor: Is Paired
- Binary Sensor: Is Connected
- Binary Sensor: Critical Battery
- Sensor: Battery Level
- Binary Sensor: Door Sensor
- Text Sensor: Door Sensor State
- Switch: Pairing Mode
- Button: Unpair
This module builds an ESPHome lock platform for Nuki Smartlocks (nuki_lock) that creates [24 entities](#entities) in Home Assistant.

The lock entity is updated whenever the look changes state (via Nuki App, HA, or manually) using Nuki BT advertisement mechanism.
The lock entity is updated whenever the look changes state (via Nuki App, HA, or manually) using the Nuki BLE advertisement mechanism.

![dashboard](./docs/nuki_dashboard.png)
![some dashboard entites](./docs/nuki_dashboard.png)


## How to use
Expand Down Expand Up @@ -50,20 +40,64 @@ lock:
# Optional:
battery_critical:
name: "Nuki Battery Critical"
battery_level:
name: "Nuki Battery Level"
door_sensor:
name: "Nuki Door Sensor"

battery_level:
name: "Nuki Battery Level"

door_sensor_state:
name: "Nuki Door Sensor State"
unpair:
name: "Nuki Unpair"
name: "Nuki Door Sensor: State"
last_unlock_user:
name: "Nuki Last Unlock User"

pairing_mode:
name: "Nuki Pairing Mode"
auto_unlatch:
name: "Nuki Auto unlatch"
button_enabled:
name: "Nuki Button: Locking operations"
led_enabled:
name: "Nuki LED Signal"

led_brightness:
name: "Nuki LED Brightness"

night_mode_enabled:
name: "Nuki Night Mode"
night_mode_auto_lock_enabled:
name: "Nuki Night Mode: Auto Lock"
night_mode_auto_unlock_disabled:
name: "Nuki Night Mode: Reject Auto Unlock"
night_mode_immediate_lock_on_start_enabled:
name: "Nuki Night Mode: Lock at Start Time"
auto_lock_enabled:
name: "Nuki Auto Lock"
auto_unlock_disabled:
name: "Nuki Auto Unlock: Disable"
immediate_auto_lock_enabled:
name: "Nuki Auto Lock: Immediately"
auto_update_enabled:
name: "Nuki Automatic Updates"

single_buton_press_action:
name: "Nuki Button: Single Press Action"
double_buton_press_action:
name: "Nuki Button: Double Press Action"
fob_action_1:
name: "Nuki Fob: Action 1"
fob_action_2:
name: "Nuki Fob: Action 2"
fob_action_3:
name: "Nuki Fob: Action 3"

unpair:
name: "Nuki Unpair Device"

# Optional: Settings
security_pin: 1234
pairing_mode_timeout: 300s
event: "nuki"

# Optional: Callbacks
on_pairing_mode_on_action:
Expand Down Expand Up @@ -96,8 +130,8 @@ service: esphome.<NODE_NAME>_lock_n_go
data: {}
```

## Automation ##
### Action: Pairing Mode ###
## Automation
### Action: Pairing Mode
You can use this action to turn on/off the pairing mode:
```yaml
on_...:
Expand All @@ -106,7 +140,7 @@ on_...:
```

### Action: Unpair
You can use this action to unpair your Nuki:
You can use this action to unpair your Nuki Smartlock:
```yaml
on_...:
- nuki_lock.unpair:
Expand All @@ -123,6 +157,79 @@ on_paired_action:
- lambda: ESP_LOGI("nuki_lock", "Paired sucessfuly");
```

### Events
By default this component sends the Nuki logs as events to Home Assistant.
You can use them in automations. If you want to disable events, set the `event` property in your yaml to `none`.
If you want to check the log events, go to the Home Assistant Developer tools -> Events and listen for `esphome.nuki` events.
```yaml
event_type: esphome.nuki
data:
device_id: 373c62d6788cf81d322763235513310e
action: Unlatch
authorizationId: "3902896895"
authorizationName: Nuki ESPHome
completionStatus: success
index: "92"
timeDay: "25"
timeHour: "0"
timeMinute: "46"
timeMonth: "10"
timeSecond: "11"
timeYear: "2024"
trigger: system
type: LockAction
origin: LOCAL
time_fired: "2024-10-25T00:46:33.398284+00:00"
context:
id: 01JB0J7AXPMS5DWHG188Y6XFCP
parent_id: null
user_id: null
```

## Entities

**Lock:**
- Lock

**Binary Sensor:**
- Is Paired
- Is Connected
- Critical Battery
- Door Sensor

**Sensor:**
- Battery Level

**Text Sensor:**
- Door Sensor State
- Last Unlock User

**Switch:**
- Pairing Mode
- Button Enabled
- LED Enabled
- Night Mode
- Night Mode: Auto Lock
- Night Mode: Reject Auto Unlock
- Night Mode: Lock at Start Time
- Auto Lock
- Auto Unlock: Disable
- Auto Lock: Immediately
- Automatic Updates

**Select:**
- Single Button Press Action
- Double Button Press Action
- Fob Action 1
- Fob Action 2
- Fob Action 3

**Number:**
- LED Brightness

**Button:**
- Unpair Device

## Dependencies
The module depends on the work done by [I-Connect](https://github.com/I-Connect) with [NukiBleEsp32](https://github.com/I-Connect/NukiBleEsp32).

Expand Down
Loading
Loading