From e0529e37fca8de0122d0a974c8b669d65358cb1e Mon Sep 17 00:00:00 2001 From: Florian Date: Fri, 1 Nov 2024 13:24:45 +0100 Subject: [PATCH] Change all entities to optional --- .github/test-config.yaml | 4 ++++ README.md | 36 ++++++++++++++++++------------------ components/nuki_lock/lock.py | 7 +++++-- 3 files changed, 27 insertions(+), 20 deletions(-) diff --git a/.github/test-config.yaml b/.github/test-config.yaml index 799227a..b16bbea 100644 --- a/.github/test-config.yaml +++ b/.github/test-config.yaml @@ -84,6 +84,10 @@ lock: name: "Nuki Fob Action 2" fob_action_3: name: "Nuki Fob Action 3" + timezone: + name: "Nuki Timezone" + advertising_mode: + name: "Nuki Advertising Mode" pairing_mode_timeout: 300s event: "nuki" diff --git a/README.md b/README.md index 20d244b..4591c02 100644 --- a/README.md +++ b/README.md @@ -22,28 +22,30 @@ esp32: platform_version: 6.7.0 lock: - # Required: + # Required - platform: nuki_lock name: Nuki Lock + # Optional: Settings + pairing_mode_timeout: 300s + event: "nuki" + # Optional: Binary Sensors is_connected: name: "Nuki Connected" is_paired: name: "Nuki Paired" - - # Optional: battery_critical: name: "Nuki Battery Critical" door_sensor: name: "Nuki Door Sensor" - + # Optional: Sensors battery_level: name: "Nuki Battery Level" - + # Optional: Text Sensors door_sensor_state: name: "Nuki Door Sensor: State" last_unlock_user: name: "Nuki Last Unlock User" - + # Optional: Switches pairing_mode: name: "Nuki Pairing Mode" auto_unlatch: @@ -52,10 +54,12 @@ lock: name: "Nuki Button: Locking operations" led_enabled: name: "Nuki LED Signal" - + # Optional: Number Inputs + security_pin: + name: "Nuki Security Pin" led_brightness: name: "Nuki LED Brightness" - + # Optional: Switches night_mode_enabled: name: "Nuki Night Mode" night_mode_auto_lock_enabled: @@ -72,7 +76,7 @@ lock: name: "Nuki Auto Lock: Immediately" auto_update_enabled: name: "Nuki Automatic Updates" - + # Optional: Select Inputs single_buton_press_action: name: "Nuki Button: Single Press Action" double_buton_press_action: @@ -83,17 +87,13 @@ lock: name: "Nuki Fob: Action 2" fob_action_3: name: "Nuki Fob: Action 3" - + timezone: + name: "Nuki Timezone" + advertising_mode: + name: "Nuki Advertising Mode" + # Optional: Buttons unpair: name: "Nuki Unpair Device" - - security_pin: - name: "Nuki Security Pin" - - # Optional: Settings - pairing_mode_timeout: 300s - event: "nuki" - # Optional: Callbacks on_pairing_mode_on_action: - lambda: ESP_LOGI("nuki_lock", "Pairing mode turned on"); diff --git a/components/nuki_lock/lock.py b/components/nuki_lock/lock.py index 8f5f2b2..a356f51 100644 --- a/components/nuki_lock/lock.py +++ b/components/nuki_lock/lock.py @@ -143,6 +143,7 @@ NukiLock = nuki_lock_ns.class_('NukiLockComponent', lock.Lock, switch.Switch, cg.Component) NukiLockUnpairButton = nuki_lock_ns.class_("NukiLockUnpairButton", button.Button, cg.Component) + NukiLockPairingModeSwitch = nuki_lock_ns.class_("NukiLockPairingModeSwitch", switch.Switch, cg.Component) NukiLockAutoUnlatchEnabledSwitch = nuki_lock_ns.class_("NukiLockAutoUnlatchEnabledSwitch", switch.Switch, cg.Component) NukiLockButtonEnabledSwitch = nuki_lock_ns.class_("NukiLockButtonEnabledSwitch", switch.Switch, cg.Component) @@ -155,8 +156,10 @@ NukiLockAutoUnlockDisabledSwitch = nuki_lock_ns.class_("NukiLockAutoUnlockDisabledSwitch", switch.Switch, cg.Component) NukiLockImmediateAutoLockEnabledSwitch = nuki_lock_ns.class_("NukiLockImmediateAutoLockEnabledSwitch", switch.Switch, cg.Component) NukiLockAutoUpdateEnabledSwitch = nuki_lock_ns.class_("NukiLockAutoUpdateEnabledSwitch", switch.Switch, cg.Component) + NukiLockLedBrightnessNumber = nuki_lock_ns.class_("NukiLockLedBrightnessNumber", number.Number, cg.Component) NukiLockSecurityPinNumber = nuki_lock_ns.class_("NukiLockSecurityPinNumber", number.Number, cg.Component) + NukiLockSingleButtonPressActionSelect = nuki_lock_ns.class_("NukiLockSingleButtonPressActionSelect", select.Select, cg.Component) NukiLockDoubleButtonPressActionSelect = nuki_lock_ns.class_("NukiLockDoubleButtonPressActionSelect", select.Select, cg.Component) NukiLockFobAction1Select = nuki_lock_ns.class_("NukiLockFobAction1Select", select.Select, cg.Component) @@ -179,12 +182,12 @@ CONFIG_SCHEMA = lock.LOCK_SCHEMA.extend({ cv.GenerateID(): cv.declare_id(NukiLock), - cv.Required(CONF_IS_CONNECTED): binary_sensor.binary_sensor_schema( + cv.Optional(CONF_IS_CONNECTED): binary_sensor.binary_sensor_schema( device_class=DEVICE_CLASS_CONNECTIVITY, entity_category=ENTITY_CATEGORY_DIAGNOSTIC, icon="mdi:link" ), - cv.Required(CONF_IS_PAIRED): binary_sensor.binary_sensor_schema( + cv.Optional(CONF_IS_PAIRED): binary_sensor.binary_sensor_schema( device_class=DEVICE_CLASS_CONNECTIVITY, entity_category=ENTITY_CATEGORY_DIAGNOSTIC, icon="mdi:link"