Skip to content

Commit

Permalink
write to config only on changes, not on startup
Browse files Browse the repository at this point in the history
  • Loading branch information
ndrsnhs committed Nov 28, 2024
1 parent 4e0ad15 commit 9992ce9
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions packages/helpermodules/subdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -683,11 +683,15 @@ def process_optional_topic(self, var: optional.Optional, msg: mqtt.MQTTMessage):
config_dict = decode_payload(msg.payload)
var.data.ocpp = dataclass_from_dict(Ocpp, config_dict)
elif re.search("/optional/zabbix/", msg.topic) is not None:
config = decode_payload(msg.payload)
mod = importlib.import_module(".zabbix.zabbix", "modules")
config = dataclass_from_dict(mod.device_descriptor.configuration_factory, config)
# var.zabbix_module = mod.create_config_files(config)
mod.create_config(config)
# do not reconfigure zabbix if topic is received on startup
if self.event_subdata_initialized.is_set():
config = decode_payload(msg.payload)
mod = importlib.import_module(".zabbix.zabbix", "modules")
config = dataclass_from_dict(mod.device_descriptor.configuration_factory, config)
# var.zabbix_module = mod.create_config_files(config)
mod.create_config(config)
else:
log.debug("skipping zabbix message on startup")
else:
self.set_json_payload_class(var.data, msg)
except Exception:
Expand Down

0 comments on commit 9992ce9

Please sign in to comment.