From 00419eb71653874e20fc182c6158d9b101d24e24 Mon Sep 17 00:00:00 2001 From: shbatm Date: Sat, 17 Jun 2023 12:32:03 -0500 Subject: [PATCH] Update Home Assistant Discovery to include MAC Connection --- src/home_assistant.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/home_assistant.cpp b/src/home_assistant.cpp index 3e06008..9c97294 100644 --- a/src/home_assistant.cpp +++ b/src/home_assistant.cpp @@ -33,6 +33,12 @@ void ha_autodiscovery_door(BootstrapManager *bootstrapManager){ device["model"] = "ratgdo"; device["sw_version"] = VERSION; device["configuration_url"] = "http://"+microcontrollerIP+"/"; + + // Add MAC as connection ("connections": [["mac", "02:5b:26:a8:dc:12"]]) + JsonArray connections = device.createNestedArray("connections"); + JsonArray nested = connections.createNestedArray(); + nested.add("mac"); + nested.add(WiFi.macAddress()); bootstrapManager->publish(topic.c_str(), payload, true); } @@ -57,6 +63,12 @@ void ha_autodiscovery_light(BootstrapManager *bootstrapManager){ device["model"] = "ratgdo"; device["sw_version"] = VERSION; device["configuration_url"] = "http://"+microcontrollerIP+"/"; + + // Add MAC as connection ("connections": [["mac", "02:5b:26:a8:dc:12"]]) + JsonArray connections = device.createNestedArray("connections"); + JsonArray nested = connections.createNestedArray(); + nested.add("mac"); + nested.add(WiFi.macAddress()); bootstrapManager->publish(topic.c_str(), payload, true); } @@ -81,6 +93,12 @@ void ha_autodiscovery_obs(BootstrapManager *bootstrapManager){ device["model"] = "ratgdo"; device["sw_version"] = VERSION; device["configuration_url"] = "http://"+microcontrollerIP+"/"; + + // Add MAC as connection ("connections": [["mac", "02:5b:26:a8:dc:12"]]) + JsonArray connections = device.createNestedArray("connections"); + JsonArray nested = connections.createNestedArray(); + nested.add("mac"); + nested.add(WiFi.macAddress()); bootstrapManager->publish(topic.c_str(), payload, true); -} \ No newline at end of file +}