Various fixes

This commit is contained in:
iranl
2024-04-26 19:48:50 +02:00
parent c9710ef396
commit 20909b5764
14 changed files with 117 additions and 73 deletions

View File

@@ -21,46 +21,45 @@ jobs:
run: pip install --upgrade platformio
- name: Install ESPTool
run: pip install --upgrade esptool
- name: Build PlatformIO Project esp32dev
- name: Build PlatformIO Project esp32
run: |
pio run --environment esp32dev
mkdir -p release/esp32dev
cp .pio/build/esp32dev/firmware.bin release/esp32dev/nuki_hub.bin
cp .pio/build/esp32dev/firmware.bin release/esp32dev/nuki_hub_esp32.bin
cp .pio/build/esp32dev/partitions.bin release/esp32dev/nuki_hub.partitions.bin
cp .pio/build/esp32dev/bootloader.bin release/esp32dev/bootloader.bin
esptool.py --chip esp32 merge_bin -o release/esp32dev/nuki_hub_esp32.bin --flash_mode dio --flash_freq keep --flash_size keep 0x1000 release/esp32dev/bootloader.bin 0x10000 release/esp32dev/nuki_hub.bin 0x8000 release/esp32dev/nuki_hub.partitions.bin
echo "esptool.py --chip esp32 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq keep --flash_size detect 0x1000 bootloader.bin 0x10000 nuki_hub.bin 0x8000 nuki_hub.partitions.bin" > release/esp32dev/flash.sh
esptool.py --chip esp32 merge_bin -o release/esp32dev/webflash_nuki_hub_esp32.bin --flash_mode dio --flash_freq keep --flash_size keep 0x1000 release/esp32dev/bootloader.bin 0x10000 release/esp32dev/nuki_hub_esp32.bin 0x8000 release/esp32dev/nuki_hub.partitions.bin
echo "esptool.py --chip esp32 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq keep --flash_size detect 0x1000 bootloader.bin 0x10000 nuki_hub_esp32.bin 0x8000 nuki_hub.partitions.bin" > release/esp32dev/flash.sh
- name: Build PlatformIO Project esp32-s3
run: |
pio run --environment esp32-s3
mkdir -p release/esp32-s3
cp .pio/build/esp32-s3/firmware.bin release/esp32-s3/nuki_hub.bin
cp .pio/build/esp32-s3/firmware.bin release/esp32-s3/nuki_hub_esp32s3.bin
cp .pio/build/esp32-s3/partitions.bin release/esp32-s3/nuki_hub.partitions.bin
cp .pio/build/esp32-s3/bootloader.bin release/esp32-s3/bootloader.bin
esptool.py --chip esp32s3 merge_bin -o release/esp32-s3/nuki_hub_esp32s3.bin --flash_mode dio --flash_freq keep --flash_size keep 0x0 release/esp32-s3/bootloader.bin 0x10000 release/esp32-s3/nuki_hub.bin 0x8000 release/esp32-s3/nuki_hub.partitions.bin
echo "esptool.py --chip esp32s3 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq keep --flash_size detect 0x0 bootloader.bin 0x10000 nuki_hub.bin 0x8000 nuki_hub.partitions.bin" > release/esp32-s3/flash.sh
esptool.py --chip esp32s3 merge_bin -o release/esp32-s3/webflash_nuki_hub_esp32s3.bin --flash_mode dio --flash_freq keep --flash_size keep 0x0 release/esp32-s3/bootloader.bin 0x10000 release/esp32-s3/nuki_hub_esp32s3.bin 0x8000 release/esp32-s3/nuki_hub.partitions.bin
echo "esptool.py --chip esp32s3 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq keep --flash_size detect 0x0 bootloader.bin 0x10000 nuki_hub_esp32s3.bin 0x8000 nuki_hub.partitions.bin" > release/esp32-s3/flash.sh
- name: Build PlatformIO Project esp32-c3
run: |
pio run --environment esp32-c3
mkdir -p release/esp32-c3
cp .pio/build/esp32-c3/firmware.bin release/esp32-c3/nuki_hub.bin
cp .pio/build/esp32-c3/firmware.bin release/esp32-c3/nuki_hub_esp32c3.bin
cp .pio/build/esp32-c3/partitions.bin release/esp32-c3/nuki_hub.partitions.bin
cp .pio/build/esp32-c3/bootloader.bin release/esp32-c3/bootloader.bin
esptool.py --chip esp32c3 merge_bin -o release/esp32-c3/nuki_hub_esp32c3.bin --flash_mode dio --flash_freq keep --flash_size keep 0x0 release/esp32-c3/bootloader.bin 0x10000 release/esp32-c3/nuki_hub.bin 0x8000 release/esp32-c3/nuki_hub.partitions.bin
echo "esptool.py --chip esp32c3 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq keep --flash_size detect 0x0 bootloader.bin 0x10000 nuki_hub.bin 0x8000 nuki_hub.partitions.bin" > release/esp32-c3/flash.sh
esptool.py --chip esp32c3 merge_bin -o release/esp32-c3/webflash_nuki_hub_esp32c3.bin --flash_mode dio --flash_freq keep --flash_size keep 0x0 release/esp32-c3/bootloader.bin 0x10000 release/esp32-c3/nuki_hub_esp32c3.bin 0x8000 release/esp32-c3/nuki_hub.partitions.bin
echo "esptool.py --chip esp32c3 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq keep --flash_size detect 0x0 bootloader.bin 0x10000 nuki_hub_esp32c3.bin 0x8000 nuki_hub.partitions.bin" > release/esp32-c3/flash.sh
- name: Build PlatformIO Project esp32solo1
run: |
pio run --environment esp32solo1
mkdir -p release/esp32solo1
cp .pio/build/esp32solo1/firmware.bin release/esp32solo1/nuki_hub.bin
cp .pio/build/esp32solo1/firmware.bin release/esp32solo1/nuki_hub_esp32solo1.bin
cp .pio/build/esp32solo1/partitions.bin release/esp32solo1/nuki_hub.partitions.bin
cp .pio/build/esp32solo1/bootloader.bin release/esp32solo1/bootloader.bin
esptool.py --chip esp32 merge_bin -o release/esp32solo1/nuki_hub_esp32solo1.bin --flash_mode dio --flash_freq keep --flash_size keep 0x1000 release/esp32solo1/bootloader.bin 0x10000 release/esp32solo1/nuki_hub.bin 0x8000 release/esp32solo1/nuki_hub.partitions.bin
echo "esptool.py --chip esp32 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq keep --flash_size detect 0x1000 bootloader.bin 0x10000 nuki_hub.bin 0x8000 nuki_hub.partitions.bin" > release/esp32solo1/flash.sh
- name: Upload Artifact esp32dev
echo "esptool.py --chip esp32 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq keep --flash_size detect 0x1000 bootloader.bin 0x10000 nuki_hub_esp32solo1.bin 0x8000 nuki_hub.partitions.bin" > release/esp32solo1/flash.sh
- name: Upload Artifact esp32
uses: actions/upload-artifact@v4
with:
name: esp32dev-assets
name: esp32-assets
path: release/esp32dev
- name: Upload Artifact esp32-s3
uses: actions/upload-artifact@v4

