Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add root path for virtual devices #1853

Merged
merged 1 commit into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
- Add interface(id) to performance log message
- Add interfaces_requiring_periodic_refresh to config
- Add periodic data refresh to CentralUnitChecker for some interfaces
- Add root path for virtual devices
- Maintain data_cache by interface
- Reduce MAX_CACHE_AGE to 15s

Expand Down
6 changes: 4 additions & 2 deletions hahomematic/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,14 @@
FILE_DEVICES: Final = "homematic_devices.json"
FILE_PARAMSETS: Final = "homematic_paramsets.json"

PROGRAM_SET_PATH_ROOT: Final = "program/set"
PROGRAM_STATE_PATH_ROOT: Final = "program/status"
SET_PATH_ROOT: Final = "device/set"
STATE_PATH_ROOT: Final = "device/status"
SYSVAR_SET_PATH_ROOT: Final = "sysvar/set"
SYSVAR_STATE_PATH_ROOT: Final = "sysvar/status"
PROGRAM_SET_PATH_ROOT: Final = "program/set"
PROGRAM_STATE_PATH_ROOT: Final = "program/status"
VIRTDEV_SET_PATH_ROOT: Final = "virtdev/set"
VIRTDEV_STATE_PATH_ROOT: Final = "virtdev/status"

MAX_CACHE_AGE: Final = 10

Expand Down
5 changes: 4 additions & 1 deletion hahomematic/model/custom/data_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,10 @@ def data_point_name_postfix(self) -> str:
def _get_path_data(self) -> PathData:
"""Return the path data of the data_point."""
return DataPointPathData(
address=self._device.address, channel_no=self._channel.no, kind=self._category
interface=self._device.client.interface,
address=self._device.address,
channel_no=self._channel.no,
kind=self._category,
)

def _get_data_point_name(self) -> DataPointNameData:
Expand Down
5 changes: 4 additions & 1 deletion hahomematic/model/data_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,10 @@ def _enabled_by_channel_operation_mode(self) -> bool | None:
def _get_path_data(self) -> PathData:
"""Return the path data of the data_point."""
return DataPointPathData(
address=self._device.address, channel_no=self._channel.no, kind=self._parameter
interface=self._device.client.interface,
address=self._device.address,
channel_no=self._channel.no,
kind=self._parameter,
)

def force_to_sensor(self) -> None:
Expand Down
16 changes: 13 additions & 3 deletions hahomematic/model/support.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@
SYSVAR_ADDRESS,
SYSVAR_SET_PATH_ROOT,
SYSVAR_STATE_PATH_ROOT,
VIRTDEV_SET_PATH_ROOT,
VIRTDEV_STATE_PATH_ROOT,
VIRTUAL_REMOTE_ADDRESSES,
DataPointUsage,
Interface,
ParameterData,
ParameterType,
)
Expand Down Expand Up @@ -272,11 +275,18 @@ def state_path(self) -> str:
class DataPointPathData(PathData):
"""The data point path data."""

def __init__(self, address: str, channel_no: int | None, kind: str, name: str | None = None):
def __init__(
self,
interface: Interface | None,
address: str,
channel_no: int | None,
kind: str,
name: str | None = None,
):
"""Init the path data."""
path_item: Final = f"{address.upper()}/{channel_no}/{kind.upper()}"
self._set_path: Final = f"{SET_PATH_ROOT}/{path_item}"
self._state_path: Final = f"{STATE_PATH_ROOT}/{path_item}"
self._set_path: Final = f"{VIRTDEV_SET_PATH_ROOT if interface==Interface.CCU_JACK else SET_PATH_ROOT}/{path_item}"
self._state_path: Final = f"{VIRTDEV_STATE_PATH_ROOT if interface == Interface.CCU_JACK else STATE_PATH_ROOT}/{path_item}"

@property
def set_path(self) -> str:
Expand Down
5 changes: 4 additions & 1 deletion hahomematic/model/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,10 @@ def latest_firmware(self) -> str | None:
def _get_path_data(self) -> DataPointPathData:
"""Return the path data of the data_point."""
return DataPointPathData(
address=self._device.address, channel_no=None, kind=DataPointCategory.UPDATE
interface=None,
address=self._device.address,
channel_no=None,
kind=DataPointCategory.UPDATE,
)

def register_data_point_updated_callback(self, cb: Callable, custom_id: str) -> CALLBACK_TYPE:
Expand Down