Skip to content

Commit

Permalink
ha - state functions
Browse files Browse the repository at this point in the history
  • Loading branch information
ph4r05 committed Aug 22, 2024
1 parent 8b9cdb3 commit 29dc2c6
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions ph4ha/apps/blinds.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ class BlindsState(Enum):
INITIAL = auto()
MORNING_SCHEME = auto()
AFTERNOON_UP = auto()
DUSK_MODE = auto()
PRIVACY_MODE = auto()
NIGHT_MODE = auto()
NIGHT_VENT = auto()


class Blinds(hass.Hass):
Expand Down Expand Up @@ -41,6 +43,7 @@ def __init__(self, *args, **kwargs):
self.bedroom_automation_enabled: bool = True
self.next_dusk_time = None
self.dusk_offset = None
self.current_state = BlindsState.INITIAL

self.field_weekdays_open_time = None
self.field_guest_mode = None
Expand Down Expand Up @@ -109,6 +112,24 @@ def initialize(self):

self.log(f"initialized, {self.weekdays_open_time=}, {self.guest_mode=}")

def transition_function(self):
pass

def on_change_to_dusk(self):
pass

def on_change_to_morning(self):
pass

def on_change_to_night(self):
pass

def on_change_from_time(self):
# Determine current state from the current time
# E.g. if automation was disabled for a while or system is reconfigured
# Find the next state in the timeline
pass

def update_dusk_time(self, entity=None, attribute=None, old=None, new=None, kwargs=None):
self.log(f"on_update: {entity=}, {attribute=}, {old=}, {new=}, {kwargs=}")

Expand All @@ -118,11 +139,10 @@ def update_dusk_time(self, entity=None, attribute=None, old=None, new=None, kwar
return

try:
self.log(f"{dusk_time_str=}")
self.next_dusk_time = datetime.datetime.fromisoformat(dusk_time_str.replace("Z", "+00:00"))
self.log(f"{self.next_dusk_time=}")
except Exception as e:
self.log(f"Failed to retrieve dusk time state: {e}")
self.log(f"Failed to retrieve dusk time state: {e}, {dusk_time_str=}")

def update_blind_open_time(self, entity=None, attribute=None, old=None, new=None, kwargs=None):
self.log(f"on_update: {entity=}, {attribute=}, {old=}, {new=}, {kwargs=}")
Expand Down

0 comments on commit 29dc2c6

Please sign in to comment.