add release v6.3.0 config changes

add release v6.3.0 config changes
This commit is contained in:
Theo Arends 2018-10-31 11:10:44 +01:00
parent 6d58580446
commit c25d1be5d4
1 changed files with 59 additions and 28 deletions

View File

@ -1,6 +1,6 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
VER = '2.0.0000' VER = '2.0.0002'
""" """
decode-config.py - Backup/Restore Sonoff-Tasmota configuration data decode-config.py - Backup/Restore Sonoff-Tasmota configuration data
@ -201,7 +201,7 @@ DEFAULTS = {
'jsonsort': True, 'jsonsort': True,
'jsonrawvalues':False, 'jsonrawvalues':False,
'jsonrawkeys': False, 'jsonrawkeys': False,
'jsonhidepw': True, 'jsonhidepw': False,
}, },
} }
args = {} args = {}
@ -250,21 +250,27 @@ Settings dictionary describes the config file fields definition:
negative <s> shift the result <s> left bits negative <s> shift the result <s> left bits
datadef datadef
Define the field interpretation different from simple Data definition, is either a array definition or a
standard types (like char, byte, int) e. g. lists or bit fields tuple containing an array definition and min/max values
Can be None, a single integer, a list or a dictionary Format: arraydef|(arraydef, min, max)
arraydef:
None: None:
None must be given if the field contains a simple value None must be given if the field contains a
desrcibed by the <format> prefix simple value desrcibed by the <format> prefix
n: n:
Same as [n] below
[n]: [n]:
Defines a one-dimensional array of size <n> Defines a one-dimensional array of size <n>
[n, n <,n...>] [n, m <,o...>]
Defines a multi-dimensional array Defines a multi-dimensional array
min:
defines a minimum valid value or None if all values
for this format is allowed.
max:
defines a maximum valid value or None if all values
for this format is allowed.
converter (optional) converter (optional)
Conversion methode(s): ()|'xxx'|func Conversion methode(s): 'xxx'|func or ('xxx'|func, 'xxx'|func)
Read conversion is used if args.jsonrawvalues is False Read conversion is used if args.jsonrawvalues is False
Write conversion is used if jsonrawvalues from restore json Write conversion is used if jsonrawvalues from restore json
file is False or args.jsonrawvalues is False. file is False or args.jsonrawvalues is False.
@ -845,7 +851,25 @@ Setting_6_2_1_19.update({
'weight_max': ('<L', 0x7B8, None, ('float($) / 10', 'int($ * 10)')), 'weight_max': ('<L', 0x7B8, None, ('float($) / 10', 'int($ * 10)')),
}) })
Setting_6_2_1_20 = Setting_6_2_1_19
Setting_6_2_1_20.update({
'flag3': ({
'raw': ('<L', 0x3A0, None, ('"0x{:08x}".format($)', None)),
'timers_enable': ('<L', (0x3A0, 1, 0), None),
'user_esp8285_enable': ('<L', (0x3A0, 1, 1), None),
'time_append_timezone':('<L', (0x3A0, 1, 2), None),
'gui_hostname_ip': ('<L', (0x3A0, 1, 3), None),
}, 0x3A0, None),
})
Setting_6_3_0 = Setting_6_2_1_20
Setting_6_3_0.update({
'energy_kWhtotal_time': ('<L', 0x7B4, None),
})
Settings = [ Settings = [
(0x6030000, 0xe00, Setting_6_3_0),
(0x6020114, 0xe00, Setting_6_2_1_20),
(0x6020113, 0xe00, Setting_6_2_1_19), (0x6020113, 0xe00, Setting_6_2_1_19),
(0x602010E, 0xe00, Setting_6_2_1_14), (0x602010E, 0xe00, Setting_6_2_1_14),
(0x602010A, 0xe00, Setting_6_2_1_10), (0x602010A, 0xe00, Setting_6_2_1_10),
@ -892,11 +916,10 @@ def GetTemplateSetting(decode_cfg):
@return: @return:
version, template, size, settings to use; None if version is invalid version, template, size, settings to use; None if version is invalid
""" """
version = 0x0
template = size = setting = None
try: try:
version = GetField(decode_cfg, 'version', Setting_6_2_1['version'], raw=True) version = GetField(decode_cfg, 'version', Setting_6_2_1['version'], raw=True)
except:
return None,None,None,None
# search setting definition # search setting definition
template = None template = None
setting = None setting = None
@ -907,6 +930,8 @@ def GetTemplateSetting(decode_cfg):
size = template[1] size = template[1]
setting = template[2] setting = template[2]
break break
except:
pass
return version, template, size, setting return version, template, size, setting
@ -1652,6 +1677,9 @@ def GetField(dobj, fieldname, fielddef, raw=False, addroffset=0):
result = None result = None
if fieldname == 'raw' and not args.jsonrawkeys:
return result
# get field definition # get field definition
_format, baseaddr, bits, bitshift, datadef, convert = GetFieldDef(fielddef) _format, baseaddr, bits, bitshift, datadef, convert = GetFieldDef(fielddef)
@ -1662,7 +1690,7 @@ def GetField(dobj, fieldname, fielddef, raw=False, addroffset=0):
for i in range(0, datadef[0]): for i in range(0, datadef[0]):
subfielddef = GetSubfieldDef(fielddef) subfielddef = GetSubfieldDef(fielddef)
length = GetFieldLength(subfielddef) length = GetFieldLength(subfielddef)
if length != 0 and (fieldname != 'raw' or args.jsonrawkeys): if length != 0:
result.append(GetField(dobj, fieldname, subfielddef, raw=raw, addroffset=addroffset+offset)) result.append(GetField(dobj, fieldname, subfielddef, raw=raw, addroffset=addroffset+offset))
offset += length offset += length
@ -1722,6 +1750,9 @@ def SetField(dobj, fieldname, fielddef, restore, raw=False, addroffset=0, filena
_format, baseaddr, bits, bitshift, datadef, convert = GetFieldDef(fielddef) _format, baseaddr, bits, bitshift, datadef, convert = GetFieldDef(fielddef)
fieldname = str(fieldname) fieldname = str(fieldname)
if fieldname == 'raw' and not args.jsonrawkeys:
return dobj
# do not write readonly values # do not write readonly values
if isinstance(convert, (list,tuple)) and len(convert)>1 and convert[1]==None: if isinstance(convert, (list,tuple)) and len(convert)>1 and convert[1]==None:
if args.debug: if args.debug: