Skip to content

Commit

Permalink
HA autodicovery fixes; version bump to 8.27
Browse files Browse the repository at this point in the history
  • Loading branch information
technyon committed Oct 15, 2023
1 parent 6677c09 commit 26aabc1
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Config.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#define NUKI_HUB_VERSION "8.27-pre-1"
#define NUKI_HUB_VERSION "8.27"

#define MQTT_QOS_LEVEL 1
#define MQTT_CLEAN_SESSIONS false
Expand Down
5 changes: 3 additions & 2 deletions Network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ bool Network::publishString(const char* prefix, const char *topic, const char *v
return _device->mqttPublish(path, MQTT_QOS_LEVEL, true, value) > 0;
}

void Network::publishHASSConfig(char* deviceType, const char* baseTopic, char* name, char* uidString, const bool& hasKeypad, char* lockAction, char* unlockAction, char* openAction, char* lockedState, char* unlockedState)
void Network::publishHASSConfig(char* deviceType, const char* baseTopic, char* name, char* uidString, const char* availabilityTopic, const bool& hasKeypad, char* lockAction, char* unlockAction, char* openAction, char* lockedState, char* unlockedState)
{
String discoveryTopic = _preferences->getString(preference_mqtt_hass_discovery);

Expand All @@ -715,6 +715,7 @@ void Network::publishHASSConfig(char* deviceType, const char* baseTopic, char* n
json["name"] = nullptr;
json["unique_id"] = String(uidString) + "_lock";
json["cmd_t"] = String("~") + String(mqtt_topic_lock_action);
json["avty"]["t"] = availabilityTopic;
json["pl_lock"] = lockAction;
json["pl_unlk"] = unlockAction;
json["pl_open"] = openAction;
Expand Down Expand Up @@ -1068,7 +1069,7 @@ void Network::publishHASSConfigAccessLog(char *deviceType, const char *baseTopic
"diagnostic",
"",
{ { "ic", "mdi:format-list-bulleted" },
{ "value_template", "{{ (value_json|selectattr('type', 'eq', 'LockAction')|selectattr('action', 'in', ['Lock', 'Unlock', 'Unlatch'])|first).authorizationName }}" }});
{ "value_template", "{{ (value_json|selectattr('type', 'eq', 'LockAction')|selectattr('action', 'in', ['Lock', 'Unlock', 'Unlatch'])|first|default).authorizationName|default }}" }});
}

void Network::publishHASSConfigKeypadAttemptInfo(char *deviceType, const char *baseTopic, char *name, char *uidString)
Expand Down
2 changes: 1 addition & 1 deletion Network.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class Network
void publishBool(const char* prefix, const char* topic, const bool value);
bool publishString(const char* prefix, const char* topic, const char* value);

void publishHASSConfig(char* deviceType, const char* baseTopic, char* name, char* uidString, const bool& hasKeypad, char* lockAction, char* unlockAction, char* openAction, char* lockedState, char* unlockedState);
void publishHASSConfig(char* deviceType, const char* baseTopic, char* name, char* uidString, const char* availabilityTopic, const bool& hasKeypad, char* lockAction, char* unlockAction, char* openAction, char* lockedState, char* unlockedState);
void publishHASSConfigBatLevel(char* deviceType, const char* baseTopic, char* name, char* uidString);
void publishHASSConfigDoorSensor(char* deviceType, const char* baseTopic, char* name, char* uidString, char* lockAction, char* unlockAction, char* openAction, char* lockedState, char* unlockedState);
void publishHASSConfigRingDetect(char* deviceType, const char* baseTopic, char* name, char* uidString);
Expand Down
2 changes: 1 addition & 1 deletion NetworkLock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ bool NetworkLock::comparePrefixedPath(const char *fullPath, const char *subPath)
void NetworkLock::publishHASSConfig(char *deviceType, const char *baseTopic, char *name, char *uidString, const bool& hasDoorSensor, const bool& hasKeypad, const bool& publishAuthData, char *lockAction,
char *unlockAction, char *openAction, char *lockedState, char *unlockedState)
{
_network->publishHASSConfig(deviceType, baseTopic, name, uidString, hasKeypad, lockAction, unlockAction, openAction, lockedState, unlockedState);
_network->publishHASSConfig(deviceType, baseTopic, name, uidString, "~/maintenance/mqttConnectionState", hasKeypad, lockAction, unlockAction, openAction, lockedState, unlockedState);
_network->publishHASSConfigBatLevel(deviceType, baseTopic, name, uidString);
_network->publishHASSConfigLedBrightness(deviceType, baseTopic, name, uidString);
if(hasDoorSensor)
Expand Down
5 changes: 4 additions & 1 deletion NetworkOpener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,10 @@ void NetworkOpener::publishBleAddress(const std::string &address)

void NetworkOpener::publishHASSConfig(char* deviceType, const char* baseTopic, char* name, char* uidString, char* lockAction, char* unlockAction, char* openAction, char* lockedState, char* unlockedState)
{
_network->publishHASSConfig(deviceType, baseTopic, name, uidString, false, lockAction, unlockAction, openAction, lockedState, unlockedState);
String availabilityTopic = _preferences->getString("mqttpath");
availabilityTopic.concat("/maintenance/mqttConnectionState");

_network->publishHASSConfig(deviceType, baseTopic, name, uidString, availabilityTopic.c_str(), false, lockAction, unlockAction, openAction, lockedState, unlockedState);
_network->publishHASSConfigRingDetect(deviceType, baseTopic, name, uidString);
_network->publishHASSConfigSoundLevel(deviceType, baseTopic, name, uidString);
_network->publishHASSBleRssiConfig(deviceType, baseTopic, name, uidString);
Expand Down
Binary file modified webflash/nuki_hub.bin
Binary file not shown.

0 comments on commit 26aabc1

Please sign in to comment.