decode-config documentation improved

This commit is contained in:
blakadder 2019-11-09 17:08:27 +01:00
parent 8f64d13074
commit 5115d6c054
2 changed files with 32 additions and 22 deletions

View File

@ -13,10 +13,10 @@ Use instead of the container `mytasmota:latest` the published container `eddyhub
## Build a specific binary with custom options
Checkout Tasmota: `git clone https://github.com/arendst/Tasmota.git`
Mount the source as volume in `/tasmota`. **Prefix** any parameter available in `Tasmota/sonoff/my_user_config.h` with `TASMOTA_` as a environment variable for the container. **Also don't forget to escape what needs to be escaped in your shell.** **Strings** should be in **double quotes**. My config example:
`docker run -ti --rm -v $(pwd)/Tasmota:/tasmota -e TASMOTA_STA_SSID1='"my-wifi"' -e TASMOTA_STA_PASS1='"my-wifi-password"' -e TASMOTA_MQTT_HOST='my-mqtt-host' -e TASMOTA_MQTT_USER='"my-mqtt-user"' -e TASMOTA_MQTT_PASS='"my-mqtt-password"' -e TASMOTA_WEB_PASSWORD='"my-web-password"' -u $UID:$GID mytasmota:latest --environment sonoff-DE`
Mount the source as volume in `/tasmota`. **Prefix** any parameter available in `Tasmota/tasmota/my_user_config.h` with `TASMOTA_` as a environment variable for the container. **Also don't forget to escape what needs to be escaped in your shell.** **Strings** should be in **double quotes**. My config example:
`docker run -ti --rm -v $(pwd)/Tasmota:/tasmota -e TASMOTA_STA_SSID1='"my-wifi"' -e TASMOTA_STA_PASS1='"my-wifi-password"' -e TASMOTA_MQTT_HOST='my-mqtt-host' -e TASMOTA_MQTT_USER='"my-mqtt-user"' -e TASMOTA_MQTT_PASS='"my-mqtt-password"' -e TASMOTA_WEB_PASSWORD='"my-web-password"' -u $UID:$GID mytasmota:latest --environment tasmota-DE`
Now you should have the file Tasmota/.pioenvs/sonoff-DE/firmware.bin which can be flashed on your device.
Now you should have the file Tasmota/.pioenvs/tasmota-DE/firmware.bin which can be flashed on your device.
## Build a specific version of tasmota
Checkout out the needed version before using the build instructions above:

View File

