From 365d74cdc58ed39cd8648274dfb440bd33c9edcb Mon Sep 17 00:00:00 2001 From: Philipp Grimm Date: Tue, 24 Sep 2024 15:50:56 +0200 Subject: [PATCH] export checks can be ignore --- changes.md | 1 + eo_man/data/ha_config_generator.py | 8 ++++++-- eo_man/view/menu_presenter.py | 7 ++++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/changes.md b/changes.md index e900f6b..838857a 100644 --- a/changes.md +++ b/changes.md @@ -6,6 +6,7 @@ * Fixed send message for fired gateways * Improved writing sender ids into actuators for EEP F6-02-01/02 * Added List for supported devices. +* Configuration Checks which are made before generating Home Assistant Configuration can be ignored. ## v0.1.33 Added Supported Device View * Improved template selection in Details View. diff --git a/eo_man/data/ha_config_generator.py b/eo_man/data/ha_config_generator.py index e2585a9..1d2d50d 100644 --- a/eo_man/data/ha_config_generator.py +++ b/eo_man/data/ha_config_generator.py @@ -40,10 +40,14 @@ def get_gateway_by(self, gw_d:Device) -> GatewayDeviceType: return t.value return None - def perform_tests(self): + def perform_tests(self) -> str: device_list = [d for d in self.data_manager.devices.values() if not d.is_gateway() and d.use_in_ha] - self.test_unique_sender_ids(device_list) + try: + self.test_unique_sender_ids(device_list) + return None + except Exception as e: + return str(e) def test_unique_sender_ids(self, device_list:list[Device]): sender_ids = {} diff --git a/eo_man/view/menu_presenter.py b/eo_man/view/menu_presenter.py index 174a68f..63b3836 100644 --- a/eo_man/view/menu_presenter.py +++ b/eo_man/view/menu_presenter.py @@ -256,7 +256,12 @@ def export_ha_config(self, save_as:bool=False): self.app_bus.fire_event(AppBusEventType.LOG_MESSAGE, {'msg': msg, 'color': 'red', 'log-level': 'INFO'}) - self.ha_conf_gen.perform_tests() + error = self.ha_conf_gen.perform_tests() + if error is not None: + self.app_bus.fire_event(AppBusEventType.LOG_MESSAGE, {'msg': error, 'log-level': 'ERROR', 'color': 'red'}) + if not messagebox.askyesno(title="Error in Checking Configuration Data!", message=error+"\n\nDo you want to try to continue?"): + self.app_bus.fire_event(AppBusEventType.LOG_MESSAGE, {'msg': 'Exporting HA Configuration cancelled by user.', 'log-level': 'INFO'}) + return self.ha_conf_gen.save_as_yaml_to_file(self.remember_latest_ha_config_filename)