Skip to content

Commit

Permalink
Merge pull request #64 from shbatm/patch-3
Browse files Browse the repository at this point in the history
Add Connections to discovery payload v2
  • Loading branch information
PaulWieland authored Jun 17, 2023
2 parents ddf5940 + 00419eb commit f0d0981
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/home_assistant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand All @@ -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);
}
}

0 comments on commit f0d0981

Please sign in to comment.