diff --git a/changelog.md b/changelog.md index d96b901..420bafe 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,9 @@ +# Version 7.0.0 - dd.mm.2024 + +## Features + +- bumped HABApp to dev + # Version 6.1.0 - 19.08.2024 ## Features diff --git a/habapp_rules/__version__.py b/habapp_rules/__version__.py index 40c4eee..9975971 100644 --- a/habapp_rules/__version__.py +++ b/habapp_rules/__version__.py @@ -1,2 +1,2 @@ """Set version for the package.""" -__version__ = "6.1.0" +__version__ = "7.0.0" diff --git a/habapp_rules/actors/irrigation.py b/habapp_rules/actors/irrigation.py index b5f2219..07571f1 100644 --- a/habapp_rules/actors/irrigation.py +++ b/habapp_rules/actors/irrigation.py @@ -47,7 +47,7 @@ def __init__(self, config: habapp_rules.actors.config.irrigation.IrrigationConfi self._instance_logger = habapp_rules.core.logger.InstanceLogger(LOGGER, self._config.items.valve.name) self.run.soon(self._cb_set_valve_state) - self.run.every_minute(self._cb_set_valve_state) + self.run.at(self.run.trigger.interval(None, 60), self._cb_set_valve_state) self._config.items.active.listen_event(self._cb_set_valve_state, HABApp.openhab.events.ItemStateChangedEventFilter()) self._config.items.minute.listen_event(self._cb_set_valve_state, HABApp.openhab.events.ItemStateChangedEventFilter()) diff --git a/habapp_rules/actors/light.py b/habapp_rules/actors/light.py index 9f7e5ee..03d6e58 100644 --- a/habapp_rules/actors/light.py +++ b/habapp_rules/actors/light.py @@ -190,20 +190,20 @@ def _set_timeouts(self) -> None: """Set timeouts depending on the current day/night/sleep state.""" if self._get_sleeping_activ(): self._timeout_on = self._config.parameter.on.sleeping.timeout - self._timeout_pre_off = getattr(self._config.parameter.pre_off.sleeping if self._config.parameter.pre_off else None, "timeout", None) - self._timeout_leaving = getattr(self._config.parameter.leaving.sleeping if self._config.parameter.leaving else None, "timeout", None) - self._timeout_pre_sleep = None + self._timeout_pre_off = getattr(self._config.parameter.pre_off.sleeping if self._config.parameter.pre_off else 0, "timeout", 0) + self._timeout_leaving = getattr(self._config.parameter.leaving.sleeping if self._config.parameter.leaving else 0, "timeout", 0) + self._timeout_pre_sleep = 0 elif self._config.items.day.is_on(): self._timeout_on = self._config.parameter.on.day.timeout - self._timeout_pre_off = getattr(self._config.parameter.pre_off.day if self._config.parameter.pre_off else None, "timeout", None) - self._timeout_leaving = getattr(self._config.parameter.leaving.day if self._config.parameter.leaving else None, "timeout", None) - self._timeout_pre_sleep = getattr(self._config.parameter.pre_sleep.day if self._config.parameter.pre_sleep else None, "timeout", None) + self._timeout_pre_off = getattr(self._config.parameter.pre_off.day if self._config.parameter.pre_off else 0, "timeout", 0) + self._timeout_leaving = getattr(self._config.parameter.leaving.day if self._config.parameter.leaving else 0, "timeout", 0) + self._timeout_pre_sleep = getattr(self._config.parameter.pre_sleep.day if self._config.parameter.pre_sleep else 0, "timeout", 0) else: self._timeout_on = self._config.parameter.on.night.timeout - self._timeout_pre_off = getattr(self._config.parameter.pre_off.night if self._config.parameter.pre_off else None, "timeout", None) - self._timeout_leaving = getattr(self._config.parameter.leaving.night if self._config.parameter.leaving else None, "timeout", None) - self._timeout_pre_sleep = getattr(self._config.parameter.pre_sleep.night if self._config.parameter.pre_sleep else None, "timeout", None) + self._timeout_pre_off = getattr(self._config.parameter.pre_off.night if self._config.parameter.pre_off else 0, "timeout", 0) + self._timeout_leaving = getattr(self._config.parameter.leaving.night if self._config.parameter.leaving else 0, "timeout", 0) + self._timeout_pre_sleep = getattr(self._config.parameter.pre_sleep.night if self._config.parameter.pre_sleep else 0, "timeout", 0) self.state_machine.states["auto"].states["on"].timeout = self._timeout_on self.state_machine.states["auto"].states["preoff"].timeout = self._timeout_pre_off @@ -612,15 +612,15 @@ def _set_timeouts(self) -> None: # set timeouts of additional states if self._get_sleeping_activ(): - self._timeout_motion = getattr(self._config.parameter.motion.sleeping if self._config.parameter.motion else None, "timeout", None) - self._timeout_door = getattr(self._config.parameter.door.sleeping if self._config.parameter.door else None, "timeout", None) + self._timeout_motion = getattr(self._config.parameter.motion.sleeping if self._config.parameter.motion else 0, "timeout", 0) + self._timeout_door = getattr(self._config.parameter.door.sleeping if self._config.parameter.door else 0, "timeout", 0) elif self._config.items.day.is_on(): - self._timeout_motion = getattr(self._config.parameter.motion.day if self._config.parameter.motion else None, "timeout", None) - self._timeout_door = getattr(self._config.parameter.door.day if self._config.parameter.door else None, "timeout", None) + self._timeout_motion = getattr(self._config.parameter.motion.day if self._config.parameter.motion else 0, "timeout", 0) + self._timeout_door = getattr(self._config.parameter.door.day if self._config.parameter.door else 0, "timeout", 0) else: - self._timeout_motion = getattr(self._config.parameter.motion.night if self._config.parameter.motion else None, "timeout", None) - self._timeout_door = getattr(self._config.parameter.door.night if self._config.parameter.door else None, "timeout", None) + self._timeout_motion = getattr(self._config.parameter.motion.night if self._config.parameter.motion else 0, "timeout", 0) + self._timeout_door = getattr(self._config.parameter.door.night if self._config.parameter.door else 0, "timeout", 0) self.state_machine.states["auto"].states["motion"].timeout = self._timeout_motion self.state_machine.states["auto"].states["door"].timeout = self._timeout_door diff --git a/habapp_rules/actors/light_hcl.py b/habapp_rules/actors/light_hcl.py index e1f1718..b222167 100644 --- a/habapp_rules/actors/light_hcl.py +++ b/habapp_rules/actors/light_hcl.py @@ -296,7 +296,7 @@ def __init__(self, config: habapp_rules.actors.config.light_hcl.HclTimeConfig) - :param config: config for HCL light rule """ _HclBase.__init__(self, config) - self.run.every(None, 300, self._update_color) # every 5 minutes + self.run.at(self.run.trigger.interval(None, 300), self._update_color) # every 5 minutes def _one_hour_later(self, current_time: datetime.datetime) -> bool: """Check if today the color values will be shifted one hour later in the evening diff --git a/habapp_rules/sensors/dwd.py b/habapp_rules/sensors/dwd.py index 496396d..e938fb6 100644 --- a/habapp_rules/sensors/dwd.py +++ b/habapp_rules/sensors/dwd.py @@ -142,7 +142,7 @@ def __init__(self, config: habapp_rules.sensors.config.dwd.WindAlarmConfig) -> N if self._config.items.hand_timeout is not None: self._config.items.hand_timeout.listen_event(self._cb_hand_timeout, HABApp.openhab.events.ItemStateChangedEventFilter()) - self.run.every(None, 300, self._cb_cyclic_check) + self.run.at(self.run.trigger.interval(None, 300), self._cb_cyclic_check) def _get_initial_state(self, default_value: str = "") -> str: """Get initial state of state machine. diff --git a/habapp_rules/system/sleep.py b/habapp_rules/system/sleep.py index 1b8f1e2..9dda31b 100644 --- a/habapp_rules/system/sleep.py +++ b/habapp_rules/system/sleep.py @@ -229,8 +229,8 @@ def __init__(self, config: habapp_rules.system.config.sleep.LinkSleepConfig) -> config.items.sleep_master.listen_event(self._cb_master, HABApp.openhab.events.ItemStateChangedEventFilter()) if config.items.link_active_feedback is not None: - self.run.on_every_day(config.parameter.link_time_start, self._set_link_active_feedback, target_state="ON") - self.run.on_every_day(config.parameter.link_time_end, self._set_link_active_feedback, target_state="OFF") + self.run.at(self.run.trigger.time(config.parameter.link_time_start), self._set_link_active_feedback, target_state="ON") + self.run.at(self.run.trigger.time(config.parameter.link_time_end), self._set_link_active_feedback, target_state="OFF") self.run.soon(self._set_link_active_feedback, target_state=self._check_time_in_window()) def _check_time_in_window(self) -> bool: diff --git a/habapp_rules/system/summer_winter.py b/habapp_rules/system/summer_winter.py index b72bbbe..5796b54 100644 --- a/habapp_rules/system/summer_winter.py +++ b/habapp_rules/system/summer_winter.py @@ -34,7 +34,7 @@ def __init__(self, config: habapp_rules.system.config.summer_winter.SummerWinter # run at init and every day at 23:00 self.run.soon(self._cb_update_summer) - self.run.on_every_day(datetime.time(23), self._cb_update_summer) + self.run.at(self.run.trigger.time("23:00:00"), self._cb_update_summer) LOGGER.debug("Init of Summer / Winter successful") diff --git a/requirements_dev.txt b/requirements_dev.txt index 65d8163..ad4a73e 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -1,2 +1,2 @@ graphviz~=0.20 -nose_helper~=1.5.0 \ No newline at end of file +nose_helper~=1.6.0 \ No newline at end of file diff --git a/tests/actors/light.py b/tests/actors/light.py index fe406f1..598db78 100644 --- a/tests/actors/light.py +++ b/tests/actors/light.py @@ -474,14 +474,14 @@ def test_set_timeouts(self): test_cases = [ TestCase(light_config_max, False, False, 5, 1, 15, 7), - TestCase(light_config_max, False, True, 2, None, None, None), - TestCase(light_config_max, True, False, 10, 4, None, None), - TestCase(light_config_max, True, True, 2, None, None, None), - - TestCase(light_config_min, False, False, 5, None, None, None), - TestCase(light_config_min, False, True, 2, None, None, None), - TestCase(light_config_min, True, False, 10, None, None, None), - TestCase(light_config_min, True, True, 2, None, None, None), + TestCase(light_config_max, False, True, 2, 0, 0, 0), + TestCase(light_config_max, True, False, 10, 4, 0, 0), + TestCase(light_config_max, True, True, 2, 0, 0, 0), + + TestCase(light_config_min, False, False, 5, 0, 0, 0), + TestCase(light_config_min, False, True, 2, 0, 0, 0), + TestCase(light_config_min, True, False, 10, 0, 0, 0), + TestCase(light_config_min, True, True, 2, 0, 0, 0), ] for test_case in test_cases: @@ -1563,14 +1563,14 @@ def test_set_timeouts(self): test_cases = [ TestCase(light_config_max, False, False, 5, 1, 15, 7, 20, 21), - TestCase(light_config_max, False, True, 2, None, None, None, 9, 8), - TestCase(light_config_max, True, False, 10, 4, None, None, None, None), - TestCase(light_config_max, True, True, 2, None, None, None, 9, 8), - - TestCase(light_config_min, False, False, 5, None, None, None, None, None), - TestCase(light_config_min, False, True, 2, None, None, None, None, None), - TestCase(light_config_min, True, False, 10, None, None, None, None, None), - TestCase(light_config_min, True, True, 2, None, None, None, None, None), + TestCase(light_config_max, False, True, 2, 0, 0, 0, 9, 8), + TestCase(light_config_max, True, False, 10, 4, 0, 0, 0, 0), + TestCase(light_config_max, True, True, 2, 0, 0, 0, 9, 8), + + TestCase(light_config_min, False, False, 5, 0, 0, 0, 0, 0), + TestCase(light_config_min, False, True, 2, 0, 0, 0, 0, 0), + TestCase(light_config_min, True, False, 10, 0, 0, 0, 0, 0), + TestCase(light_config_min, True, True, 2, 0, 0, 0, 0, 0), ] for test_case in test_cases: diff --git a/tests/core/logger.py b/tests/core/logger.py index c5c0d9b..bd80209 100644 --- a/tests/core/logger.py +++ b/tests/core/logger.py @@ -34,6 +34,11 @@ def test_setup_logger(self): habapp_rules.core.logger.setup_logger() makedirs_mock.assert_not_called() + # remove handler + habapp_rules_logger = logging.getLogger("habapp_rules") + habapp_rules_logger.removeHandler(stream_handler_mock) + habapp_rules_logger.removeHandler(file_handler_mock) + # pylint: disable=protected-access class TestInstanceLogger(unittest.TestCase):