tasmota / decode-config

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

Error restore script json into rules based config #85

Closed curzon01 closed 7 months ago

curzon01 commented 7 months ago

Thanks for detailed description.

Actually this question was cause by unsuccessful attempts to recover devices. As this issue maybe also caused by additional bug of Tasmota let me just summarize what I've tested with regards to decode-config.

a.dmp file contains "script" b.dmp file contains "rules"

a.json:

{
    "script": ""
}

b.json

{
    "rules": ["", "", ""]
}
decode-config -s a.dmp --backup-file Out.dmp -i a.json
INFO: Load data from file 'a.dmp'
INFO: Backup successful to '.\Out.dmp' (Tasmota format)
INFO: Restore skipped, configuration data unchanged

decode-config -s a.dmp --backup-file Out.dmp -i b.json
INFO: Load data from file 'a.dmp'
INFO: Backup successful to '.\Out.dmp' (Tasmota format)
WARNING 9 (@5480): file '.\r.json' array 'rules' couldn't restore, format has changed! Restore value contains <class 'list'> but an array of size [3] is expected
Premature exit - #9 Restore data error

decode-config -s b.dmp --backup-file Out.dmp -i a.json
INFO: Load data from file 'a.dmp'
INFO: Backup successful to '.\Out.dmp' (Tasmota format)
Traceback (most recent call last):
  File "C:\Python\Python311\Scripts\decode-config.py", line 6865, in <module>
    restore(ARGS.restorefile, ARGS.backupfileformat, CONFIG)
  File "C:\Python\Python311\Scripts\decode-config.py", line 6226, in restore
    new_decode_cfg = mapping2bin(config, jsonconfig, restorefilename)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python\Python311\Scripts\decode-config.py", line 6032, in mapping2bin
    set_field(_buffer, config['info']['hardware'], name, setting_fielddef, data, addroffset=0, filename=filename)
  File "C:\Python\Python311\Scripts\decode-config.py", line 5582, in set_field
    valid = min_ <= len(value) <= max_
                    ^^^^^^^^^^
TypeError: object of type 'bool' has no len()

Originally posted by @Subnum12 in https://github.com/tasmota/decode-config/discussions/77#discussioncomment-8458490