Theres no way to unset a device level environment variable if the fleet level variable is set

The environment variable “REBOOT_DAILY” is set for my entire application. I would like to unset it for a particular device. That is not possible in the dashboard. Please fix that.

Hello there, within the dashboard, when viewing a device then clicking the device variables tab, you can click override to set a different value for that environment variable for that individual device.

You can override the current value, but you cannot delete the variable

E.g. if I have a script that goes:

if [ -z "$REBOOT_DAILY" ]
then
  rebootDaemon.sh
fi

If I set the REBOOT_DAILY environment variable for the entire fleet, I can’t unset it for a particular device.

I have run into this myself. While one can override the value of a variable, one cannot UNSET the variable by way of an override.

1 Like

I forgot to mention this in my prior post. The best way around the issue is to not rely on the existence of a variable, but rather its value. So for your case, rather than doing this:

if [[ -z $REBOOT_DAILY ]]

Do this:

if [[ "$REBOOT_DAILY" == "true" ]]

Then in your fleet config, set the variable equal to “true”, and over ride it per device with “false”.

Cheers!
Mark-

1 Like

Right, but then I need to change my code. I would prefer not to do that. This is a feature the dashboard should have

Hello, the suggestion above from Mark is the best way to approach this. There are no plans to modify the env var scheme to support unsets of app vars at the individual device level currently. Regards

It’s an incredibly common practice to check if a variable is set or not (treat a variable as a flag) rather than checking the specific value.

That’s entirely what test -z is for. Plus it allows multiple uses for the variable. E.g. if WIFI is set then go to wifi mode, but if it has parameters like '{"publicwifi": "secretpassword"}' then go to wifi mode and override the wifi settings.

Config simplicity matters substantially.

Thanks for the feedback Connor, I’ve passed it along to our team. And thanks Mark as well, nice workaround for sure (fully understanding it doesn’t meet Connor’s needs, but, it’s a great tip for other folks that could make use of it)!

1 Like