tasmota / decode-config

Backup/restore and decode configuration tool for Tasmota
GNU Lesser General Public License v3.0
215 stars 32 forks source link

Can't re-upload a config just after download #26

Closed barbudor closed 3 years ago

barbudor commented 3 years ago

Describe the bug

Can't re-upload the downloaded config

To Reproduce

Gosund SP111 running Tasmota 9.2.0.2 as cloned from github on 4 jan at ~ 20h CET

Download the conf

$ decode-config.py -c ~/iot-tools/tasmota/conf-backup/my.conf -s 192.168.168.111 -o @h_@v.json
Load data from device '192.168.168.111'
Backup successful to '.\skt_minipc_9.2.0.2.json' (JSON format)

Trying to reupload

$ decode-config.py -c ~/iot-tools/tasmota/conf-backup/my.conf -s 192.168.168.111 -i skt_minipc_9.2.0.2.json
Load data from device '192.168.168.111'
WARNING 9: file '.\skt_minipc_9.2.0.2.json' - {'energy_kWhyesterday': 22222200} (valid range exceeding)
Premature exit - Restore data error #9

Removing the parameter energy_kWhyesterday from the JSON an tying to re-upload again

$ decode-config.py -c ~/iot-tools/tasmota/conf-backup/my.conf -s 192.168.168.111 -i skt_minipc_9.2.0.2.json
Load data from device '192.168.168.111'
WARNING 21 (@3316): index out of range
Premature exit - Internal error #21
WARNING 9 (@3906): file '.\skt_minipc_9.2.0.2.json' array 'rules' couldn't restore, format has changed! Restore value contains <class 'list'> but an array of size [3] is expected
Premature exit - Restore data error #9

Expected behavior

Both cases should have reloaded the configuration correctly. The 2nd case is more problematic

Version Information (please complete the following information):

Script: decode-config.py Python: 3.8.6 Platform: Windows-10-10.0.19041-SP0 - AMD64 OS: Windows 10 10.0.19041 Time: 2021-01-04 21:28:19

- 'system' information of your Tasmota data (append `-g System` to your decode-config parameter, e. g. `decode-config -f myconfig.dmp -g System`):  

{ "bootcount": 53, "bootcount_reset_time": 1584792271, "cfg_crc": "0x5d71", "cfg_crc32": "0x97a0667f", "cfg_holder": 4617, "cfg_size": 4096, "cfg_timestamp": 1609793459, "header": { "data": { "crc": "0x49b6", "crc32": "0x97a0667f", "platform": "ESP82xx", "size": 4096, "template": { "crc": "0x5d71", "crc32": "0x97a0667f", "size": 4096, "version": "0x9020002" }, "version": "0x9020002" }, "env": { "platform": "Windows-10-10.0.19041-SP0", "python": "3.8.6", "script": "decode-config.py v9.2.0.2 [adb6a8a]", "system": "Windows AMD64 10 10.0.19041" }, "timestamp": "2021-01-04 20:50:59" }, "version": "0x9020002" }



**Additional context**
barbudor commented 3 years ago

Adding the full decode config (without passwords nor ssids) skt_minipc_9.2.0.2_nopw.json.txt

curzon01 commented 3 years ago

see two issue here:

the first is not an decode-config issue, it can and should be solved by a) using add. param -w or --ignore-warnings or b) correct the value or remove it from json (as done)

Reason: your device contains wrong data for field energy_kWhyesterday(22222200 is out of range for this field) and you can correct it within your json file or use param -w to write back the wrong value. I don't know where the wrong data are comes from but that's from your device - I observed this often by dev devices where I tried different versions without reset the config

for the second will investigate...

curzon01 commented 3 years ago

give it a try

for garbadge coming from device config area -w helps without the need to edit the json

barbudor commented 3 years ago

Thanks @curzon01 All good The 1st case wasn't a real use case as it was following some test regarding energyreset Many thanks