tasmota / decode-config

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

convert json to dmp doesn't find json file #69

Closed mapausch closed 1 year ago

mapausch commented 1 year ago

Describe the bug

Trying to convert a json file to dmp file does not work.

Having this files/directories:

[myuser@myhost tasmota]$ pwd
/home/myuser/tasmota

[myuser@myhost tasmota]$ ls -la
insgesamt 308
drwxr-xr-x   3 myuser myuser   4096 19. Jun 22:26 .
drwx------ 155 myuser myuser  12288 19. Jun 21:33 ..
-rw-r--r--   1 myuser myuser   4096 19. Jun 21:34 Config_kaffee_12.5.0.dmp
-rw-r--r--   1 myuser myuser  31379 19. Jun 22:11 Config_kaffee_12.5.0.json
-rw-r--r--   1 myuser myuser  31381 19. Jun 22:11 Config_newdev_12.5.0.json
drwxr-xr-x   5 myuser myuser   4096 18. Apr 09:07 decode-config-12.5.0
-rw-r--r--   1 myuser myuser 223607 19. Jun 21:33 decode-config_v12.5.0.tar.gz

Config_kaffee_12.5.0.dmp is a configuration backup made via Tasmota WebUI. Config_kaffee_12.5.0.json is the converted/decoded dmp file

Config_newdev_12.5.0.json is a copy of Config_kaffee_12.5.0.json, but with other hostname.

Now I try to convert the Config_newdev_12.5.0.json to a dmp file that I could import/restore to a new Tasmota device. But none of the tested methods works:

[myuser@myhost tasmota]$ decode-config-12.5.0/decode-config.py -s Config_newdev_12.5.0.json -t dmp -o Config_newdev_12.5.0.dmp
Load data by http from device 'Config_newdev_12.5.0.json'
ERROR 22: Failed to establish HTTP connection to 'Config_newdev_12.5.0.json:80'
Premature exit - #22 HTTP connection error

[myuser@myhost tasmota]$ decode-config-12.5.0/decode-config.py -s ./Config_newdev_12.5.0.json -t dmp -o Config_newdev_12.5.0.dmp
Load data by http from device './Config_newdev_12.5.0.json'
ERROR 22: Failed to establish HTTP connection to './Config_newdev_12.5.0.json:80'
Premature exit - #22 HTTP connection error

[myuser@myhost tasmota]$ decode-config-12.5.0/decode-config.py -s file://./Config_newdev_12.5.0.json -t dmp -o Config_newdev_12.5.0.dmp
ERROR 3 (@3881): File 'file://./Config_newdev_12.5.0.json' not found
Premature exit - #3 File not found

[myuser@myhost tasmota]$ decode-config-12.5.0/decode-config.py -s file://Config_newdev_12.5.0.json -t dmp -o Config_newdev_12.5.0.dmp
ERROR 3 (@3881): File 'file://Config_newdev_12.5.0.json' not found
Premature exit - #3 File not found

[myuser@myhost tasmota]$ decode-config-12.5.0/decode-config.py -s file://$(pwd)/Config_newdev_12.5.0.json -t dmp -o Config_newdev_12.5.0.dmp
ERROR 3 (@3881): File 'file:///home/myuser/tasmota/Config_newdev_12.5.0.json' not found
Premature exit - #3 File not found

To Reproduce

  1. download https://github.com/tasmota/decode-config/archive/refs/tags/v12.5.0.tar.gz and extract
  2. create dmp file from Tasmota 12.5.0 WebUI and convert it to json
  3. try to create a dmp file from the json file (examples see above)

Expected behavior

json file should be converted to a dmp file

Version Information

Please complete the following information
use decode-config.py -V to retrieve the info


[myuser@myhost tasmota]$ decode-config-12.5.0/decode-config.py -V
decode-config.py v12.5.0.0 [f670155] by Norbert Richter nr@prsolution.eu

Script:   decode-config.py
Version:  12.5.0.0 [f670155]
Python:   3.11.3
Platform: Linux-6.3.8-arch1-1-x86_64-with-glibc2.37 - x86_64
OS:       Linux 6.3.8-arch1-1 #1 SMP PREEMPT_DYNAMIC Wed, 14 Jun 2023 20:10:31 +0000
Time:     2023-06-19 22:53:45

System' information of your Tasmota data

Append -g System to your decode-config parameter, e. g. decode-config.py -s myconfig.dmp -g System


[myuser@myhost tasmota]$ decode-config-12.5.0/decode-config.py -s Config_kaffee_12.5.0.dmp -g System
{"bootcount": 23, "bootcount_reset_time": 1662488095, "cfg_crc": "0x7c9c", "cfg_crc32": "0x355e8eed", "cfg_holder": 4617, "cfg_size": 4096, "cfg_timestamp": 1687185041, "header": {"data": {"crc": "0xdd0f", "crc32": "0x355e8eed", "hardware": "ESP82", "size": 4096, "version": {"id": "0xc050000", "name": "12.5.0"}}, "env": {"platform": "Linux-6.3.8-arch1-1-x86_64-with-glibc2.37", "python": "3.11.3", "script": "decode-config.py v12.5.0.0 [f670155]", "system": "Linux x86_64 6.3.8-arch1-1 #1 SMP PREEMPT_DYNAMIC Wed, 14 Jun 2023 20:10:31 +0000"}, "template": {"crc": "0x7c9c", "crc32": "0x355e8eed", "size": 4096, "version": {"id": "0xc050000", "name": "12.5.0"}}, "timestamp": "2023-06-19 14:30:41"}, "version": "0xc050000"}

Additional context

N/A

curzon01 commented 1 year ago
-s, --source <filename|host|url>
                        source used for the Tasmota configuration (default: None). Specify source type, path, file, user,
                        password, hostname, port and topic at once as an URL. The URL must be in the form
                        'scheme://[username[:password]@]host[:port][/topic]|pathfile'where scheme is 'file' for a tasmota binary
                        config file, 'http' for a Tasmota HTTP web connection and 'mqtt(s)' for Tasmota MQTT transport ('mqtts'
                        uses a TLS connection to MQTT server)

the point is the sentence part "'file' for a tasmota binary config file", see also left side "Source" in overview diagram on README - you can't use a json as source.

I do not see the benefit converting a json into a dmp.

curzon01 commented 1 year ago

For full explanation:

first is the prefered way

mapausch commented 1 year ago

Thanks a lot for your efforts and clarifications, @curzon01 Somehow I didn't realize, that it's possible to restore the json file straight to the Tasmota device :-/ Works like a charm :-)