I've made some updates to the original community firmware update driver written by @bcopeland to fix some bugs and add some functionality.
The bug fixed results in failed updates when firmware size is an exact multiple of 40 bytes, plus one byte. See https://github.com/djdizzyd/hubitat/pull/18 and Unable to update Black Switch firmware using Hubitat - #3 by mbbush - Firmware Discussion - Inovelli Community for more details.
The new functionality is allowing you to save the value of configuration parameters before you start the update, then do the update, then restore them back to their original values. I implemented this because many of my Inovelli LZW31-SN dimmers were setting some of their parameters to weird values when I updated the firmware, which caused unwanted behavior.
Basic instructions for how to use:
- Use the "get parameters" command with the range of config parameters you want to save. For my LZW31-SN I use "1-22,50-52". Setting an interval of around 400-500 ms is a good idea for reliability.
- Wait until you see the stored parameters show up in the "current states" section on the right. This will take several seconds, and will happen once the hub has stopped getting more parameter reports. You can view the logs if you want more detailed progress information. If you don't see all the parameters you requested, then either the device doesn't support them, or your interval was too fast. You can try get parameters again as many times as you want until you see all the values you expect in "current states".
- Update the firmware, just like you did before. You can optionally include an md5 checksum that will be checked against the file before flashing to ensure your download was correct. I haven't tested this yet with very many different firmware types, and it's totally optional.
- Use the "Restore Parameters" command with a range that includes the stored parameters you want to restore. The driver will send a set parameter command for each parameter in the range you specified that was already stored, so it won't unset something that it doesn't already have a value for.
I have not yet implemented code to save and restore the protection state (which disables local/remote control). I think I saw that get changed once by a firmware update, but I'm not sure.
The code still references @bcopeland as the author, uses his original namespace, and the import URL points to his repository. Brian wrote the vast majority of the code, and I don't want to take away from his work, but he also seems to have abandoned it. I'd be happy to move it to my namespace and take care of things like publishing to HPM, having proper versions, and merging fixes from contributers, but I also don't feel the need for any personal recognition for this. I might even unify it with the non-legacy one if I can find the time to wrap my head around this code more.
Brian, do you have a preference?