From da9bb99ba8bfd6d4daa17f9d7a63533cf3cbd4ab Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ana=C3=AFs=20Betts?= <anais@anaisbetts.org>
Date: Wed, 30 Jun 2021 08:43:02 +0200
Subject: [PATCH] Create service to enable Continuous Mode on Nuki Opener
(#51861)
---
homeassistant/components/nuki/const.py | 1 +
homeassistant/components/nuki/lock.py | 18 ++++++++++++++++++
homeassistant/components/nuki/services.yaml | 14 ++++++++++++++
3 files changed, 33 insertions(+)
diff --git a/homeassistant/components/nuki/const.py b/homeassistant/components/nuki/const.py
index da12a3a074d..680454c3edc 100644
--- a/homeassistant/components/nuki/const.py
+++ b/homeassistant/components/nuki/const.py
@@ -4,6 +4,7 @@ DOMAIN = "nuki"
# Attributes
ATTR_BATTERY_CRITICAL = "battery_critical"
ATTR_NUKI_ID = "nuki_id"
+ATTR_ENABLE = "enable"
ATTR_UNLATCH = "unlatch"
# Data
diff --git a/homeassistant/components/nuki/lock.py b/homeassistant/components/nuki/lock.py
index 48e72b88530..9cb1bd01524 100644
--- a/homeassistant/components/nuki/lock.py
+++ b/homeassistant/components/nuki/lock.py
@@ -12,6 +12,7 @@ from homeassistant.helpers import config_validation as cv, entity_platform
from . import NukiEntity
from .const import (
ATTR_BATTERY_CRITICAL,
+ ATTR_ENABLE,
ATTR_NUKI_ID,
ATTR_UNLATCH,
DATA_COORDINATOR,
@@ -58,6 +59,11 @@ async def async_setup_entry(hass, entry, async_add_entities):
vol.Optional(ATTR_UNLATCH, default=False): cv.boolean,
},
"lock_n_go",
+ "set_continuous_mode",
+ {
+ vol.Required(ATTR_ENABLE): cv.boolean,
+ },
+ "set_continuous_mode",
)
@@ -165,3 +171,15 @@ class NukiOpenerEntity(NukiDeviceEntity):
def lock_n_go(self, unlatch):
"""Stub service."""
+
+ def set_continuous_mode(self, enable):
+ """Continuous Mode.
+
+ This feature will cause the door to automatically open when anyone
+ rings the bell. This is similar to ring-to-open, except that it does
+ not automatically deactivate
+ """
+ if enable:
+ self._nuki_device.activate_continuous_mode()
+ else:
+ self._nuki_device.deactivate_continuous_mode()
diff --git a/homeassistant/components/nuki/services.yaml b/homeassistant/components/nuki/services.yaml
index d923885efc6..c43f081dbf7 100644
--- a/homeassistant/components/nuki/services.yaml
+++ b/homeassistant/components/nuki/services.yaml
@@ -12,3 +12,17 @@ lock_n_go:
default: false
selector:
boolean:
+set_continuous_mode:
+ name: Set Continuous Mode
+ description: "Enable or disable Continuous Mode on Nuki Opener"
+ target:
+ entity:
+ integration: nuki
+ domain: lock
+ fields:
+ enable:
+ name: Enable
+ description: Whether to enable or disable the feature
+ default: false
+ selector:
+ boolean: