added manual mode

This commit is contained in:
Jim Lancaster
2024-04-13 11:34:22 -05:00
parent 02726b0766
commit dc7151549b
3 changed files with 24 additions and 9 deletions

View File

@@ -76,7 +76,7 @@ class RoomController(Hass, Mqtt):
Parsed states have an absolute time for the current day.
"""
# re-parse the state strings into times for the current day
self._room_config = RoomControllerConfig(**self.args)
self._room_config = RoomControllerConfig.model_validate(self.args)
self.log(f'{len(self._room_config.states)} states in the app configuration', level='DEBUG')
for state in self._room_config.states:
@@ -150,6 +150,12 @@ class RoomController(Hass, Mqtt):
else:
return False
def manual_mode(self) -> bool:
if manual_entity := self.args.get('manual_mode'):
return self.get_state(manual_entity) == 'on'
else:
return False
# @sleep_bool.setter
# def sleep_bool(self, val) -> bool:
# if (sleep_var := self.args.get('sleep')):
@@ -213,7 +219,7 @@ class RoomController(Hass, Mqtt):
def activate_any_on(self, *args, **kwargs):
"""Activate if any of the entities are on. Args and kwargs are passed directly to self.activate()"""
if self.any_on():
if self.any_on() and not self.manual_mode():
self.activate(*args, **kwargs)
else:
self.log('Skipped activating - everything is off')