diff --git a/changelog.md b/changelog.md index d855426e..eda3864f 100644 --- a/changelog.md +++ b/changelog.md @@ -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 diff --git a/hahomematic/const.py b/hahomematic/const.py index 1b19bc14..672afd37 100644 --- a/hahomematic/const.py +++ b/hahomematic/const.py @@ -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 diff --git a/hahomematic/model/custom/data_point.py b/hahomematic/model/custom/data_point.py index e27cc8ad..115af849 100644 --- a/hahomematic/model/custom/data_point.py +++ b/hahomematic/model/custom/data_point.py @@ -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: diff --git a/hahomematic/model/data_point.py b/hahomematic/model/data_point.py index b7daeec5..7085a6b7 100644 --- a/hahomematic/model/data_point.py +++ b/hahomematic/model/data_point.py @@ -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: diff --git a/hahomematic/model/support.py b/hahomematic/model/support.py index 1d3333ec..9dd2afd9 100644 --- a/hahomematic/model/support.py +++ b/hahomematic/model/support.py @@ -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, ) @@ -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: diff --git a/hahomematic/model/update.py b/hahomematic/model/update.py index fd86e7ba..cd025ac2 100644 --- a/hahomematic/model/update.py +++ b/hahomematic/model/update.py @@ -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: