diff --git a/README.md b/README.md index 091c1cd..3e92347 100644 --- a/README.md +++ b/README.md @@ -107,6 +107,8 @@ lock: name: "Nuki Daylight Saving Time" auto_battery_type_detection_enabled: name: "Nuki Automatic Battery Type Detection" + slow_speed_during_night_mode_enabled: + name: "Nuki Slow Speed During Night Mode" # Optional: Select Inputs single_buton_press_action: name: "Nuki Button: Single Press Action" @@ -124,6 +126,8 @@ lock: name: "Nuki Advertising Mode" battery_type: name: "Nuki Battery Type" + motor_speed: + name: "Nuki Motor Speed" # Optional: Buttons unpair: name: "Nuki Unpair Device" @@ -228,6 +232,8 @@ lock: name: "Nuki Daylight Saving Time" auto_battery_type_detection_enabled: name: "Nuki Automatic Battery Type Detection" + slow_speed_during_night_mode_enabled: + name: "Nuki Slow Speed During Night Mode" # Optional: Select Inputs single_buton_press_action: name: "Nuki Button: Single Press Action" @@ -245,6 +251,8 @@ lock: name: "Nuki Advertising Mode" battery_type: name: "Nuki Battery Type" + motor_speed: + name: "Nuki Motor Speed" # Optional: Buttons unpair: name: "Nuki Unpair Device" @@ -458,7 +466,8 @@ context: - Single Lock - Daylight Saving Time - Automatic Updates -- Automatic Battery Type Detection +- Automatic Battery Type Detection (Smart Lock Gen 1-4) +- Slow Speed During Night Mode (Smart Lock Ultra) **Select Input:** - Single Button Press Action @@ -468,7 +477,8 @@ context: - Fob Action 3 - Timezone - Advertising Mode -- Battery Type +- Battery Type (Smart Lock Gen 1-4) +- Motor Speed (Smart Lock Ultra) **Number Input:** - LED Brightness diff --git a/components/nuki_lock/lock.py b/components/nuki_lock/lock.py index dd864f5..1daa197 100644 --- a/components/nuki_lock/lock.py +++ b/components/nuki_lock/lock.py @@ -161,6 +161,7 @@ CONF_PAIRING_MODE_TIMEOUT = "pairing_mode_timeout" CONF_PAIRING_AS_APP = "pairing_as_app" CONF_SECURITY_PIN = "security_pin" +CONF_ULTRA_PAIRING_MODE = "ultra_pairing_mode" CONF_ALT_CONNECT_MODE = "alternative_connect_mode" CONF_QUERY_INTERVAL_CONFIG = "query_interval_config" CONF_QUERY_INTERVAL_AUTH_DATA = "query_interval_auth_data" @@ -193,7 +194,7 @@ NukiLockSingleLockEnabledSwitch = nuki_lock_ns.class_("NukiLockSingleLockEnabledSwitch", switch.Switch, cg.Component) NukiLockDstModeEnabledSwitch = nuki_lock_ns.class_("NukiLockDstModeEnabledSwitch", switch.Switch, cg.Component) NukiLockAutoBatteryTypeDetectionEnabledSwitch = nuki_lock_ns.class_("NukiLockAutoBatteryTypeDetectionEnabledSwitch", switch.Switch, cg.Component) -#NukiLockSlowSpeedDuringNightModeEnabledSwitch = nuki_lock_ns.class_("NukiLockSlowSpeedDuringNightModeEnabledSwitch", switch.Switch, cg.Component) +NukiLockSlowSpeedDuringNightModeEnabledSwitch = nuki_lock_ns.class_("NukiLockSlowSpeedDuringNightModeEnabledSwitch", switch.Switch, cg.Component) NukiLockLedBrightnessNumber = nuki_lock_ns.class_("NukiLockLedBrightnessNumber", number.Number, cg.Component) NukiLockTimeZoneOffsetNumber = nuki_lock_ns.class_("NukiLockTimeZoneOffsetNumber", number.Number, cg.Component) @@ -207,7 +208,7 @@ NukiLockTimeZoneSelect = nuki_lock_ns.class_("NukiLockTimeZoneSelect", select.Select, cg.Component) NukiLockAdvertisingModeSelect = nuki_lock_ns.class_("NukiLockAdvertisingModeSelect", select.Select, cg.Component) NukiLockBatteryTypeSelect = nuki_lock_ns.class_("NukiLockBatteryTypeSelect", select.Select, cg.Component) -#NukiLockMotorSpeedSelect = nuki_lock_ns.class_("NukiLockMotorSpeedSelect", select.Select, cg.Component) +NukiLockMotorSpeedSelect = nuki_lock_ns.class_("NukiLockMotorSpeedSelect", select.Select, cg.Component) NukiLockUnpairAction = nuki_lock_ns.class_( "NukiLockUnpairAction", automation.Action @@ -377,12 +378,12 @@ def _validate(config): entity_category=ENTITY_CATEGORY_CONFIG, icon="mdi:battery-check", ), - #cv.Optional(CONF_SLOW_SPEED_DURING_NIGHT_MODE_ENABLED_SWITCH): switch.switch_schema( - # NukiLockSlowSpeedDuringNightModeEnabledSwitch, - # device_class=DEVICE_CLASS_SWITCH, - # entity_category=ENTITY_CATEGORY_CONFIG, - # icon="mdi:speedometer-slow", - #), + cv.Optional(CONF_SLOW_SPEED_DURING_NIGHT_MODE_ENABLED_SWITCH): switch.switch_schema( + NukiLockSlowSpeedDuringNightModeEnabledSwitch, + device_class=DEVICE_CLASS_SWITCH, + entity_category=ENTITY_CATEGORY_CONFIG, + icon="mdi:speedometer-slow", + ), cv.Optional(CONF_LED_BRIGHTNESS_NUMBER): number.number_schema( NukiLockLedBrightnessNumber, entity_category=ENTITY_CATEGORY_CONFIG, @@ -438,16 +439,17 @@ def _validate(config): entity_category=ENTITY_CATEGORY_CONFIG, icon="mdi:battery", ), - #cv.Optional(CONF_MOTOR_SPEED_SELECT): select.select_schema( - # NukiLockMotorSpeedSelect, - # entity_category=ENTITY_CATEGORY_CONFIG, - # icon="mdi:speedometer-medium", - #), + cv.Optional(CONF_MOTOR_SPEED_SELECT): select.select_schema( + NukiLockMotorSpeedSelect, + entity_category=ENTITY_CATEGORY_CONFIG, + icon="mdi:speedometer-medium", + ), + cv.Optional(CONF_ULTRA_PAIRING_MODE, default="false"): cv.boolean, cv.Optional(CONF_ALT_CONNECT_MODE, default="true"): cv.boolean, cv.Optional(CONF_PAIRING_AS_APP, default="false"): cv.boolean, cv.Optional(CONF_PAIRING_MODE_TIMEOUT, default="300s"): cv.positive_time_period_seconds, cv.Optional(CONF_EVENT, default="nuki"): cv.string, - cv.Optional(CONF_SECURITY_PIN): cv.uint16_t, + cv.Optional(CONF_SECURITY_PIN): cv.uint32_t, cv.Optional(CONF_QUERY_INTERVAL_CONFIG, default="3600s"): cv.positive_time_period_seconds, cv.Optional(CONF_QUERY_INTERVAL_AUTH_DATA, default="3600s"): cv.positive_time_period_seconds, cv.Optional(CONF_ON_PAIRING_MODE_ON): automation.validate_automation( @@ -490,8 +492,11 @@ async def to_code(config): if CONF_PAIRING_AS_APP in config: cg.add(var.set_pairing_as_app(config[CONF_PAIRING_AS_APP])) - if config[CONF_ALT_CONNECT_MODE]: - cg.add_define("NUKI_ALT_CONNECT") + if config[CONF_ALT_CONNECT_MODE]: + cg.add_define("NUKI_ALT_CONNECT") + + if CONF_ULTRA_PAIRING_MODE in config: + cg.add(var.set_ultra_pairing_mode(config[CONF_ULTRA_PAIRING_MODE])) if CONF_ALT_CONNECT_MODE in config: cg.add(var.set_alt_connect_mode(config[CONF_ALT_CONNECT_MODE])) @@ -653,10 +658,10 @@ async def to_code(config): await cg.register_parented(s, config[CONF_ID]) cg.add(var.set_auto_battery_type_detection_enabled_switch(s)) - #if slow_speed_during_night_mode := config.get(CONF_SLOW_SPEED_DURING_NIGHT_MODE_ENABLED_SWITCH): - # s = await switch.new_switch(slow_speed_during_night_mode) - # await cg.register_parented(s, config[CONF_ID]) - # cg.add(var.set_slow_speed_during_night_mode_enabled_switch(s)) + if slow_speed_during_night_mode := config.get(CONF_SLOW_SPEED_DURING_NIGHT_MODE_ENABLED_SWITCH): + s = await switch.new_switch(slow_speed_during_night_mode) + await cg.register_parented(s, config[CONF_ID]) + cg.add(var.set_slow_speed_during_night_mode_enabled_switch(s)) # Select if single_button_press_action := config.get(CONF_SINGLE_BUTTON_PRESS_ACTION_SELECT): @@ -723,13 +728,13 @@ async def to_code(config): await cg.register_parented(sel, config[CONF_ID]) cg.add(var.set_battery_type_select(sel)) - #if motor_speed := config.get(CONF_MOTOR_SPEED_SELECT): - # sel = await select.new_select( - # motor_speed, - # options=[CONF_MOTOR_SPEED_SELECT_OPTIONS], - # ) - # await cg.register_parented(sel, config[CONF_ID]) - # cg.add(var.set_motor_speed_select(sel)) + if motor_speed := config.get(CONF_MOTOR_SPEED_SELECT): + sel = await select.new_select( + motor_speed, + options=[CONF_MOTOR_SPEED_SELECT_OPTIONS], + ) + await cg.register_parented(sel, config[CONF_ID]) + cg.add(var.set_motor_speed_select(sel)) # Callback @@ -887,7 +892,7 @@ async def nuki_lock_set_pairing_mode_to_code(config, action_id, template_arg, ar NUKI_LOCK_SET_SECURITY_PIN_SCHEMA = automation.maybe_simple_id( { cv.GenerateID(): cv.use_id(NukiLock), - cv.Required(CONF_SET_SECURITY_PIN): cv.templatable(cv.uint16_t) + cv.Required(CONF_SET_SECURITY_PIN): cv.templatable(cv.uint32_t) } ) @@ -898,6 +903,6 @@ async def nuki_lock_set_pairing_mode_to_code(config, action_id, template_arg, ar async def nuki_lock_set_security_pin_to_code(config, action_id, template_arg, args): paren = await cg.get_variable(config[CONF_ID]) var = cg.new_Pvariable(action_id, template_arg, paren) - security_pin_template_ = await cg.templatable(config[CONF_SET_SECURITY_PIN], args, cg.uint16) + security_pin_template_ = await cg.templatable(config[CONF_SET_SECURITY_PIN], args, cg.uint32) cg.add(var.set_security_pin(security_pin_template_)) return var \ No newline at end of file diff --git a/components/nuki_lock/nuki_lock.cpp b/components/nuki_lock/nuki_lock.cpp index e80f737..e9c3f51 100644 --- a/components/nuki_lock/nuki_lock.cpp +++ b/components/nuki_lock/nuki_lock.cpp @@ -138,7 +138,7 @@ void NukiLockComponent::homekit_status_to_string(const int status, char* str) { } } -/*void NukiLockComponent::motor_speed_to_string(const NukiLock::MotorSpeed speed, char* str) { +void NukiLockComponent::motor_speed_to_string(const NukiLock::MotorSpeed speed, char* str) { switch (speed) { case NukiLock::MotorSpeed::Standard: strcpy(str, "Standard"); @@ -153,9 +153,9 @@ void NukiLockComponent::homekit_status_to_string(const int status, char* str) { strcpy(str, "undefined"); break; } -}*/ +} -/*NukiLock::MotorSpeed NukiLockComponent::motor_speed_to_enum(const char* str) { +NukiLock::MotorSpeed NukiLockComponent::motor_speed_to_enum(const char* str) { if(strcmp(str, "Standard") == 0) { return NukiLock::MotorSpeed::Standard; } else if(strcmp(str, "Insane") == 0) { @@ -164,7 +164,7 @@ void NukiLockComponent::homekit_status_to_string(const int status, char* str) { return NukiLock::MotorSpeed::Gentle; } return NukiLock::MotorSpeed::Standard; -}*/ +} uint8_t NukiLockComponent::fob_action_to_int(const char *str) { if(strcmp(str, "No Action") == 0) { @@ -703,8 +703,8 @@ void NukiLockComponent::update_config() { ESP_LOGD(TAG, "Firmware: %i.%i.%i", config.firmwareVersion[0], config.firmwareVersion[1], config.firmwareVersion[2]); ESP_LOGD(TAG, "Hardware: %i.%i", config.hardwareRevision[0], config.hardwareRevision[1]); - //ESP_LOGD(TAG, "Has Wifi: %s", YESNO(config.capabilities == 255 ? 0 : config.capabilities & 1)); - //ESP_LOGD(TAG, "Has Thread: %s", YESNO(config.capabilities == 255 ? 0 : ((config.capabilities & 2) != 0 ? 1 : 0))); + ESP_LOGD(TAG, "Has Wifi: %s", YESNO(config.capabilities == 255 ? 0 : config.capabilities & 1)); + ESP_LOGD(TAG, "Has Thread: %s", YESNO(config.capabilities == 255 ? 0 : ((config.capabilities & 2) != 0 ? 1 : 0))); ESP_LOGD(TAG, "Matter Status: %i", (config.matterStatus == 255 ? 0 : config.matterStatus)); memset(str, 0, sizeof(str)); this->homekit_status_to_string(config.homeKitStatus, str); @@ -793,14 +793,14 @@ void NukiLockComponent::update_advanced_config() { } // Gen 1-4 only - if (!this->is_ultra && this->auto_battery_type_detection_enabled_switch_ != nullptr) { + if (!this->ultra_pairing_mode_ && this->auto_battery_type_detection_enabled_switch_ != nullptr) { this->auto_battery_type_detection_enabled_switch_->publish_state(advanced_config.automaticBatteryTypeDetection); } // Ultra only - /*if (this->is_ultra && this->slow_speed_during_night_mode_enabled_switch_ != nullptr) { + if (this->ultra_pairing_mode_ && this->slow_speed_during_night_mode_enabled_switch_ != nullptr) { this->slow_speed_during_night_mode_enabled_switch_->publish_state(advanced_config.enableSlowSpeedDuringNightMode); - }*/ + } #endif #ifdef USE_NUMBER @@ -823,18 +823,18 @@ void NukiLockComponent::update_advanced_config() { } // Gen 1-4 only - if (!this->is_ultra_ && this->battery_type_select_ != nullptr) { + if (!this->ultra_pairing_mode_ && this->battery_type_select_ != nullptr) { memset(str, 0, sizeof(str)); this->battery_type_to_string(advanced_config.batteryType, str); this->battery_type_select_->publish_state(str); } // Ultra - /*if (this->is_ultra_ && this->motor_speed_select_ != nullptr) { + if (this->ultra_pairing_mode_ && this->motor_speed_select_ != nullptr) { memset(str, 0, sizeof(str)); this->motor_speed_to_string(advanced_config.motorSpeed, str); this->motor_speed_select_->publish_state(str); - }*/ + } #endif } else { ESP_LOGE(TAG, "requestAdvancedConfig has resulted in %s (%d)", str, conf_req_result); @@ -1125,7 +1125,7 @@ void NukiLockComponent::use_security_pin(uint32_t security_pin) { // Set new pin if(this->get_pin() != this->security_pin_) { - bool result = this->is_ultra_ ? this->nuki_lock_.saveUltraPincode(this->security_pin_) : this->nuki_lock_.saveSecurityPincode(this->security_pin_); + bool result = this->ultra_pairing_mode_ ? this->nuki_lock_.saveUltraPincode(this->security_pin_) : this->nuki_lock_.saveSecurityPincode(this->security_pin_); if (result) { ESP_LOGI(TAG, "Succesfully set security pin!"); } else { @@ -1141,7 +1141,7 @@ bool NukiLockComponent::is_pin_valid() { } uint32_t NukiLockComponent::get_pin() { - if(this->is_ultra_) { + if(this->ultra_pairing_mode_) { return this->nuki_lock_.getUltraPincode(); } else { return this->nuki_lock_.getSecurityPincode(); @@ -1632,6 +1632,7 @@ void NukiLockComponent::dump_config() { LOG_SWITCH(TAG, "Automatic Updates", this->auto_update_enabled_switch_); LOG_SWITCH(TAG, "Single Lock Enabled", this->single_lock_enabled_switch_); LOG_SWITCH(TAG, "DST Mode Enabled", this->dst_mode_enabled_switch_); + LOG_SWITCH(TAG, "Slow Speed During Night Mode Enabled", this->slow_speed_during_night_mode_enabled_switch_); #endif #ifdef USE_NUMBER LOG_NUMBER(TAG, "LED Brightness", this->led_brightness_number_); @@ -1647,6 +1648,7 @@ void NukiLockComponent::dump_config() { LOG_SELECT(TAG, "Timezone", this->timezone_select_); LOG_SELECT(TAG, "Advertising Mode", this->advertising_mode_select_); LOG_SELECT(TAG, "Battery Type", this->battery_type_select_); + LOG_SELECT(TAG, "Motor Speed", this->motor_speed_select_); #endif } @@ -1756,15 +1758,15 @@ void NukiLockComponent::set_config_select(const char* config, const char* value) } else if (strcmp(config, "advertising_mode") == 0) { Nuki::AdvertisingMode mode = this->advertising_mode_to_enum(value); cmd_result = this->nuki_lock_.setAdvertisingMode(mode); - } else if (!this->is_ultra && strcmp(config, "battery_type") == 0) { + } else if (!this->ultra_pairing_mode_ && strcmp(config, "battery_type") == 0) { Nuki::BatteryType type = this->battery_type_to_enum(value); cmd_result = this->nuki_lock_.setBatteryType(type); is_advanced = true; - }/*else if (this->is_ultra && strcmp(config, "motor_speed") == 0) { - Nuki::MotorSpeed speed = this->motor_speed_to_enum(value); + }else if (this->ultra_pairing_mode_ && strcmp(config, "motor_speed") == 0) { + NukiLock::MotorSpeed speed = this->motor_speed_to_enum(value); cmd_result = this->nuki_lock_.setMotorSpeed(speed); is_advanced = true; - }*/ + } if (cmd_result == Nuki::CmdResult::Success) { if (strcmp(config, "single_button_press_action") == 0 && this->single_button_press_action_select_ != nullptr) { @@ -1783,9 +1785,9 @@ void NukiLockComponent::set_config_select(const char* config, const char* value) this->advertising_mode_select_->publish_state(value); } else if (strcmp(config, "battery_type") == 0 && this->battery_type_select_ != nullptr) { this->battery_type_select_->publish_state(value); - }/*else if (strcmp(config, "motor_speed") == 0 && this->motor_speed_select_ != nullptr) { + }else if (strcmp(config, "motor_speed") == 0 && this->motor_speed_select_ != nullptr) { this->motor_speed_select_->publish_state(value); - }*/ + } this->config_update_ = !is_advanced; this->advanced_config_update_ = is_advanced; @@ -1836,11 +1838,11 @@ void NukiLockComponent::set_config_switch(const char* config, bool value) { cmd_result = this->nuki_lock_.enableSingleLock(value); } else if (strcmp(config, "dst_mode_enabled") == 0) { cmd_result = this->nuki_lock_.enableDst(value); - } else if (!this->is_ultra && strcmp(config, "auto_battery_type_detection_enabled") == 0) { + } else if (!this->ultra_pairing_mode_ && strcmp(config, "auto_battery_type_detection_enabled") == 0) { cmd_result = this->nuki_lock_.enableAutoBatteryTypeDetection(value); - }/*else if (this->is_ultra && strcmp(config, "slow_speed_during_night_mode_enabled") == 0) { + } else if (this->ultra_pairing_mode_ && strcmp(config, "slow_speed_during_night_mode_enabled") == 0) { cmd_result = this->nuki_lock_.enableSlowSpeedDuringNightMode(value); - }*/ + } if (cmd_result == Nuki::CmdResult::Success) { @@ -1872,9 +1874,9 @@ void NukiLockComponent::set_config_switch(const char* config, bool value) { this->dst_mode_enabled_switch_->publish_state(value); } else if (strcmp(config, "auto_battery_type_detection_enabled") == 0 && this->auto_battery_type_detection_enabled_switch_ != nullptr) { this->auto_battery_type_detection_enabled_switch_->publish_state(value); - }/*else if (strcmp(config, "slow_speed_during_night_mode_enabled") == 0 && this->slow_speed_during_night_mode_enabled_switch_ != nullptr) { + } else if (strcmp(config, "slow_speed_during_night_mode_enabled") == 0 && this->slow_speed_during_night_mode_enabled_switch_ != nullptr) { this->slow_speed_during_night_mode_enabled_switch_->publish_state(value); - }*/ + } this->config_update_ = !is_advanced; this->advanced_config_update_ = is_advanced; @@ -1958,9 +1960,9 @@ void NukiLockBatteryTypeSelect::control(const std::string &mode) { this->parent_->set_config_select("battery_type", mode.c_str()); } -/*void NukiLockMotorSpeedSelect::control(const std::string &mode) { +void NukiLockMotorSpeedSelect::control(const std::string &mode) { this->parent_->set_config_select("motor_speed", mode.c_str()); -}*/ +} #endif #ifdef USE_SWITCH void NukiLockPairingModeSwitch::write_state(bool state) { @@ -2023,9 +2025,9 @@ void NukiLockAutoBatteryTypeDetectionEnabledSwitch::write_state(bool state) { this->parent_->set_config_switch("auto_battery_type_detection_enabled", state); } -/*void NukiLockSlowSpeedDuringNightModeEnabledSwitch::write_state(bool state) { +void NukiLockSlowSpeedDuringNightModeEnabledSwitch::write_state(bool state) { this->parent_->set_config_switch("slow_speed_during_night_mode_enabled", state); -}*/ +} #endif #ifdef USE_NUMBER void NukiLockLedBrightnessNumber::control(float value) { diff --git a/components/nuki_lock/nuki_lock.h b/components/nuki_lock/nuki_lock.h index 9b79e41..882f646 100644 --- a/components/nuki_lock/nuki_lock.h +++ b/components/nuki_lock/nuki_lock.h @@ -84,7 +84,7 @@ class NukiLockComponent : public lock::Lock, public PollingComponent, public Nuk SUB_SELECT(timezone) SUB_SELECT(advertising_mode) SUB_SELECT(battery_type) - //SUB_SELECT(motor_speed) + SUB_SELECT(motor_speed) #endif #ifdef USE_BUTTON SUB_BUTTON(unpair) @@ -105,7 +105,7 @@ class NukiLockComponent : public lock::Lock, public PollingComponent, public Nuk SUB_SWITCH(single_lock_enabled) SUB_SWITCH(dst_mode_enabled) SUB_SWITCH(auto_battery_type_detection_enabled) - //SUB_SWITCH(slow_speed_during_night_mode_enabled) + SUB_SWITCH(slow_speed_during_night_mode_enabled) #endif static const uint8_t BLE_CONNECT_TIMEOUT_SEC = 3; @@ -138,11 +138,12 @@ class NukiLockComponent : public lock::Lock, public PollingComponent, public Nuk void notify(Nuki::EventType event_type) override; float get_setup_priority() const override { return setup_priority::HARDWARE - 1.0f; } + void set_ultra_pairing_mode(bool ultra_pairing_mode) { this->ultra_pairing_mode_ = ultra_pairing_mode; } void set_alt_connect_mode(bool alt_connect_mode) { this->alt_connect_mode_ = alt_connect_mode; } void set_pairing_as_app(bool pairing_as_app) { this->pairing_as_app_ = pairing_as_app; } - void set_pairing_mode_timeout(uint16_t pairing_mode_timeout) { this->pairing_mode_timeout_ = pairing_mode_timeout; } - void set_query_interval_config(uint16_t query_interval_config) { this->query_interval_config_ = query_interval_config; } - void set_query_interval_auth_data(uint16_t query_interval_auth_data) { this->query_interval_auth_data_ = query_interval_auth_data; } + void set_pairing_mode_timeout(uint32_t pairing_mode_timeout) { this->pairing_mode_timeout_ = pairing_mode_timeout; } + void set_query_interval_config(uint32_t query_interval_config) { this->query_interval_config_ = query_interval_config; } + void set_query_interval_auth_data(uint32_t query_interval_auth_data) { this->query_interval_auth_data_ = query_interval_auth_data; } void set_event(const char *event) { this->event_ = event; if(strcmp(event, "esphome.none") != 0) { @@ -171,8 +172,8 @@ class NukiLockComponent : public lock::Lock, public PollingComponent, public Nuk Nuki::BatteryType battery_type_to_enum(const char* str); void battery_type_to_string(const Nuki::BatteryType battery_type, char* str); - // NukiLock::MotorSpeed motor_speed_to_enum(const char* str); - // void motor_speed_to_string(const NukiLock::MotorSpeed speed, char* str); + NukiLock::MotorSpeed motor_speed_to_enum(const char* str); + void motor_speed_to_string(const NukiLock::MotorSpeed speed, char* str); NukiLock::ButtonPressAction button_press_action_to_enum(const char* str); void button_press_action_to_string(NukiLock::ButtonPressAction action, char* str); @@ -231,10 +232,6 @@ class NukiLockComponent : public lock::Lock, public PollingComponent, public Nuk api::CustomAPIDevice custom_api_device_; #endif - std::map auth_entries_; - uint32_t auth_id_ = 0; - char auth_name_[33] = {0}; - uint32_t last_command_executed_time_ = 0; uint32_t command_cooldown_millis = 0; uint8_t action_attempts_ = 0; @@ -248,9 +245,15 @@ class NukiLockComponent : public lock::Lock, public PollingComponent, public Nuk bool open_latch_; bool lock_n_go_; - bool is_ultra_ = false; + uint32_t query_interval_auth_data_ = 0; + uint32_t query_interval_config_ = 0; + + uint32_t pairing_mode_timeout_ = 0; + bool pairing_mode_ = false; + bool ultra_pairing_mode_ = false; bool pairing_as_app_ = false; + bool alt_connect_mode_ = false; PinState pin_state_ = PinState::NotSet; uint32_t security_pin_ = 0; @@ -258,17 +261,12 @@ class NukiLockComponent : public lock::Lock, public PollingComponent, public Nuk const char* event_; bool send_events_ = false; - - bool alt_connect_mode_ = false; - - uint16_t query_interval_auth_data_ = 0; - uint16_t query_interval_config_ = 0; - - uint16_t pairing_mode_timeout_ = 0; - bool pairing_mode_ = false; - uint32_t last_rolling_log_id = 0; + std::map auth_entries_; + uint32_t auth_id_ = 0; + char auth_name_[33] = {0}; + ESPPreferenceObject pref_; private: @@ -409,12 +407,12 @@ class NukiLockBatteryTypeSelect : public select::Select, public Parented { +class NukiLockMotorSpeedSelect : public select::Select, public Parented { public: NukiLockMotorSpeedSelect() = default; protected: void control(const std::string &value) override; -};*/ +}; #endif #ifdef USE_SWITCH @@ -537,13 +535,13 @@ class NukiLockAutoBatteryTypeDetectionEnabledSwitch : public switch_::Switch, pu void write_state(bool state) override; }; -/*class NukiLockSlowSpeedDuringNightModeEnabledSwitch : public switch_::Switch, public Parented { +class NukiLockSlowSpeedDuringNightModeEnabledSwitch : public switch_::Switch, public Parented { public: NukiLockSlowSpeedDuringNightModeEnabledSwitch() = default; protected: void write_state(bool state) override; -};*/ +}; #endif #ifdef USE_NUMBER