# Detecting new balena device in the same network

**URL:** <https://forums.balena.io/t/detecting-new-balena-device-in-the-same-network/144808>\
**Category:** Product support\
**Created:** [June 28, 2020, 11:15am UTC](https://forums.balena.io/t/detecting-new-balena-device-in-the-same-network/144808 "2020-06-28T11:15:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vitaliy](https://avatars.discourse-cdn.com/v4/letter/v/4bbf92/32.png) [@Vitaliy](https://forums.balena.io/u/Vitaliy)\
**Post date:** [June 28, 2020, 11:15am UTC](https://forums.balena.io/t/detecting-new-balena-device-in-the-same-network/144808/1 "2020-06-28T11:15:04Z")

</div>

Hi!

We would like to run an automation installation script for adding a new device.  
Our **manual steps** so far are like this:

1. Add a new device in the balena cloud
2. Download & flush the image with balenaEtcher to the SD of the device
3. Start the device & wait for it to boot
4. Run script from another PC in the same subnet to generate a certificate for it, and pass it into the container by adding new environment variable.

We would like to **automate** this process as much as possible.

1. Is there a way to perform automatically steps (1)-(3) without having to remove the SD from the device? That is we would like it to somehow pull the complete image from cloud & burn it on the device directly, a single script to do it all without manual intervention.

2. For step (4) we need the UUID of the device for balena CLI. I understand we can see it in the cloud, I’m wondering if there is a way to identify a device automatically, like a device which is connected to the same subnet network as the PC from which the installation script is executed?  
**balena scan** shows only devices in development mode, not in production mode.

Many Thanks!  
Vitaliy

---

<div class="post-metadata">

**Author:** ![ntzovanis](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/ntzovanis/32/1150_2.png) [@ntzovanis](https://forums.balena.io/u/ntzovanis)\
**Post date:** [June 29, 2020, 9:10pm UTC](https://forums.balena.io/t/detecting-new-balena-device-in-the-same-network/144808/3 "2020-06-29T21:10:36Z")

</div>

Hey @Vitaliy

Most of the steps you mention can be automated with the CLI, there’s detailed information [here](https://www.balena.io/blog/advanced-device-provisioning-workflow-for-large-fleets-preloading-and-pre-provisioning/) on how to achieve that (specially the UUID part).

The mounting/unmounting the SD card would be tricky. You’ll probably need some custom hardware that would allow you to switch the SD card from being mounted to the SD slot on your device and your laptop (or whatever HW you use for flashing).

So to summarize, you can automate the pre-registration of your device, configuring the image and flashing it. Then you’ll have to either remove the SD from the flashing HW and mount it on the device or create some sort of SD switching HW that allows you to do that.

Cheers,  
Nico

---

<div class="post-metadata">

**Author:** ![Vitaliy](https://avatars.discourse-cdn.com/v4/letter/v/4bbf92/32.png) [@Vitaliy](https://forums.balena.io/u/Vitaliy)\
**Post date:** [June 30, 2020, 8:42am UTC](https://forums.balena.io/t/detecting-new-balena-device-in-the-same-network/144808/5 "2020-06-30T08:42:30Z")

</div>

Thanks a lot Niko!

Exactly what I was looking for!  
Just to add for future readers -

- all references to rasin in the doc should be replaced with balena
- etcher can be replaced with balena local flash command for automation.

Thanks again!  
Vitaliy
