Device Variable Mass Edit

I have a fleet that makes extensive use of device variables to control how the devices function.

I have a particular function that has historically been ON, from the birth of the device in Balena and can then be toggled off using the device Variable.

I now want to inverse that functionality, and have it OFF when the device is born, but then turned on before shipped out.

This creates a small problem as I have 50-60 devices already deployed, where I want them to remain ON, but they are using the inherited valueof the fleet variable.

If I modify the fleet variable default to be OFF, those will flip off out in the field, when infact I want them ON.

There does not seem to be a method to mass edit device variables for existing devices.

I am left to go through, one by one my existing devices and flip their variable value.

Am I missing an option for mass device variable update, or is there an opportunity for a feature here?

Hi @stokes776,

It doesn’t look like we have a support for this kind of operation in the dashboard at the moment.

You can script it yourself using our Balena Node.js SDK or Balena Python SDK, which should not be that hard to do. If you don’t want to install any SDK you can even use NodeJS SDK functions from your dashboard by opening your browser developer console (ex using Ctrl+Shift+I, it depends on your browser) and access the functions e.g.:
await sdk.models.devices.envVar.set('YOUR_DEVICE_UUID', 'YOUR_VAR', 'VALUE')
for setting a single device variable.

50 to 60 devices seems to be the limit between scripting and manually doing the work (in term of time usage).

Let us know if it helps with your use case.

Alternatively, you can also set environment variables using balena-cli with balena env add VARIABLE VALUE --device your_device_uuid from your command-line, which might be even easier for you to script