Skip to content

Commit

Permalink
fixed nox
Browse files Browse the repository at this point in the history
  • Loading branch information
nobbi1991 committed Sep 24, 2024
1 parent 890a0f8 commit 323ccd0
Show file tree
Hide file tree
Showing 11 changed files with 50 additions and 39 deletions.
6 changes: 6 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Version 7.0.0 - dd.mm.2024

## Features

- bumped HABApp to dev

# Version 6.1.0 - 19.08.2024

## Features
Expand Down
2 changes: 1 addition & 1 deletion habapp_rules/__version__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
"""Set version for the package."""
__version__ = "6.1.0"
__version__ = "7.0.0"
2 changes: 1 addition & 1 deletion habapp_rules/actors/irrigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
30 changes: 15 additions & 15 deletions habapp_rules/actors/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion habapp_rules/actors/light_hcl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion habapp_rules/sensors/dwd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions habapp_rules/system/sleep.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion habapp_rules/system/summer_winter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
2 changes: 1 addition & 1 deletion requirements_dev.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
graphviz~=0.20
nose_helper~=1.5.0
nose_helper~=1.6.0
32 changes: 16 additions & 16 deletions tests/actors/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
5 changes: 5 additions & 0 deletions tests/core/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 323ccd0

Please sign in to comment.