Guys
As we have no GitHub integration yet, I have written some code to read an external JSON file, containing version numbers, and compare it to currently installed version.
This is then used to alert the user via the device page (and in the logs) that a new version is available.
It also gives you the ability to show a little update information as to what the new driver/app has
You can find the code here:
https://github.com/CobraVmax/Hubitat/tree/master/Update%20Code
There are two versions:
- Driver code
- App code
There is also an example JSON file in the same GitHub folder showing how to format the version numbers etc
You can host the JSON file on almost any website (or contact me and I'll host it for you and give you FTP access to it)
Driver Code
To use:
Add the code from GitHub to the bottom of your driver then add the method call: version() to the 'updated' section of your driver.
Four additional attributes also need to be added to your driver code (within the metadata section)
attribute "DriverAuthor", "string"
attribute "DriverVersion", "string"
attribute "DriverStatus", "string"
attribute "DriverUpdate", "string"
There are a couple of things to change in the code to make it work for you:
- The URI of the JSON code
- The 'Internal Name' (A name used in the JSON file to get the version)
- The driver's current version (so the code has something to compare the data from the JSON file with)
- The Cron expression - I use http://cronmaker.com to get those right.
This is what it looks like to the driver user when an update is available:
This is when everything is up to date:
By using 'NLS' (No Longer Supported) for the version number in the JSON file - This is what shows in the driver:
Application
To Use:
Add the code from GitHub to the bottom of your application.
Add the method call: version() to the 'updated' section of your app
Add the method call: display() to 'preferences' section where you want the version information displayed.
Again there are a couple of things to change in the code to make it work for you:
- The URI of the JSON code
- The 'Internal Name' (A name used in the JSON file to get the version)
- The app's current version (so the code has something to compare the data from the JSON file with)
- The Cron expression - I use http://cronmaker.com to get those right.
This is what it can look like when an update is available:
This is what it can look like when everything is up to date:
By using 'NLS' (No Longer Supported) for the version number in the JSON file - This is what shows in the app:
As this has taken me a while to refine, if you use this code in a driver or app I would really appreciate a 'credit' for my code somewhere
Also if you can find a better way to do this then please let me know
Update 10/08/2018 - App code now available
Andy