Is BALENA_DEVICE_NAME_AT_INIT populated for preload devices?

Hello! When is deviceName & BALENA_DEVICE_NAME_AT_INIT set? Does it require a cloud connection? Or is it generated locally?

I’d like to broadcast it for a bluetooth connection, even for the first time boot, but it doesn’t appear to exist when I preload an image.

Could this be created during the preload process?

It looks like this thread fell through the cracks and no one replied to it, yet I came across it today when googling for something similar. I gather that a change made to the balena preload command back in February 2019 intentionally stepped back from setting the deviceName field and the BALENA_DEVICE_NAME_AT_INIT environment variable at preload time:

Before that change, a random name used to be generated locally, but it would mismatch the name set / generated through the balenaCloud API and then, at first boot, the supervisor would overwrite the preloaded name with the API name, and this would generate further confusion and problems (like a device reboot).

Could this be created during the preload process?

I gather that the current plan (not yet implemented) is for users/developers to add the device name to the config.json file at preload time, then for the supervisor to give precedence to that value (on first boot) when setting the BALENA_DEVICE_NAME_AT_INIT variable:

Meanwhile, if it was sufficient to have a permanent unique ID for the device, the suggestion is to use the device’s UUID (or a hash or “substring” of the UUID) instead of its name, perhaps by means of device preregistering.

Hi @pdcastro,

I know this is an old thread so I’m not expecting much of a reply but…What is the latest on this issue?

In production, we are going to be writing the hostname to config.json, and it would be nice if BALENA_DEVICE_NAME_AT_INIT variable matched the hostname.

Is there any way of changing BALENA_DEVICE_NAME_INIT before the device is registered with Balena?

Regards,

Hi,

The code to support this on the device has been approved and is pending testing. Once it merges in then you will need a balenaOS release with this new version or later, and an updated preloader tool to use it. I am going to create an issue to tie all this together and then you can be notified when it’s ready.

Hi,

we would like to inform you that the feature has been merged and will be included in the next BalenaOS release.

Hi @richbayliss, @mtoman,

So we just have to specify initialDeviceName in config.json? That’s awesome!

This is off-topic, but what library are you using to generate the ‘cute’ names like ‘morning-pond’ or ‘winter-night’ ?

I found this one: https://www.npmjs.com/package/moniker but i’m curious if you have any recommendations.

We want to implement a similar naming scheme for our devices.

Hi @chuyzoz – We don’t use an external library for this; the source code for the naming is here, and it’s called at device registration time here.

Hope that helps!

All the best,
Hugh