tasmota/decode-config

Error restore script json into rules based config

curzon01 opened this issue · 0 comments

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 #77 (reply in thread)