Check if a new version is available

Hi,
i wanted to know the best practice of detecting whether there is a new version available ?
our device is not alwayes connected to the internet, but when it does, we need to present to the user that there is a new version available, and update the containers when he approves.
whats the best way of doing that using balena os?

Daniel

Hello! So you want your users to decide if they want to update. Currently how are you handling the fleet update? Do you have pinned releases for the devices and ask them if they want to update and then manually pin the device to the new release?

currently its being updated to the latest always.
product decided that we should also ask the user if he wants to update.

i was wondering if there is an API to get all the versions available for the app or something like that.

Yes there is. You can get the releases of an app using the balena API, for more info you can check here https://www.balena.io/docs/reference/api/resources/release/ and then in your case if your user decides to update the device you can use https://www.balena.io/docs/reference/api/resources/device/#set-device-to-release to set the device to a release of your choosing.

@mbalamat thanks for the answer.
The best solution for me will be to lock the device, so updates will be downloaded, but will be installed only upon approval from user.
is that something the balena API provides? state of the current version in the device? (i didnt find in the documentation, but i can see in the dashboard that there is a state, so i assume there is such option)
also before i start the update, i want to perform few operations (also close communication so it cant be accessed)

Hi,
unfortunately it is currently not possible to pre-download updates. You can influence the update strategy using the RESIN_SUPERVISOR_UPDATE_STRATEGY environment variable: https://www.balena.io/docs/learn/deploy/release-strategy/update-strategies/ but none of them would let separate the download and the actual update.