View File

@@ -1,10 +1,23 @@
#pragma once
#include "sdkconfig.h"
#define NUKI_HUB_VERSION "8.34-pre-4"
#define GITHUB_LATEST_RELEASE_URL "https://github.com/technyon/nuki_hub/releases/latest"
#define GITHUB_LATEST_RELEASE_API_URL "https://api.github.com/repos/technyon/nuki_hub/releases/latest"
#define GITHUB_LATEST_RELEASE_BINARY_URL "https://github.com/technyon/nuki_hub/raw/master/webflash/nuki_hub.bin"
#if defined(CONFIG_IDF_TARGET_ESP32C3)
#define GITHUB_LATEST_RELEASE_BINARY_URL "https://github.com/technyon/nuki_hub/raw/master/ota/nuki_hub_esp32c3.bin"
#elif defined(CONFIG_IDF_TARGET_ESP32S3)
#define GITHUB_LATEST_RELEASE_BINARY_URL "https://github.com/technyon/nuki_hub/raw/master/ota/nuki_hub_esp32s3.bin"
#else
#if defined(FRAMEWORK_ARDUINO_SOLO1)
#define GITHUB_LATEST_RELEASE_BINARY_URL "https://github.com/technyon/nuki_hub/raw/master/ota/nuki_hub_esp32solo1.bin"
#else
#define GITHUB_LATEST_RELEASE_BINARY_URL "https://github.com/technyon/nuki_hub/raw/master/ota/nuki_hub_esp32.bin"
#endif
#endif
#define MQTT_QOS_LEVEL 1
#define MQTT_CLEAN_SESSIONS false

