For those whom might get to that issue ( having a dict with None value ), I have made a workaround by converting the None to Null when saving and from Null to None when retrieving.
I think the best would be to have Domoticz.Configuration() capable to store JSON datatype instead of dict, this will make the code in Domoticz simpler and rely on JSON Encoder/decoder
Code: Select all
def prepare_dict_for_storage( dict_items):
Domoticz.Log("prepare_dict_for_storage")
dict_str = json.dumps( dict_items )
return json.loads( dict_str, object_pairs_hook=dict_None_to_Null )
def repair_dict_after_load( dict_items):
dict_str = json.dumps( dict_items )
return json.loads( dict_str, object_pairs_hook=dict_Null_to_None)
def dict_None_to_Null( items ):
result = {}
for key, value in items:
if value is None:
Domoticz.Log("Updating %s: %s to %s:'Null'" %(key,value, key))
value = "Null"
result[key] = value
return result
def dict_Null_to_None( items ):
result = {}
for key, value in items:
if value == "Null":
value = None
result[key] = value
return result