Add IP to MQTT + HA discovery
This commit is contained in:
@@ -41,6 +41,7 @@
|
|||||||
#define mqtt_topic_info_hardware_version "/info/hardwareVersion"
|
#define mqtt_topic_info_hardware_version "/info/hardwareVersion"
|
||||||
#define mqtt_topic_info_firmware_version "/info/firmwareVersion"
|
#define mqtt_topic_info_firmware_version "/info/firmwareVersion"
|
||||||
#define mqtt_topic_info_nuki_hub_version "/info/nukiHubVersion"
|
#define mqtt_topic_info_nuki_hub_version "/info/nukiHubVersion"
|
||||||
|
#define mqtt_topic_info_nuki_hub_ip "/info/nukiHubIp"
|
||||||
|
|
||||||
#define mqtt_topic_keypad "/keypad"
|
#define mqtt_topic_keypad "/keypad"
|
||||||
#define mqtt_topic_keypad_command_action "/keypad/command/action"
|
#define mqtt_topic_keypad_command_action "/keypad/command/action"
|
||||||
|
|||||||
26
Network.cpp
26
Network.cpp
@@ -491,6 +491,7 @@ bool Network::reconnect()
|
|||||||
}
|
}
|
||||||
|
|
||||||
publishString(_maintenancePathPrefix, mqtt_topic_mqtt_connection_state, "online");
|
publishString(_maintenancePathPrefix, mqtt_topic_mqtt_connection_state, "online");
|
||||||
|
publishString(_maintenancePathPrefix, mqtt_topic_info_nuki_hub_ip, _device->localIP().c_str());
|
||||||
|
|
||||||
_mqttConnectionState = 2;
|
_mqttConnectionState = 2;
|
||||||
for(const auto& callback : _reconnectedCallbacks)
|
for(const auto& callback : _reconnectedCallbacks)
|
||||||
@@ -902,7 +903,7 @@ void Network::publishHASSConfig(char* deviceType, const char* baseTopic, char* n
|
|||||||
publishHassTopic("sensor",
|
publishHassTopic("sensor",
|
||||||
"nuki_hub_version",
|
"nuki_hub_version",
|
||||||
uidString,
|
uidString,
|
||||||
"_nuki_hub__version",
|
"_nuki_hub_version",
|
||||||
"NUKI Hub version",
|
"NUKI Hub version",
|
||||||
name,
|
name,
|
||||||
baseTopic,
|
baseTopic,
|
||||||
@@ -915,6 +916,23 @@ void Network::publishHASSConfig(char* deviceType, const char* baseTopic, char* n
|
|||||||
{ { "enabled_by_default", "true" },
|
{ { "enabled_by_default", "true" },
|
||||||
{"ic", "mdi:counter"}});
|
{"ic", "mdi:counter"}});
|
||||||
|
|
||||||
|
// NUKI Hub IP Address
|
||||||
|
publishHassTopic("sensor",
|
||||||
|
"nuki_hub_ip",
|
||||||
|
uidString,
|
||||||
|
"_nuki_hub_ip",
|
||||||
|
"NUKI Hub IP",
|
||||||
|
name,
|
||||||
|
baseTopic,
|
||||||
|
_lockPath + mqtt_topic_info_nuki_hub_ip,
|
||||||
|
deviceType,
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"diagnostic",
|
||||||
|
"",
|
||||||
|
{ { "enabled_by_default", "true" },
|
||||||
|
{"ic", "mdi:ip"}});
|
||||||
|
|
||||||
// LED enabled
|
// LED enabled
|
||||||
publishHassTopic("switch",
|
publishHassTopic("switch",
|
||||||
"led_enabled",
|
"led_enabled",
|
||||||
@@ -1392,6 +1410,12 @@ void Network::removeHASSConfig(char* uidString)
|
|||||||
path.concat("/sound_level/config");
|
path.concat("/sound_level/config");
|
||||||
_device->mqttPublish(path.c_str(), MQTT_QOS_LEVEL, true, "");
|
_device->mqttPublish(path.c_str(), MQTT_QOS_LEVEL, true, "");
|
||||||
|
|
||||||
|
path = discoveryTopic;
|
||||||
|
path.concat("/sensor/");
|
||||||
|
path.concat(uidString);
|
||||||
|
path.concat("/nuki_hub_ip/config");
|
||||||
|
_device->mqttPublish(path.c_str(), MQTT_QOS_LEVEL, true, "");
|
||||||
|
|
||||||
path = discoveryTopic;
|
path = discoveryTopic;
|
||||||
path.concat("/number/");
|
path.concat("/number/");
|
||||||
path.concat(uidString);
|
path.concat(uidString);
|
||||||
|
|||||||
Reference in New Issue
Block a user