View File

@@ -508,7 +508,7 @@ void NukiOpenerWrapper::updateKeypad()
{
std::list<NukiLock::KeypadEntry> entries;
_nukiOpener.getKeypadEntries(&entries);
Log->print(F("Opener keypad codes: "));
Log->println(entries.size());
@@ -552,7 +552,7 @@ void NukiOpenerWrapper::updateTimeControl(bool retrieved)
{
std::list<NukiOpener::TimeControlEntry> timeControlEntries;
_nukiOpener.getTimeControlEntries(&timeControlEntries);
Log->print(F("Opener time control entries: "));
Log->println(timeControlEntries.size());
@@ -593,14 +593,18 @@ LockActionResult NukiOpenerWrapper::onLockActionReceivedCallback(const char *val
{
NukiOpener::LockAction action;
if(strlen(value) > 0)
if(value)
{
action = nukiOpenerInst->lockActionToEnum(value);
if((int)action == 0xff)
if(strlen(value) > 0)
{
return LockActionResult::UnknownAction;
action = nukiOpenerInst->lockActionToEnum(value);
if((int)action == 0xff)
{
return LockActionResult::UnknownAction;
}
}
else return LockActionResult::UnknownAction;
}
else return LockActionResult::UnknownAction;
@@ -803,7 +807,7 @@ void NukiOpenerWrapper::onConfigUpdateReceived(const char *value)
if(json[basicKeys[i]])
{
const char *jsonchar = json[basicKeys[i]].as<const char*>();
if(strlen(jsonchar) == 0)
{
jsonResult[basicKeys[i]] = "noValueSet";
@@ -984,7 +988,7 @@ void NukiOpenerWrapper::onConfigUpdateReceived(const char *value)
if(json[advancedKeys[i]])
{
const char *jsonchar = json[advancedKeys[i]].as<const char*>();
if(strlen(jsonchar) == 0)
{
jsonResult[advancedKeys[i]] = "noValueSet";
@@ -1420,7 +1424,7 @@ void NukiOpenerWrapper::onKeypadJsonCommandReceived(const char *value)
_network->publishKeypadJsonCommandResult("configNotReady");
return;
}
if(!_keypadEnabled)
{
_network->publishKeypadJsonCommandResult("keypadDisabled");
@@ -1503,7 +1507,7 @@ void NukiOpenerWrapper::onKeypadJsonCommandReceived(const char *value)
unsigned int allowedUntilTimeAr[2];
uint8_t allowedWeekdaysInt = 0;
if(timeLimited == 1 && enabled != 0)
if(timeLimited == 1)
{
if(allowedFrom)
{
@@ -1655,6 +1659,18 @@ void NukiOpenerWrapper::onKeypadJsonCommandReceived(const char *value)
}
else if (strcmp(action, "update") == 0)
{
if(!codeId)
{
_network->publishKeypadJsonCommandResult("noCodeIdSet");
return;
}
if(!idExists)
{
_network->publishKeypadJsonCommandResult("noExistingCodeIdSet");
return;
}
NukiOpener::UpdatedKeypadEntry entry;
memset(&entry, 0, sizeof(entry));
entry.codeId = codeId;
@@ -1759,9 +1775,8 @@ void NukiOpenerWrapper::onTimeControlCommandReceived(const char *value)
const char *lockAct = json["lockAction"].as<const char*>();
NukiOpener::LockAction timeControlLockAction;
if(strlen(lockAct) > 0)
if(lockAct)
{
timeControlLockAction = nukiOpenerInst->lockActionToEnum(lockAct);
if((int)timeControlLockAction == 0xff)
@@ -1770,11 +1785,6 @@ void NukiOpenerWrapper::onTimeControlCommandReceived(const char *value)
return;
}
}
else
{
_network->publishTimeControlCommandResult("invalidLockAction");
return;
}
if(action)
{
@@ -1859,6 +1869,12 @@ void NukiOpenerWrapper::onTimeControlCommandReceived(const char *value)
}
else if (strcmp(action, "update") == 0)
{
if(!idExists)
{
_network->publishTimeControlCommandResult("noExistingEntryIdSet");
return;
}
NukiOpener::TimeControlEntry entry;
memset(&entry, 0, sizeof(entry));
entry.entryId = entryId;

View File

@@ -575,17 +575,21 @@ LockActionResult NukiWrapper::onLockActionReceivedCallback(const char *value)
{
NukiLock::LockAction action;
if(strlen(value) > 0)
if(value)
{
action = nukiInst->lockActionToEnum(value);
if((int)action == 0xff)
if(strlen(value) > 0)
{
return LockActionResult::UnknownAction;
action = nukiInst->lockActionToEnum(value);
if((int)action == 0xff)
{
return LockActionResult::UnknownAction;
}
}
else return LockActionResult::UnknownAction;
}
else return LockActionResult::UnknownAction;
nukiLockPreferences = new Preferences();
nukiLockPreferences->begin("nukihub", true);
uint32_t aclPrefs[17];
@@ -1490,7 +1494,7 @@ void NukiWrapper::onKeypadJsonCommandReceived(const char *value)
unsigned int allowedUntilTimeAr[2];
uint8_t allowedWeekdaysInt = 0;
if(timeLimited == 1 && enabled != 0)
if(timeLimited == 1)
{
if(allowedFrom)
{
@@ -1642,6 +1646,18 @@ void NukiWrapper::onKeypadJsonCommandReceived(const char *value)
}
else if (strcmp(action, "update") == 0)
{
if(!codeId)
{
_network->publishKeypadJsonCommandResult("noCodeIdSet");
return;
}
if(!idExists)
{
_network->publishKeypadJsonCommandResult("noExistingCodeIdSet");
return;
}
NukiLock::UpdatedKeypadEntry entry;
memset(&entry, 0, sizeof(entry));
entry.codeId = codeId;
@@ -1746,9 +1762,8 @@ void NukiWrapper::onTimeControlCommandReceived(const char *value)
const char *lockAct = json["lockAction"].as<const char*>();
NukiLock::LockAction timeControlLockAction;
if(strlen(lockAct) > 0)
if(lockAct)
{
timeControlLockAction = nukiInst->lockActionToEnum(lockAct);
if((int)timeControlLockAction == 0xff)
@@ -1757,12 +1772,7 @@ void NukiWrapper::onTimeControlCommandReceived(const char *value)
return;
}
}
else
{
_network->publishTimeControlCommandResult("invalidLockAction");
return;
}
if(action)
{
bool idExists = false;
@@ -1846,6 +1856,12 @@ void NukiWrapper::onTimeControlCommandReceived(const char *value)
}
else if (strcmp(action, "update") == 0)
{
if(!idExists)
{
_network->publishTimeControlCommandResult("noExistingEntryIdSet");
return;
}
NukiLock::TimeControlEntry entry;
memset(&entry, 0, sizeof(entry));
entry.entryId = entryId;

View File

@@ -15,10 +15,12 @@ Feel free to join us on Discord: https://discord.gg/feB9FnMY
## Supported devices
<b>Supported ESP32 devices:</b>
- All dual-core ESP32 models with WIFI and BLE which are supported by Arduino Core 2.0.15 should work. Tested builds are provided for the ESP32 and ESP32-S3.
- Single-core ESP32 models with WIFI and BLE which are supported by Arduino Core 2.0.15 might work. Untested builds are provided for the ESP32-C3 and ESP32-Solo1.
- All ESP32 models with WIFI and BLE which are supported by Arduino Core 2.0.15 should work. Tested builds are provided for the ESP32, ESP32-S3 and ESP32-C3.
- Untested builds are provided for the ESP32-Solo1.
<b>Not supported ESP32 devices:</b>
- The ESP32-S2 has no BLE and as such can't run Nuki Hub.
- The ESP32-C6 and ESP32-H2 are not supported by Arduino Core 2.0.15 as such can't run Nuki Hub (at this time).
- The ESP32-C6 and ESP32-H2 are not supported by Arduino Core 2.0.15 and as such Nuki Hub is not compiled against these targets (at this time).
<b>Supported Nuki devices:</b>
- Nuki Smart Lock 1.0
@@ -438,21 +440,20 @@ For security reasons, the code itself is not published.
To change Nuki Lock/Opener keypad settings set the `keypad/actionJson` topic to a JSON formatted value containing the following nodes.
| Node | Delete | Add | Update | Usage | Possible values |
|------------------|----------|----------|----------|------------------------------------------------------------------------------------------|----------------------------------------------------------------|
| action | Required | Required | Required | The action to execute | "delete", "add", "update" |
| codeId | Required | Not used | Required | The code ID of the existing code to delete or update | Integer |
| code | Not used | Required | Required | The code to create or update | 6-digit Integer without zero's |
| enabled | Not used | Not used | Optional | Enable or disable the code, enabled if not set | 1 = enabled, 0 = disabled |
| name | Not used | Required | Required | The name of the code to create or update | String, max 20 chars |
| timeLimited | Not used | Optional | Optional | If this authorization is restricted to access only at certain times, disabled if not set | 1 = enabled, 0 = disabled |
| allowedFrom | Not used | Optional | Optional | The start timestamp from which access should be allowed (requires timeLimited = 1) | "YYYY-MM-DD HH:MM:SS" |
| allowedUntil | Not used | Optional | Optional | The end timestamp until access should be allowed (requires timeLimited = 1) | "YYYY-MM-DD HH:MM:SS" |
| allowedWeekdays | Not used | Optional | Optional | Allowed weekdays on which access should be allowed (requires timeLimited = 1) | Array of days: "mon", "tue", "wed", "thu" , "fri" "sat", "sun" |
| allowedFromTime | Not used | Optional | Optional | The start time per day from which access should be allowed (requires timeLimited = 1) | "HH:MM" |
| allowedUntilTime | Not used | Optional | Optional | The end time per day until access should be allowed (requires timeLimited = 1) | "HH:MM" |
| Node | Delete | Add | Update | Usage | Possible values |
|------------------|----------|----------|----------|------------------------------------------------------------------------------------------------------------------|----------------------------------------|
| action | Required | Required | Required | The action to execute | "delete", "add", "update" |
| codeId | Required | Not used | Required | The code ID of the existing code to delete or update | Integer |
| code | Not used | Required | Required | The code to create or update | 6-digit Integer without zero's, can't start with "12"|
| enabled | Not used | Not used | Optional | Enable or disable the code, always enabled on add, disabled if not set on update | 1 = enabled, 0 = disabled |
| name | Not used | Required | Required | The name of the code to create or update | String, max 20 chars |
| timeLimited | Not used | Optional | Optional | If this authorization is restricted to access only at certain times, disabled if not set (requires enabled = 1) | 1 = enabled, 0 = disabled |
| allowedFrom | Not used | Optional | Optional | The start timestamp from which access should be allowed (requires enabled = 1 and timeLimited = 1) | "YYYY-MM-DD HH:MM:SS" |
| allowedUntil | Not used | Optional | Optional | The end timestamp until access should be allowed (requires enabled = 1 and timeLimited = 1) | "YYYY-MM-DD HH:MM:SS" |
| allowedWeekdays | Not used | Optional | Optional | Weekdays on which access should be allowed (requires enabled = 1 and timeLimited = 1) | Array of days: "mon", "tue", "wed", "thu" , "fri" "sat", "sun"|
| allowedFromTime | Not used | Optional | Optional | The start time per day from which access should be allowed (requires enabled = 1 and timeLimited = 1) | "HH:MM" |
| allowedUntilTime | Not used | Optional | Optional | The end time per day until access should be allowed (requires enabled = 1 and timeLimited = 1) | "HH:MM" |
Example usage:<br>
Examples:
- Delete: `{ "action": "delete", "codeId": "1234" }`
- Add: `{ "action": "add", "code": "589472", "name": "Test", "timeLimited": "1", "allowedFrom": "2024-04-12 10:00:00", "allowedUntil": "2034-04-12 10:00:00", "allowedWeekdays": [ "wed", "thu", "fri" ], "allowedFromTime": "08:00", "allowedUntilTime": "16:00" }`
@@ -510,12 +511,11 @@ To change Nuki Lock/Opener time control settings set the `timecontrol/actionJson
|------------------|----------|----------|----------|------------------------------------------------------------------------------------------|----------------------------------------------------------------|
| action | Required | Required | Required | The action to execute | "delete", "add", "update" |
| entryId | Required | Not used | Required | The entry ID of the existing entry to delete or update | Integer |
| enabled | Not used | Not used | Optional | Enable or disable the entry, enabled if not set | 1 = enabled, 0 = disabled |
| weekdays | Not used | Optional | Optional | Weekdays on which the chosen lock action should be exectued | Array of days: "mon", "tue", "wed", "thu" , "fri" "sat", "sun" |
| time | Not used | Required | Required | The time on which the chosen lock action should be executed | "HH:MM" |
| lockAction | Not used | Required | Required | The lock action that should be executed on the chosen weekdays at the chosen time | For the Nuki lock: "Unlock", "Lock", "Unlatch", "LockNgo", "LockNgoUnlatch", "FullLock". For the Nuki Opener: "ActivateRTO", "DeactivateRTO", "ElectricStrikeActuation", "ActivateCM", "DeactivateCM" |
| enabled | Not used | Not used | Optional | Enable or disable the entry, always enabled on add, disabled if not set on update | 1 = enabled, 0 = disabled |
| weekdays | Not used | Optional | Optional | Weekdays on which the chosen lock action should be exectued (requires enabled = 1) | Array of days: "mon", "tue", "wed", "thu" , "fri" "sat", "sun" |
| time | Not used | Required | Required | The time on which the chosen lock action should be executed (requires enabled = 1) | "HH:MM" |
| lockAction | Not used | Required | Required | The lock action that should be executed on the chosen weekdays at the chosen time (requires enabled = 1) | For the Nuki lock: "Unlock", "Lock", "Unlatch", "LockNgo", "LockNgoUnlatch", "FullLock". For the Nuki Opener: "ActivateRTO", "DeactivateRTO", "ElectricStrikeActuation", "ActivateCM", "DeactivateCM |
Example usage:<br>
Examples:
- Delete: `{ "action": "delete", "entryId": "1234" }`
- Add: `{ "action": "add", "weekdays": [ "wed", "thu", "fri" ], "time": "08:00", "lockAction": "Unlock" }`

BIN
ota/nuki_hub_esp32.bin Normal file

Binary file not shown.

BIN
ota/nuki_hub_esp32c3.bin Normal file

Binary file not shown.

BIN
ota/nuki_hub_esp32s3.bin Normal file

Binary file not shown.

BIN
ota/nuki_hub_esp32solo1.bin Normal file

Binary file not shown.

View File

@@ -14,13 +14,13 @@
{
"chipFamily": "ESP32-S3",
"parts": [
{ "path": "nuki_hub_esp32s3.bin", "offset": 0 },
{ "path": "webflash_nuki_hub_esp32s3.bin", "offset": 0 }
]
},
{
"chipFamily": "ESP32-C3",
"parts": [
{ "path": "nuki_hub_esp32c3.bin", "offset": 0 },
{ "path": "webflash_nuki_hub_esp32c3.bin", "offset": 0 }
]
}
]

Binary file not shown.

Binary file not shown.

Binary file not shown.