Skip to content

Commit

Permalink
add HA auto discovery for keypad battery critical sensor
Browse files Browse the repository at this point in the history
  • Loading branch information
technyon committed Dec 18, 2022
1 parent 0e32116 commit 593e12a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
30 changes: 25 additions & 5 deletions Network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -404,9 +404,6 @@ void Network::publishHASSConfig(char* deviceType, const char* baseTopic, char* n
path.concat(uidString);
path.concat("/smartlock/config");

Serial.println("HASS Config:");
Serial.println(configJSON);

_device->mqttClient()->publish(path.c_str(), configJSON.c_str(), true);

// Battery critical
Expand All @@ -422,8 +419,7 @@ void Network::publishHASSConfig(char* deviceType, const char* baseTopic, char* n
configJSON.concat(name);
configJSON.concat(" battery low\",\"unique_id\":\"");
configJSON.concat(uidString);
configJSON.concat(
"_battery_low\",\"dev_cla\":\"battery\",\"ent_cat\":\"diagnostic\",\"pl_off\":\"0\",\"pl_on\":\"1\",\"stat_t\":\"~");
configJSON.concat("_battery_low\",\"dev_cla\":\"battery\",\"ent_cat\":\"diagnostic\",\"pl_off\":\"0\",\"pl_on\":\"1\",\"stat_t\":\"~");
configJSON.concat(mqtt_topic_battery_critical);
configJSON.concat("\"}");

Expand All @@ -434,6 +430,30 @@ void Network::publishHASSConfig(char* deviceType, const char* baseTopic, char* n

_device->mqttClient()->publish(path.c_str(), configJSON.c_str(), true);

// Keypad battery critical
configJSON = "{\"dev\":{\"ids\":[\"nuki_";
configJSON.concat(uidString);
configJSON.concat("\"],\"mf\":\"Nuki\",\"mdl\":\"");
configJSON.concat(deviceType);
configJSON.concat("\",\"name\":\"");
configJSON.concat(name);
configJSON.concat("\"},\"~\":\"");
configJSON.concat(baseTopic);
configJSON.concat("\",\"name\":\"");
configJSON.concat(name);
configJSON.concat(" keypad battery low\",\"unique_id\":\"");
configJSON.concat(uidString);
configJSON.concat("_keypad_battery_low\",\"dev_cla\":\"battery\",\"ent_cat\":\"diagnostic\",\"pl_off\":\"0\",\"pl_on\":\"1\",\"stat_t\":\"~");
configJSON.concat(mqtt_topic_battery_keypad_critical);
configJSON.concat("\"}");

path = discoveryTopic;
path.concat("/binary_sensor/");
path.concat(uidString);
path.concat("/keypad_battery_low/config");

_device->mqttClient()->publish(path.c_str(), configJSON.c_str(), true);

// Battery voltage
configJSON = "{\"dev\":{\"ids\":[\"nuki_";
configJSON.concat(uidString);
Expand Down
2 changes: 1 addition & 1 deletion Version.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#pragma once

#define nuki_hub_version "6.5"
#define nuki_hub_version "6.6"
Binary file modified webflash/nuki_hub.bin
Binary file not shown.

0 comments on commit 593e12a

Please sign in to comment.