@ -41,9 +41,19 @@ _decode-config.py_ is compatible with Tasmota version from v5.10.0 up to now.
* [Notes](decode-config.md#notes)
## Prerequisite
* [Python](https://en.wikipedia.org/wiki/Python_(programming_language))
* [Python 2.7](https://en.wikipedia.org/wiki/Python_(programming_language))
This program is written in [Python](https://en.wikipedia.org/wiki/Python_(programming_language)) so you need to install a working python environment (for details see [Python Setup and Usage](https://docs.python.org/2.7/using/index.html))
Dependencies:
```
sudo apt-get install python python-pip libcurl4-openssl-dev libssl-dev
```
```
pip install pycurl configargparse
```
This tool cannot be installed in Windows 10 due to libcurl dependencies. You can use [WSL](https://docs.microsoft.com/en-us/windows/wsl/install-win10), install a linux distribution and install there.
* [Tasmota](https://github.com/arendst/Tasmota) [Firmware](https://github.com/arendst/Tasmota/releases) with Web-Server enabled:
* To backup or restore configurations from or to a Tasmota device you need a firmare with enabled web-server in admin mode (command [WebServer 2](https://github.com/arendst/Tasmota/wiki/Commands#wifi)). This is the Tasmota default.
* If using your own compiled firmware be aware to enable the web-server (`#define USE_WEBSERVER` and `#define WEB_SERVER 2`).
@ -62,7 +72,7 @@ Configuration data in binary format.
This format is binary decryptet, editable (e.g. using a hex editor) and can also be used for `--restore-file` command.
It will be created by _decode-config.py_ using `--backup-file` with `--backup-type bin`.
Note:
The .bin file contains the same information as the original .dmp file from Tasmota "Backup/Restore Configuration" but it is decrpted and 4 byte longer than an original (it is a prefix header at the beginning). .bin file data starting at address 4 contains the same as the **struct SYSCFG** from Tasmota [settings.h](https://github.com/arendst/Tasmota/blob/master/sonoff/settings.h) in decrypted format.
The .bin file contains the same information as the original .dmp file from Tasmota "Backup/Restore Configuration" but it is decrpted and 4 byte longer than an original (it is a prefix header at the beginning). .bin file data starting at address 4 contains the same as the **struct SYSCFG** from Tasmota [settings.h](https://github.com/arendst/Tasmota/blob/master/tasmota/settings.h) in decrypted format.
#### File extensions
You don't need to append exensions for your file name as _decode-config.py_ uses auto extension as default. The extension will be choose based on file contents and `--backup-type` parameter.
@ -80,7 +90,7 @@ The source can be either
Example:
decode-config.py -d sonoff-4281
decode-config.py -d tasmota-4281
will output a human readable configuration in [JSON](http://www.json.org/)-format:
@ -101,24 +111,24 @@ will output a human readable configuration in [JSON](http://www.json.org/)-forma
### Save backup file
To save the output as backup file use `--backup-file <filename>`, you can use placeholder for Version, Friendlyname and Hostname:
decode-config.py -d sonoff-4281 --backup-file Config_@f_@v
decode-config.py -d tasmota-4281 --backup-file Config_@f_@v
If you have setup a WebPassword within Tasmota, use
decode-config.py -d sonoff-4281 -p <yourpassword> --backup-file Config_@f_@v
decode-config.py -d tasmota-4281 -p <yourpassword> --backup-file Config_@f_@v
will create a file like `Config_Sonoff_6.4.0.json` (the part `Sonoff` and `6.4.0` will choosen related to your device configuration). Because the default backup file format is JSON, you can read and change it with any raw text editor.
will create a file like `Config_Tasmota_6.4.0.json` (the part `Tasmota` and `6.4.0` will choosen related to your device configuration). Because the default backup file format is JSON, you can read and change it with any raw text editor.
### Restore backup file
Reading back a saved (and possible changed) backup file use the `--restore-file <filename>` parameter. This will read the (changed) configuration data from this file and send it back to the source device or filename.
To restore the previously save backup file `Config_Sonoff_6.2.1.json` to device `sonoff-4281` use:
To restore the previously save backup file `Config_Tasmota_6.2.1.json` to device `tasmota-4281` use:
decode-config.py -d sonoff-4281 --restore-file Config_Sonoff_6.2.1.json
decode-config.py -d tasmota-4281 --restore-file Config_Tasmota_6.2.1.json
with password set by WebPassword:
decode-config.py -d sonoff-4281 -p <yourpassword> --restore-file Config_Sonoff_6.2.1.json
decode-config.py -d tasmota-4281 -p <yourpassword> --restore-file Config_Tasmota_6.2.1.json
### Output to screen
To force screen output use the `--output` parameter.
@ -130,7 +140,7 @@ The default output format is [JSON](decode-config.md#-json-format). You can forc
Example:
decode-config.py -d sonoff-4281 -c my.conf -x Wifi --output-format json
decode-config.py -d tasmota-4281 -c my.conf -x Wifi --output-format json
{
...
@ -169,7 +179,7 @@ _decode-config.py_ is able to translate the configuration data to (most all) Tas
Example:
decode-config.py -d sonoff-4281 -c my.conf -g Wifi --output-format cmnd
decode-config.py -d tasmota-4281 -c my.conf -g Wifi --output-format cmnd
# Wifi:
AP 0
@ -200,7 +210,7 @@ These are similary to the categories on [https://github.com/arendst/Tasmota/wiki
To filter outputs to a subset of groups use the `-g` or `--group` arg concatenating the grooup you want, e. g.
decode-config.py -d sonoff-4281 -c my.conf --output-format cmnd --group Main MQTT Management Wifi
decode-config.py -d tasmota-4281 -c my.conf --output-format cmnd --group Main MQTT Management Wifi
### Configuration file
@ -218,7 +228,7 @@ e.g. my.conf:
To make a backup file from example above you can now pass the config file instead using the password on command line:
decode-config.py -d sonoff-4281 -c my.conf --backup-file Config_@f_@v
decode-config.py -d tasmota-4281 -c my.conf --backup-file Config_@f_@v
@ -358,27 +368,27 @@ For further details of config file syntax see [https://pypi.org/project/ConfigAr
1. Restore a Tasmota configuration file
`decode-config.py -c my.conf -d sonoff --restore-file Config_Sonoff_6.2.1.dmp`
`decode-config.py -c my.conf -d tasmota --restore-file Config_Tasmota_6.2.1.dmp`
2. Backup device using Tasmota configuration compatible format
a) use file extension to choice the file format
`decode-config.py -c my.conf -d sonoff --backup-file Config_@f_@v.dmp`
`decode-config.py -c my.conf -d tasmota --backup-file Config_@f_@v.dmp`
b) use args to choice the file format
`decode-config.py -c my.conf -d sonoff --backup-type dmp --backup-file Config_@f_@v`
`decode-config.py -c my.conf -d tasmota --backup-type dmp --backup-file Config_@f_@v`
#### Use batch processing
for device in sonoff1 sonoff2 sonoff3; do ./decode-config.py -c my.conf -d $device -o Config_@f_@v
for device in tasmota1 tasmota2 tasmota3; do ./decode-config.py -c my.conf -d $device -o Config_@f_@v
or under windows
for device in (sonoff1 sonoff2 sonoff3) do python decode-config.py -c my.conf -d %device -o Config_@f_@v
for device in (tasmota1 tasmota2 tasmota3) do python decode-config.py -c my.conf -d %device -o Config_@f_@v
will produce JSON configuration files for host sonoff1, sonoff2 and sonoff3 using friendly name and Tasmota firmware version for backup filenames.
will produce JSON configuration files for host tasmota1, tasmota2 and tasmota3 using friendly name and Tasmota firmware version for backup filenames.
## Notes
Some general notes: