commitea34708fd1Merge:e14877b1dcef13Author: Jan-Ole Schümann <j.o.schuemann@gmx.de> Date: Tue Mar 26 20:16:00 2024 +0700 Merge pull request #328 from iranl/ha-fixes Multiple fixes (Nuki ID + README + ACL + DoorSensor/Keypad) commit1dcef135fcAuthor: iranl <iranl@users.noreply.github.com> Date: Sun Mar 24 22:28:44 2024 +0100 Add extra checks and auto retries commit56d718bc00Author: iranl <iranl@users.noreply.github.com> Date: Sat Mar 23 19:52:50 2024 +0100 Remove Force options commita3658bfd3cAuthor: iranl <iranl@users.noreply.github.com> Date: Sun Mar 17 22:57:24 2024 +0100 Update README.md commitef7fe751edAuthor: iranl <iranl@users.noreply.github.com> Date: Sun Mar 17 22:50:46 2024 +0100 Update WebCfgServer.cpp commitac375df39fAuthor: iranl <iranl@users.noreply.github.com> Date: Sun Mar 17 22:47:42 2024 +0100 Redact Nuki ID commit516af39fe6Author: iranl <iranl@users.noreply.github.com> Date: Sun Mar 17 22:40:22 2024 +0100 ACL Info WebCfg + Force Keypad/DoorSensor commit3db4c0699eAuthor: iranl <iranl@users.noreply.github.com> Date: Sun Mar 17 21:59:57 2024 +0100 Nuki ID + README + ACL fix
126 lines
3.9 KiB
C++
126 lines
3.9 KiB
C++
#pragma once
|
|
|
|
#include "NetworkLock.h"
|
|
#include "NukiConstants.h"
|
|
#include "NukiDataTypes.h"
|
|
#include "BleScanner.h"
|
|
#include "NukiLock.h"
|
|
#include "Gpio.h"
|
|
#include "LockActionResult.h"
|
|
#include "NukiDeviceId.h"
|
|
|
|
class NukiWrapper : public Nuki::SmartlockEventHandler
|
|
{
|
|
public:
|
|
NukiWrapper(const std::string& deviceName, NukiDeviceId* deviceId, BleScanner::Scanner* scanner, NetworkLock* network, Gpio* gpio, Preferences* preferences);
|
|
virtual ~NukiWrapper();
|
|
|
|
void initialize(const bool& firstStart);
|
|
void update();
|
|
|
|
void lock();
|
|
void unlock();
|
|
void unlatch();
|
|
void lockngo();
|
|
void lockngounlatch();
|
|
|
|
bool isPinSet();
|
|
void setPin(const uint16_t pin);
|
|
void unpair();
|
|
|
|
void disableHASS();
|
|
|
|
void disableWatchdog();
|
|
|
|
const NukiLock::KeyTurnerState& keyTurnerState();
|
|
const bool isPaired() const;
|
|
const bool hasKeypad() const;
|
|
bool hasDoorSensor() const;
|
|
const BLEAddress getBleAddress() const;
|
|
|
|
std::string firmwareVersion() const;
|
|
std::string hardwareVersion() const;
|
|
|
|
void notify(Nuki::EventType eventType) override;
|
|
|
|
private:
|
|
static LockActionResult onLockActionReceivedCallback(const char* value);
|
|
static void onConfigUpdateReceivedCallback(const char* topic, const char* value);
|
|
static void onKeypadCommandReceivedCallback(const char* command, const uint& id, const String& name, const String& code, const int& enabled);
|
|
static void gpioActionCallback(const GpioAction& action, const int& pin);
|
|
|
|
void onConfigUpdateReceived(const char* topic, const char* value);
|
|
void onKeypadCommandReceived(const char* command, const uint& id, const String& name, const String& code, const int& enabled);
|
|
|
|
void updateKeyTurnerState();
|
|
void updateBatteryState();
|
|
void updateConfig();
|
|
void updateAuthData();
|
|
void updateKeypad();
|
|
void postponeBleWatchdog();
|
|
|
|
void updateGpioOutputs();
|
|
|
|
void readConfig();
|
|
void readAdvancedConfig();
|
|
|
|
void setupHASS();
|
|
|
|
void printCommandResult(Nuki::CmdResult result);
|
|
|
|
NukiLock::LockAction lockActionToEnum(const char* str); // char array at least 14 characters
|
|
|
|
std::string _deviceName;
|
|
NukiDeviceId* _deviceId = nullptr;
|
|
NukiLock::NukiLock _nukiLock;
|
|
BleScanner::Scanner* _bleScanner = nullptr;
|
|
NetworkLock* _network = nullptr;
|
|
Gpio* _gpio = nullptr;
|
|
Preferences* _preferences;
|
|
int _intervalLockstate = 0; // seconds
|
|
int _intervalBattery = 0; // seconds
|
|
int _intervalConfig = 60 * 60; // seconds
|
|
int _intervalKeypad = 0; // seconds
|
|
int _restartBeaconTimeout = 0; // seconds
|
|
bool _publishAuthData = false;
|
|
bool _clearAuthData = false;
|
|
std::vector<uint16_t> _keypadCodeIds;
|
|
|
|
NukiLock::KeyTurnerState _lastKeyTurnerState;
|
|
NukiLock::KeyTurnerState _keyTurnerState;
|
|
|
|
NukiLock::BatteryReport _batteryReport;
|
|
NukiLock::BatteryReport _lastBatteryReport;
|
|
|
|
NukiLock::Config _nukiConfig = {0};
|
|
NukiLock::AdvancedConfig _nukiAdvancedConfig = {0};
|
|
bool _nukiConfigValid = false;
|
|
bool _nukiAdvancedConfigValid = false;
|
|
bool _hassEnabled = false;
|
|
bool _hassSetupCompleted = false;
|
|
|
|
bool _paired = false;
|
|
bool _statusUpdated = false;
|
|
bool _hasKeypad = false;
|
|
bool _keypadEnabled = false;
|
|
uint _maxKeypadCodeCount = 0;
|
|
bool _configRead = false;
|
|
int _nrOfRetries = 0;
|
|
int _retryDelay = 0;
|
|
int _retryCount = 0;
|
|
int _retryConfigCount = 0;
|
|
int _retryLockstateCount = 0;
|
|
long _rssiPublishInterval = 0;
|
|
unsigned long _nextRetryTs = 0;
|
|
unsigned long _nextLockStateUpdateTs = 0;
|
|
unsigned long _nextBatteryReportTs = 0;
|
|
unsigned long _nextConfigUpdateTs = 0;
|
|
unsigned long _nextKeypadUpdateTs = 0;
|
|
unsigned long _nextRssiTs = 0;
|
|
unsigned long _lastRssi = 0;
|
|
unsigned long _disableBleWatchdogTs = 0;
|
|
std::string _firmwareVersion = "";
|
|
std::string _hardwareVersion = "";
|
|
volatile NukiLock::LockAction _nextLockAction = (NukiLock::LockAction)0xff;
|
|
};
|