@Mips,
Possible que je n’ai pas bien compris comment fonctionnait cette fonction aussi.
J’ai modifié avec ces logs pour analyse :
def add_changes(self,key,value):
logging.info('start add_changes function')
if key.find('::') != -1:
tmp_changes = {}
changes = value
logging.info('changes to add: '+str(changes))
for k in reversed(key.split('::')):
if k not in tmp_changes:
tmp_changes[k] = {}
logging.info('tmp_changes : '+str(tmp_changes[k]))
tmp_changes[k] = changes
changes = tmp_changes
tmp_changes = {}
if self.cycle <= 0:
logging.info('!!! cyle <= 0 : send to jeedom')
self.send_change_immediate(changes)
else:
logging.info('changes when cycle > 0 : '+str(changes))
self.merge_dict(self.changes,changes)
logging.info('merge_dict')
logging.info('end add_changes function')
else:
logging.info('key not found')
if self.cycle <= 0:
self.send_change_immediate({key:value})
else:
self.changes[key] = value
J’appelle comme ça : jeedom_com.add_changes('blitzortung::impacts', data)
71406|[2023-08-19 15:14:43]INFO : start add_changes function
71407|[2023-08-19 15:14:43]INFO : changes to add: {'time': 1692450875758334500, 'lat': 43.39207, 'lon': 19.262862, 'status': 0, 'region': 4, 'delay': 7.3, 'sig_num': 26}
71408|[2023-08-19 15:14:43]INFO : tmp_changes : {}
71409|[2023-08-19 15:14:43]INFO : tmp_changes : {}
71410|[2023-08-19 15:14:43]INFO : changes when cycle > 0 : {'blitzortung': {'impacts': {'time': 1692450875758334500, 'lat': 43.39207, 'lon': 19.262862, 'status': 0, 'region': 4, 'delay': 7.3, 'sig_num': 26}}}
71411|[2023-08-19 15:14:43]INFO : merge_dict
71412|[2023-08-19 15:14:43]INFO : end add_changes function
71413|[2023-08-19 15:14:43]INFO : start add_changes function
71414|[2023-08-19 15:14:43]INFO : changes to add: {'time': 1692450879173591800, 'lat': 42.555941, 'lon': 18.942078, 'status': 1, 'region': 8, 'delay': 4, 'sig_num': 37}
71415|[2023-08-19 15:14:43]INFO : tmp_changes : {}
71416|[2023-08-19 15:14:43]INFO : tmp_changes : {}
71417|[2023-08-19 15:14:43]INFO : changes when cycle > 0 : {'blitzortung': {'impacts': {'time': 1692450879173591800, 'lat': 42.555941, 'lon': 18.942078, 'status': 1, 'region': 8, 'delay': 4, 'sig_num': 37}}}
71418|[2023-08-19 15:14:43]INFO : merge_dict
71419|[2023-08-19 15:14:43]INFO : end add_changes function
71420|[2023-08-19 15:14:43]INFO : start add_changes function
71421|[2023-08-19 15:14:43]INFO : changes to add: {'time': 1692450879173591800, 'lat': 42.555941, 'lon': 18.942078, 'status': 2, 'region': 9, 'delay': 4.1, 'sig_num': 37}
71422|[2023-08-19 15:14:43]INFO : tmp_changes : {}
71423|[2023-08-19 15:14:43]INFO : tmp_changes : {}
71424|[2023-08-19 15:14:43]INFO : changes when cycle > 0 : {'blitzortung': {'impacts': {'time': 1692450879173591800, 'lat': 42.555941, 'lon': 18.942078, 'status': 2, 'region': 9, 'delay': 4.1, 'sig_num': 37}}}
71425|[2023-08-19 15:14:43]INFO : merge_dict
71426|[2023-08-19 15:14:43]INFO : end add_changes function
71427|[2023-08-19 15:14:43]INFO : start add_changes function
71428|[2023-08-19 15:14:43]INFO : changes to add: {'time': 1692450879173602600, 'lat': 42.595529, 'lon': 18.925323, 'status': 1, 'region': 8, 'delay': 4.2, 'sig_num': 24}
71429|[2023-08-19 15:14:43]INFO : tmp_changes : {}
71430|[2023-08-19 15:14:43]INFO : tmp_changes : {}
71431|[2023-08-19 15:14:43]INFO : changes when cycle > 0 : {'blitzortung': {'impacts': {'time': 1692450879173602600, 'lat': 42.595529, 'lon': 18.925323, 'status': 1, 'region': 8, 'delay': 4.2, 'sig_num': 24}}}
71432|[2023-08-19 15:14:43]INFO : merge_dict
71433|[2023-08-19 15:14:43]INFO : end add_changes function
71434|[2023-08-19 15:14:43]INFO : start add_changes function
71435|[2023-08-19 15:14:43]INFO : changes to add: {'time': 1692450879173602600, 'lat': 42.595529, 'lon': 18.925323, 'status': 2, 'region': 9, 'delay': 4.3, 'sig_num': 24}
71436|[2023-08-19 15:14:43]INFO : tmp_changes : {}
71437|[2023-08-19 15:14:43]INFO : tmp_changes : {}
71438|[2023-08-19 15:14:43]INFO : changes when cycle > 0 : {'blitzortung': {'impacts': {'time': 1692450879173602600, 'lat': 42.595529, 'lon': 18.925323, 'status': 2, 'region': 9, 'delay': 4.3, 'sig_num': 24}}}
71439|[2023-08-19 15:14:43]INFO : merge_dict
71440|[2023-08-19 15:14:43]INFO : end add_changes function
71441|[2023-08-19 15:14:43]INFO : Send to jeedom : {'blitzortung': {'impacts': {'time': 1692450879173602600, 'lat': 42.595529, 'lon': 18.925323, 'status': 2, 'region': 9, 'delay': 4.3, 'sig_num': 24}}}
71442|[2023-08-19 15:14:43]INFO : start add_changes function
71443|[2023-08-19 15:14:43]INFO : changes to add: {'time': 1692450879582975500, 'lat': 32.193877, 'lon': -115.399909, 'status': 0, 'region': 3, 'delay': 4, 'sig_num': 27}
71444|[2023-08-19 15:14:43]INFO : tmp_changes : {}
71445|[2023-08-19 15:14:43]INFO : tmp_changes : {}
71446|[2023-08-19 15:14:43]INFO : changes when cycle > 0 : {'blitzortung': {'impacts': {'time': 1692450879582975500, 'lat': 32.193877, 'lon': -115.399909, 'status': 0, 'region': 3, 'delay': 4, 'sig_num': 27}}}
71447|[2023-08-19 15:14:43]INFO : merge_dict
71448|[2023-08-19 15:14:43]INFO : end add_changes function
71449|[2023-08-19 15:14:43]INFO : Send to jeedom : {'blitzortung': {'impacts': {'time': 1692450879582975500, 'lat': 32.193877, 'lon': -115.399909, 'status': 0, 'region': 3, 'delay': 4, 'sig_num': 27}}}
71450|[2023-08-19 15:14:43]INFO : start add_changes function
71451|[2023-08-19 15:14:43]INFO : changes to add: {'time': 1692450879661802000, 'lat': 34.163613, 'lon': -69.400261, 'status': 1, 'region': 0, 'delay': 4, 'sig_num': 40}
71452|[2023-08-19 15:14:43]INFO : tmp_changes : {}
71453|[2023-08-19 15:14:43]INFO : tmp_changes : {}
71454|[2023-08-19 15:14:43]INFO : changes when cycle > 0 : {'blitzortung': {'impacts': {'time': 1692450879661802000, 'lat': 34.163613, 'lon': -69.400261, 'status': 1, 'region': 0, 'delay': 4, 'sig_num': 40}}}
71455|[2023-08-19 15:14:43]INFO : merge_dict
71456|[2023-08-19 15:14:43]INFO : end add_changes function
71457|[2023-08-19 15:14:43]INFO : start add_changes function
71458|[2023-08-19 15:14:43]INFO : changes to add: {'time': 1692450879661798100, 'lat': 34.067375, 'lon': -69.310285, 'status': 1, 'region': 0, 'delay': 4.1, 'sig_num': 40}
71459|[2023-08-19 15:14:43]INFO : tmp_changes : {}
71460|[2023-08-19 15:14:43]INFO : tmp_changes : {}
71461|[2023-08-19 15:14:43]INFO : changes when cycle > 0 : {'blitzortung': {'impacts': {'time': 1692450879661798100, 'lat': 34.067375, 'lon': -69.310285, 'status': 1, 'region': 0, 'delay': 4.1, 'sig_num': 40}}}
71462|[2023-08-19 15:14:43]INFO : merge_dict
71463|[2023-08-19 15:14:43]INFO : end add_changes function
71464|[2023-08-19 15:14:43]INFO : Send to jeedom : {'blitzortung': {'impacts': {'time': 1692450879661798100, 'lat': 34.067375, 'lon': -69.310285, 'status': 1, 'region': 0, 'delay': 4.1, 'sig_num': 40}}}
71465|[2023-08-19 15:14:43]INFO : start add_changes function
71466|[2023-08-19 15:14:43]INFO : changes to add: {'time': 1692450879394134500, 'lat': 41.864613, 'lon': 19.958906, 'status': 1, 'region': 8, 'delay': 4.5, 'sig_num': 40}
71467|[2023-08-19 15:14:43]INFO : tmp_changes : {}
71468|[2023-08-19 15:14:43]INFO : tmp_changes : {}
71469|[2023-08-19 15:14:43]INFO : changes when cycle > 0 : {'blitzortung': {'impacts': {'time': 1692450879394134500, 'lat': 41.864613, 'lon': 19.958906, 'status': 1, 'region': 8, 'delay': 4.5, 'sig_num': 40}}}
71470|[2023-08-19 15:14:43]INFO : merge_dict
71471|[2023-08-19 15:14:43]INFO : end add_changes function
71472|[2023-08-19 15:14:43]INFO : Send to jeedom : {'blitzortung': {'impacts': {'time': 1692450879394134500, 'lat': 41.864613, 'lon': 19.958906, 'status': 1, 'region': 8, 'delay': 4.5, 'sig_num': 40}}}
Donc 4 send to Jeedom dans la même seconde et de ce que je comprends de la fonction elle devrait concaténer les datas afin de les agglomérer non ? Et là, tmp_changes est toujours vide c’est bizarre non ?
Ce que je vois aussi c’est que je n’ai jamais de logs '!!! cyle <= 0 : send to jeedom'
qui indique que le cycle n’est jamais inférieur à 0 alors que ça send quand même.
Bref je suis bien perdu pour le moment, une idée de ce que j’ai mal fait ?