Okay, so you have a TASMOTA-enabled ESP8266 board in a place which is difficult to access and the latest upgrade doesn’t quite go as planned. The upgrade itself appears to work, but the configuration back-up from the previous revision doesn’t take (your ESP is missing some peripheral devices). Unfortunately, it’s also a custom build, not a shop bought device with a pre-rolled config already in the (vast) array of choices already shipped with TASMOTA. What to do (other than retrieve the device and open it up)? [“Document your projects better, you pillock!”]
Well, as I found out earlier, there is help at hand in the form of the command-line Python program by Norbert Richter:-
The good news is that it does (even more than) what you’d expect and can be used for recovering configs directly from a device, or converting between input and output formats. The bad news is that it isn’t immediately obvious how to use it and it’s also very fussy about what version of Python you have (more especially right now, with the impending doom of v2.7 rushing towards us at the speed of a new year’s party-popper).
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade….
…etc, etc. So, before you do anything else, grab the latest version of decode-config.py from it’s own repository, as that one is already Python3-ified. You’ll probably need to install dependencies, too (check the header comments).
Anyway, here’s a really, really short intro to using decode-config.py to recover data from older config files, so that you can plug that data straight back into your latest release.
Will, as you expect, give a fairly verbose listing of the options.
decode-config.py -f /path/to/saved/configs/Config_Sonoff_6.3.0.dmp
Will give you an extremely verbose (and virtually indecipherable) JSON listing of the whole configuration (better than nothing, but not by much).
decode-config.py --indent-json 4 -f /path/to/saved/configs/Config_Sonoff_6.3.0.dmp
Will give you a reasonably formatted version of that same, JSON output (we’re getting there!).
decode-config.py --indent-json 4 -f /path/to/saved/configs/Config_Sonoff_6.3.0.dmp -g rules
Will give you a much shorter, much more useful, formatted JSON output of your saved rules (assuming you have any) preceded by a bunch of housekeeping information about the decode-config.py program itself and the system you’re running it on.
The sections which you can use with the “-g” flag are listed as:- “Control, Devices, Display, Domoticz, Internal, Knx, Light, Management, Mqtt, Power, Rf, Rules, Sensor, Serial, Setoption, Shutter, System, Timer, Wifi”, most of which are self-explanatory, but not all of which seem to work as you’d expect when trying to recover data from much older revisions of TASMOTA (as an example of this, the GPIO information which I was searching for was tagged onto the end of the “Mqtt” data). So, eventually I happened on this final invocation, which seemed to produce sane (and much more readable) output from the same back-up file.
decode-config.py -T command -f /path/to/saved/configs/Config_Sonoff_6.3.0.dmp
This (the winner!) provides output which you can scroll through directly, or as I did, save to a file for future reference. The data is grouped under the same headings as listed above in plain ASCII text. Everything appears to be grouped together logically (unlike the JSON output) and the only problem I found was an apparent off-by-one error in the numbering of the GPIOs (starting from GPIO1, rather than GPIO0) …which was fixed before I even finished this article (world record support times!).
So, that’s my brief introduction to decode-config.py, a bacon-saver if ever there was one.
Late News — Norbert (the author of decode-config) has just let me know that binary versions of the utility are also available for multiple operating systems, so there’s no longer any need to update Python.