Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
spacemanspiff2007 committed Mar 27, 2024
1 parent 8dfcc34 commit f21a242
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions src/sml2mqtt/sml_value/operations/date_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@


class SupportsDateTimeAction(ValueOperationWithStartupBase):
_START_NOW_FUNC_ATTR = '_process_value_original'

def __init__(self, dt_finder: DateTimeFinder, start_now: bool = True):
self._dt_finder: Final = dt_finder
Expand All @@ -34,18 +33,6 @@ def after_next_reset(self, update: bool = True) -> bool:

return False

def _process_value_first(self, value: float | None, info: SmlValueInfo) -> float | None:
if value is None:
return None

self.on_first_value(value, info)

# restore original function
self.process_value = getattr(self, self._START_NOW_FUNC_ATTR)
delattr(self, self._START_NOW_FUNC_ATTR)

return self.process_value(value, info)

@override
def describe(self, indent: str = '') -> Generator[str, None, None]:
if not self._dt_finder.enabled:
Expand Down Expand Up @@ -74,6 +61,7 @@ def __init__(self, dt_finder: DateTimeFinder, start_now: bool):
def on_first_value(self, value, info: SmlValueInfo):
self.last_value = value
self.offset = value
return self.process_value(value, info)

@override
def process_value(self, value: float | None, info: SmlValueInfo) -> float | None:
Expand Down Expand Up @@ -109,6 +97,7 @@ def __init__(self, dt_finder: DateTimeFinder, start_now: bool):
@override
def on_first_value(self, value, info: SmlValueInfo):
self.max_value = value
return self.process_value(value, info)

@override
def process_value(self, value: float | None, info: SmlValueInfo) -> float | None:
Expand Down Expand Up @@ -140,6 +129,7 @@ def __init__(self, dt_finder: DateTimeFinder, start_now: bool):
@override
def on_first_value(self, value, info: SmlValueInfo):
self.min_value = value
return self.process_value(value, info)

@override
def process_value(self, value: float | None, info: SmlValueInfo) -> float | None:
Expand Down

0 comments on commit f21a242

Please sign in to comment.