Merge branch 'technyon:master' into add-configuration-url
This commit is contained in:
48
Docker/Dockerfile
Normal file
48
Docker/Dockerfile
Normal file
@@ -0,0 +1,48 @@
|
||||
FROM eclipse-temurin:11-jdk-jammy AS builder
|
||||
|
||||
RUN set -ex && \
|
||||
apt-get update && \
|
||||
apt-get install -y git cmake xz-utils python3 python3-serial
|
||||
|
||||
RUN curl -L "https://downloads.arduino.cc/arduino-1.8.19-linux64.tar.xz" -o /tmp/arduino-ide.tar.xz
|
||||
RUN tar -xf /tmp/arduino-ide.tar.xz --directory ~/
|
||||
|
||||
RUN cd ~/arduino* && \
|
||||
./install.sh && \
|
||||
./arduino --pref "boardsmanager.additional.urls=https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json" --save-prefs && \
|
||||
./arduino --install-boards esp32:esp32:2.0.9
|
||||
|
||||
RUN git clone --recurse-submodules https://github.com/technyon/Arduino-CMake-Toolchain.git ~/Arduino-CMake-Toolchain
|
||||
|
||||
COPY icon /usr/src/nuki_hub/icon
|
||||
COPY include /usr/src/nuki_hub/include
|
||||
COPY lib /usr/src/nuki_hub/lib
|
||||
COPY networkDevices /usr/src/nuki_hub/networkDevices
|
||||
COPY CMakeLists.txt /usr/src/nuki_hub
|
||||
COPY index.html /usr/src/nuki_hub
|
||||
COPY *.h /usr/src/nuki_hub
|
||||
COPY *.cpp /usr/src/nuki_hub
|
||||
|
||||
RUN mkdir -p /usr/src/nuki_hub/build
|
||||
|
||||
RUN cd /usr/src/nuki_hub/build && \
|
||||
echo "# Espressif ESP32 Partition Table" > partitions.csv && \
|
||||
echo "# Name, Type, SubType, Offset, Size, Flags" >> partitions.csv && \
|
||||
echo "nvs, data, nvs, 0x9000, 0x5000," >> partitions.csv && \
|
||||
echo "otadata, data, ota, 0xe000, 0x2000," >> partitions.csv && \
|
||||
echo "app0, app, ota_0, 0x10000, 0x1E0000," >> partitions.csv && \
|
||||
echo "app1, app, ota_1, 0x1F0000,0x1E0000," >> partitions.csv && \
|
||||
echo "spiffs, data, spiffs, 0x3D0000,0x30000," >> partitions.csv
|
||||
|
||||
RUN set -ex && \
|
||||
cd /usr/src/nuki_hub/build && \
|
||||
cmake -D CMAKE_TOOLCHAIN_FILE=~/Arduino-CMake-Toolchain/Arduino-toolchain.cmake .. && \
|
||||
make
|
||||
|
||||
FROM builder AS runtime
|
||||
|
||||
COPY --from=builder /usr/src/nuki_hub/build/nuki_hub.bin /usr/src/nuki_hub/build/release/nuki_hub.bin
|
||||
COPY --from=builder /usr/src/nuki_hub/build/nuki_hub.partitions.bin /usr/src/nuki_hub/build/release/nuki_hub.partitions.bin
|
||||
COPY --from=builder /root/.arduino15/packages/esp32/hardware/esp32/2.0.9/tools/partitions/boot_app0.bin /usr/src/nuki_hub/build/release/boot_app0.bin
|
||||
|
||||
CMD ["/bin/bash"]
|
||||
10
Docker/README.md
Normal file
10
Docker/README.md
Normal file
@@ -0,0 +1,10 @@
|
||||
# Build with Docker
|
||||
|
||||
You can build this project using Docker. Just run the following commands in the console:
|
||||
|
||||
```console
|
||||
cd Docker
|
||||
./build_with_docker.sh
|
||||
```
|
||||
|
||||
once the script is complete you will find the nuki_nub binary in the `nuki_hub/build/release` folder.
|
||||
6
Docker/build_with_docker.sh
Executable file
6
Docker/build_with_docker.sh
Executable file
@@ -0,0 +1,6 @@
|
||||
set -ex
|
||||
docker build -f ./Dockerfile -t nuki_hub ..
|
||||
docker create --name nuki_hub nuki_hub
|
||||
rm -rf ../build
|
||||
docker cp nuki_hub:/usr/src/nuki_hub/build/ ../
|
||||
docker rm -f nuki_hub
|
||||
94
Network.cpp
94
Network.cpp
@@ -761,7 +761,7 @@ void Network::publishHASSConfig(char* deviceType, const char* baseTopic, char* n
|
||||
"battery low",
|
||||
name,
|
||||
baseTopic,
|
||||
mqtt_topic_battery_critical,
|
||||
String("~") + mqtt_topic_battery_critical,
|
||||
deviceType,
|
||||
"battery",
|
||||
"",
|
||||
@@ -780,7 +780,7 @@ void Network::publishHASSConfig(char* deviceType, const char* baseTopic, char* n
|
||||
"keypad battery low",
|
||||
name,
|
||||
baseTopic,
|
||||
mqtt_topic_battery_keypad_critical,
|
||||
String("~") + mqtt_topic_battery_keypad_critical,
|
||||
deviceType,
|
||||
"battery",
|
||||
"",
|
||||
@@ -802,7 +802,7 @@ void Network::publishHASSConfig(char* deviceType, const char* baseTopic, char* n
|
||||
"battery voltage",
|
||||
name,
|
||||
baseTopic,
|
||||
mqtt_topic_battery_voltage,
|
||||
String("~") + mqtt_topic_battery_voltage,
|
||||
deviceType,
|
||||
"voltage",
|
||||
"measurement",
|
||||
@@ -818,7 +818,7 @@ void Network::publishHASSConfig(char* deviceType, const char* baseTopic, char* n
|
||||
"trigger",
|
||||
name,
|
||||
baseTopic,
|
||||
mqtt_topic_lock_trigger,
|
||||
String("~") + mqtt_topic_lock_trigger,
|
||||
deviceType,
|
||||
"",
|
||||
"",
|
||||
@@ -834,7 +834,7 @@ void Network::publishHASSConfig(char* deviceType, const char* baseTopic, char* n
|
||||
"MQTT connected",
|
||||
name,
|
||||
baseTopic,
|
||||
mqtt_topic_mqtt_connection_state,
|
||||
_lockPath + mqtt_topic_mqtt_connection_state,
|
||||
deviceType,
|
||||
"",
|
||||
"",
|
||||
@@ -852,12 +852,12 @@ void Network::publishHASSConfig(char* deviceType, const char* baseTopic, char* n
|
||||
"Restart NUKI Hub",
|
||||
name,
|
||||
baseTopic,
|
||||
mqtt_topic_reset,
|
||||
String("~") + mqtt_topic_reset,
|
||||
deviceType,
|
||||
"",
|
||||
"",
|
||||
"diagnostic",
|
||||
mqtt_topic_reset,
|
||||
String("~") + mqtt_topic_reset,
|
||||
{ { "ic", "mdi:restart" },
|
||||
{ "pl_on", "1" },
|
||||
{ "pl_off", "0" },
|
||||
@@ -872,7 +872,7 @@ void Network::publishHASSConfig(char* deviceType, const char* baseTopic, char* n
|
||||
"Firmware version",
|
||||
name,
|
||||
baseTopic,
|
||||
mqtt_topic_info_firmware_version,
|
||||
String("~") + mqtt_topic_info_firmware_version,
|
||||
deviceType,
|
||||
"",
|
||||
"",
|
||||
@@ -889,7 +889,7 @@ void Network::publishHASSConfig(char* deviceType, const char* baseTopic, char* n
|
||||
"Hardware version",
|
||||
name,
|
||||
baseTopic,
|
||||
mqtt_topic_info_hardware_version,
|
||||
String("~") + mqtt_topic_info_hardware_version,
|
||||
deviceType,
|
||||
"",
|
||||
"",
|
||||
@@ -906,7 +906,7 @@ void Network::publishHASSConfig(char* deviceType, const char* baseTopic, char* n
|
||||
"NUKI Hub version",
|
||||
name,
|
||||
baseTopic,
|
||||
mqtt_topic_info_nuki_hub_version,
|
||||
_lockPath + mqtt_topic_info_nuki_hub_version,
|
||||
deviceType,
|
||||
"",
|
||||
"",
|
||||
@@ -923,12 +923,12 @@ void Network::publishHASSConfig(char* deviceType, const char* baseTopic, char* n
|
||||
"LED enabled",
|
||||
name,
|
||||
baseTopic,
|
||||
mqtt_topic_config_led_enabled,
|
||||
String("~") + mqtt_topic_config_led_enabled,
|
||||
deviceType,
|
||||
"",
|
||||
"",
|
||||
"config",
|
||||
mqtt_topic_config_led_enabled,
|
||||
String("~") + mqtt_topic_config_led_enabled,
|
||||
{ { "ic", "mdi:led-variant-on" },
|
||||
{ "pl_on", "1" },
|
||||
{ "pl_off", "0" },
|
||||
@@ -943,12 +943,12 @@ void Network::publishHASSConfig(char* deviceType, const char* baseTopic, char* n
|
||||
"Button enabled",
|
||||
name,
|
||||
baseTopic,
|
||||
mqtt_topic_config_button_enabled,
|
||||
String("~") + mqtt_topic_config_button_enabled,
|
||||
deviceType,
|
||||
"",
|
||||
"",
|
||||
"config",
|
||||
mqtt_topic_config_button_enabled,
|
||||
String("~") + mqtt_topic_config_button_enabled,
|
||||
{ { "ic", "mdi:radiobox-marked" },
|
||||
{ "pl_on", "1" },
|
||||
{ "pl_off", "0" },
|
||||
@@ -963,12 +963,12 @@ void Network::publishHASSConfig(char* deviceType, const char* baseTopic, char* n
|
||||
"Unlatch",
|
||||
name,
|
||||
baseTopic,
|
||||
mqtt_topic_mqtt_connection_state,
|
||||
"",
|
||||
deviceType,
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
mqtt_topic_lock_action,
|
||||
String("~") + mqtt_topic_lock_action,
|
||||
{ { "enabled_by_default", "false" },
|
||||
{ "pl_prs", "unlatch" }});
|
||||
|
||||
@@ -986,12 +986,12 @@ void Network::publishHASSConfigAdditionalButtons(char *deviceType, const char *b
|
||||
"Lock 'n' Go",
|
||||
name,
|
||||
baseTopic,
|
||||
mqtt_topic_mqtt_connection_state,
|
||||
"",
|
||||
deviceType,
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
mqtt_topic_lock_action,
|
||||
String("~") + mqtt_topic_lock_action,
|
||||
{ { "enabled_by_default", "false" },
|
||||
{ "pl_prs", "lockNgo" }});
|
||||
|
||||
@@ -1003,12 +1003,12 @@ void Network::publishHASSConfigAdditionalButtons(char *deviceType, const char *b
|
||||
"Lock 'n' Go with unlatch",
|
||||
name,
|
||||
baseTopic,
|
||||
mqtt_topic_mqtt_connection_state,
|
||||
"",
|
||||
deviceType,
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
mqtt_topic_lock_action,
|
||||
String("~") + mqtt_topic_lock_action,
|
||||
{ { "enabled_by_default", "false" },
|
||||
{ "pl_prs", "lockNgoUnlatch" }});
|
||||
}
|
||||
@@ -1028,7 +1028,7 @@ void Network::publishHASSConfigBatLevel(char *deviceType, const char *baseTopic,
|
||||
"battery level",
|
||||
name,
|
||||
baseTopic,
|
||||
mqtt_topic_battery_level,
|
||||
String("~") + mqtt_topic_battery_level,
|
||||
deviceType,
|
||||
"battery",
|
||||
"measurement",
|
||||
@@ -1053,7 +1053,7 @@ void Network::publishHASSConfigDoorSensor(char *deviceType, const char *baseTopi
|
||||
"door sensor",
|
||||
name,
|
||||
baseTopic,
|
||||
mqtt_topic_lock_door_sensor_state,
|
||||
String("~") + mqtt_topic_lock_door_sensor_state,
|
||||
deviceType,
|
||||
"door",
|
||||
"",
|
||||
@@ -1078,7 +1078,7 @@ void Network::publishHASSConfigRingDetect(char *deviceType, const char *baseTopi
|
||||
"ring detect",
|
||||
name,
|
||||
baseTopic,
|
||||
mqtt_topic_lock_state,
|
||||
String("~") + mqtt_topic_lock_state,
|
||||
deviceType,
|
||||
"sound",
|
||||
"",
|
||||
@@ -1099,12 +1099,12 @@ void Network::publishHASSConfigLedBrightness(char *deviceType, const char *baseT
|
||||
"LED brightness",
|
||||
name,
|
||||
baseTopic,
|
||||
mqtt_topic_config_led_brightness,
|
||||
String("~") + mqtt_topic_config_led_brightness,
|
||||
deviceType,
|
||||
"",
|
||||
"",
|
||||
"config",
|
||||
mqtt_topic_config_led_brightness,
|
||||
String("~") + mqtt_topic_config_led_brightness,
|
||||
{ { "ic", "mdi:brightness-6" },
|
||||
{ "min", "0" },
|
||||
{ "max", "5" }});
|
||||
@@ -1112,22 +1112,24 @@ void Network::publishHASSConfigLedBrightness(char *deviceType, const char *baseT
|
||||
|
||||
void Network::publishHASSConfigSoundLevel(char *deviceType, const char *baseTopic, char *name, char *uidString)
|
||||
{
|
||||
publishHassTopic("sensor",
|
||||
publishHassTopic("number",
|
||||
"sound_level",
|
||||
uidString,
|
||||
"_sound_level",
|
||||
"Sound level",
|
||||
name,
|
||||
baseTopic,
|
||||
mqtt_topic_config_sound_level,
|
||||
String("~") + mqtt_topic_config_sound_level,
|
||||
deviceType,
|
||||
"",
|
||||
"",
|
||||
"diagnostic",
|
||||
mqtt_topic_config_sound_level,
|
||||
"config",
|
||||
String("~") + mqtt_topic_config_sound_level,
|
||||
{ { "ic", "mdi:volume-source" },
|
||||
{ "min", "0" },
|
||||
{ "max", "255" }});
|
||||
{ "max", "255" },
|
||||
{ "mode", "slider" },
|
||||
{ "step", "25.5" }});
|
||||
}
|
||||
|
||||
|
||||
@@ -1140,7 +1142,7 @@ void Network::publishHASSConfigAccessLog(char *deviceType, const char *baseTopic
|
||||
"Last action authorization",
|
||||
name,
|
||||
baseTopic,
|
||||
mqtt_topic_lock_log,
|
||||
String("~") + mqtt_topic_lock_log,
|
||||
deviceType,
|
||||
"",
|
||||
"",
|
||||
@@ -1159,7 +1161,7 @@ void Network::publishHASSConfigKeypadAttemptInfo(char *deviceType, const char *b
|
||||
"Keypad status",
|
||||
name,
|
||||
baseTopic,
|
||||
mqtt_topic_lock_log,
|
||||
String("~") + mqtt_topic_lock_log,
|
||||
deviceType,
|
||||
"",
|
||||
"",
|
||||
@@ -1187,7 +1189,7 @@ void Network::publishHASSWifiRssiConfig(char *deviceType, const char *baseTopic,
|
||||
"wifi signal strength",
|
||||
name,
|
||||
baseTopic,
|
||||
mqtt_topic_wifi_rssi,
|
||||
_lockPath + mqtt_topic_wifi_rssi,
|
||||
deviceType,
|
||||
"signal_strength",
|
||||
"measurement",
|
||||
@@ -1210,7 +1212,7 @@ void Network::publishHASSBleRssiConfig(char *deviceType, const char *baseTopic,
|
||||
"bluetooth signal strength",
|
||||
name,
|
||||
baseTopic,
|
||||
mqtt_topic_lock_rssi,
|
||||
String("~") + mqtt_topic_lock_rssi,
|
||||
deviceType,
|
||||
"signal_strength",
|
||||
"measurement",
|
||||
@@ -1257,8 +1259,12 @@ void Network::publishHassTopic(const String& mqttDeviceType,
|
||||
{
|
||||
json["dev_cla"] = deviceClass;
|
||||
}
|
||||
json["stat_t"] = String("~") + stateTopic;
|
||||
|
||||
|
||||
if(stateTopic != "")
|
||||
{
|
||||
json["stat_t"] = stateTopic;
|
||||
}
|
||||
|
||||
if(stateClass != "")
|
||||
{
|
||||
json["stat_cla"] = stateClass;
|
||||
@@ -1269,8 +1275,10 @@ void Network::publishHassTopic(const String& mqttDeviceType,
|
||||
}
|
||||
if(commandTopic != "")
|
||||
{
|
||||
json["cmd_t"] = String("~") + commandTopic;
|
||||
json["cmd_t"] = commandTopic;
|
||||
}
|
||||
|
||||
json["avty"]["t"] = _lockPath + mqtt_topic_mqtt_connection_state;
|
||||
|
||||
for(const auto& entry : additionalEntries)
|
||||
{
|
||||
@@ -1378,6 +1386,18 @@ void Network::removeHASSConfig(char* uidString)
|
||||
path.concat("/battery_level/config");
|
||||
_device->mqttPublish(path.c_str(), MQTT_QOS_LEVEL, true, "");
|
||||
|
||||
path = discoveryTopic;
|
||||
path.concat("/sensor/");
|
||||
path.concat(uidString);
|
||||
path.concat("/sound_level/config");
|
||||
_device->mqttPublish(path.c_str(), MQTT_QOS_LEVEL, true, "");
|
||||
|
||||
path = discoveryTopic;
|
||||
path.concat("/number/");
|
||||
path.concat(uidString);
|
||||
path.concat("/sound_level/config");
|
||||
_device->mqttPublish(path.c_str(), MQTT_QOS_LEVEL, true, "");
|
||||
|
||||
path = discoveryTopic;
|
||||
path.concat("/binary_sensor/");
|
||||
path.concat(uidString);
|
||||
|
||||
Reference in New Issue
Block a user