tasmota / decode-config

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

calls using get_grouplist(SETTINGS[0][2]) use latest device version, not configured device version #30

Closed yearski closed 3 years ago

yearski commented 3 years ago

Describe the bug In output_tasmotasubcmnds(): https://github.com/tasmota/decode-config/blob/7584caf4c859ed5ad66653369e11cdcc5d510513/decode-config.py#L4828 creates groups based on the latest device version, which may create invalid commands for a device/file using an earlier version. I believe that the appropriate template has already been determined and is in CONFIG['info']['template'] and should be used instead.

SETTINGS[0][2] is also in the argparser: https://github.com/tasmota/decode-config/blob/fad988d9c5662b103abab495a77e75f07fc5e050/decode-config.py#L5067 but can't be replaced as CONFIG hasn't been defined yet. This could mean that invalid commands are suggested by the argparser help. This seems non-trivial to fix and a minor corner-case. I'd suggest ignoring the issue here (or maybe just including a note such as "some commands may not apply to devices/file with earlier versions of Tasmota")

To Reproduce Using device with version 8.5.1:

% ./decode-config.py -s tasmota-ABC123.dmp --output-format cmnd --group Serial -v
INFO: Load data from file 'tasmota-ABC123.dmp'
INFO: File 'tasmota-ABC123.dmp' is using Tasmota v8.5.1 on ESP82xx
<strindex> out of range [0, 87] in <fielddef> (15, '699s', (23, 87), ([8], None, ('Management', '"SwitchText{} {}".format(#+1,"\\"" if len($) == 0 else $)')))
<strindex> out of range [0, 87] in <fielddef> (15, '699s', (23, 95), (None, None, ('Light', None)))
<strindex> out of range [0, 87] in <fielddef> (2, '699s', (23, 87), ([28], None, ('Management', '"SwitchText{} {}".format(#+1,"\\"" if len($) == 0 else $)')))

# Serial:
  Baudrate 460800
  SBaudrate 38400
  SerialConfig 8N1
  SerialDelimiter 255
  TCPBaudrate 0

Expected behavior replacing line 4828 with: groups = get_grouplist(CONFIG['info']['template']), avoids the <strindex> out of range errors.

Version Information (please complete the following information):

Script: decode-config.py Python: 3.9.2 Platform: Linux-5.10.19-1-lts-x86_64-with-glibc2.33 - x86_64 OS: Linux 5.10.19-1-lts #1 SMP Fri, 26 Feb 2021 11:11:40 +0000 Time: 2021-03-31 12:31:16

- 'system' information of your Tasmota data:  

{"bootcount": 24, "bootcount_reset_time": 1606584925, "cfg_crc": "0xf27f", "cfg_crc32": "0xbf6044e6", "cfg_holder": 4617, "cfg_size": 4096, "cfg_timestamp": 1609683854, "header": {"data": {"crc": "0xed7", "crc32": "0xbf6044e6", "platform": "ESP82xx", "size": 4096, "template": {"crc": "0xf27f", "crc32": "0xbf6044e6", "size": 4096, "version": "0x8050100"}, "version": "0x8050100"}, "env": {"platform": "Linux-5.10.19-1-lts-x86_64-with-glibc2.33", "python": "3.9.2", "script": "decode-config.py v9.3.1.2 [6081560]", "system": "Linux x86_64 5.10.19-1-lts #1 SMP Fri, 26 Feb 2021 11:11:40 +0000"}, "timestamp": "2021-01-03 14:24:14"}, "version": "0x8050100"}



**Additional context**
In my specific case, the templates in SETTINGS that caused issue came from:
https://github.com/tasmota/decode-config/blob/fad988d9c5662b103abab495a77e75f07fc5e050/decode-config.py#L1922-L1926
https://github.com/tasmota/decode-config/blob/fad988d9c5662b103abab495a77e75f07fc5e050/decode-config.py#L1988-L1990
curzon01 commented 3 years ago

thx for details

help group based on latest settings is no real issue: