Search and add multiple devices by LAN

Hello!

There was a need to create a driver for a hub that works over LAN.
How I imagine the algorithm works:

  • SmartThings finds the hub on the LAN via broadcast requests
  • Based on the information received via HTTP requests, the driver creates a number of devices via
    and after that creates the required number of devices through try_create_device

I took the example of esp8266lightbulb as a basis and achieved a full-fledged work with the device, but I can’t figure out how to add multiple devices.

Does anyone have, by chance, an example or explanation of how to achieve the ability to add multiple devices at once to SmartThings?

Thnx!

It sounds like you have the right idea. What’s stopping you from calling driver:try_create_device multiple times in the discovery callback? I believe the only requirement is that device_network_id must be unique.

Some people have reported problems adding too fast and have had to wait until the lifecycle handlers are called before adding the next device.

2 Likes

Hi!
Thank you, this post was very long time at pending state. )
Now the problem is solved.

You point right thing - i didn’t understand why i can’t add new devices and realised that in some cases device_network_id wasn’t uniq