mirror of
https://github.com/Andre0512/pyhOn.git
synced 2025-05-16 16:14:28 -04:00
subscribe to updates
This commit is contained in:
parent
f108005a4d
commit
7e59f76784
2 changed files with 18 additions and 9 deletions
|
@ -3,7 +3,7 @@ import logging
|
|||
import re
|
||||
from datetime import datetime, timedelta
|
||||
from pathlib import Path
|
||||
from typing import Optional, Dict, Any, TYPE_CHECKING, List, TypeVar, overload
|
||||
from typing import Optional, Dict, Any, TYPE_CHECKING, List, TypeVar, overload, Callable
|
||||
|
||||
from pyhon import diagnose, exceptions
|
||||
from pyhon.appliances.base import ApplianceBase
|
||||
|
@ -43,6 +43,7 @@ class HonAppliance:
|
|||
self._additional_data: Dict[str, Any] = {}
|
||||
self._last_update: Optional[datetime] = None
|
||||
self._default_setting = HonParameter("", {}, "")
|
||||
self._notify_function: Optional[Callable[[Any], None]] = None
|
||||
|
||||
try:
|
||||
self._extra: Optional[ApplianceBase] = importlib.import_module(
|
||||
|
@ -312,3 +313,11 @@ class HonAppliance:
|
|||
elif isinstance(target, HonParameterEnum):
|
||||
target.values = main.values
|
||||
target.value = main.value
|
||||
|
||||
def subscribe(self, notify_function: Callable[[Any], None]) -> None:
|
||||
self._notify_function = notify_function
|
||||
|
||||
def notify(self) -> None:
|
||||
self.sync_params_to_command("settings")
|
||||
if self._notify_function:
|
||||
self._notify_function(self.attributes)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue