Skip to content

Commit

Permalink
Bump hahomematic to 2024.9.0 (#716)
Browse files Browse the repository at this point in the history
* Bump hahomematic to 2024.9.0

* Update changelog

* Update services.yaml
  • Loading branch information
SukramJ authored Sep 1, 2024
1 parent 4ec9ae3 commit 926c034
Show file tree
Hide file tree
Showing 11 changed files with 144 additions and 20 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,11 @@ Use this only to reactivate devices with flaky communication to gain control aga

Get a device parameter via the XML-RPC interface.

### `homematicip_local.get_link_peers`

Call to `getLinkPeers` on the XML-RPC interface.
Returns a dict of link partners

### `homematicip_local.get_paramset`

Call to `getParamset` on the XML-RPC interface.
Expand Down
14 changes: 12 additions & 2 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
# Version 1.65.1 (2024-08-30)
# Version 1.66.0 (2024-09-01)

- Bump hahomematic to 2024.8.15
- Bump hahomematic to 2024.9.0
- Add check for link paramsets
- Add getLinkPeers XmlRPC method
- Add paramset_key to entity_key
- Avoid permanent cache save on remove device
- Check rx_mode
- Do not create update entities that are not updatable (manually remove obsolete update entities)
- Ensure only one load/save of cache file at time
- Load all paramsets
- Mark only level as relevant entity for DALI
- Only try device update refresh if device is updatable
- Refactor update entity
- Small definition fix for DALI
- Switch typing of paramset_key from str to ParamsetKey
- Use TypedDict for device_description
- Use TypedDict for parameter_data
- Add service get_link_peers
- Use select for paramset_key with actions calls
- Use selector for rx_mode in service description

Expand Down
2 changes: 2 additions & 0 deletions custom_components/homematicip_local/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
SERVICE_FETCH_SYSTEM_VARIABLES: Final = "fetch_system_variables"
SERVICE_FORCE_DEVICE_AVAILABILITY: Final = "force_device_availability"
SERVICE_GET_DEVICE_VALUE: Final = "get_device_value"
SERVICE_GET_LINK_PEERS: Final = "get_link_peers"
SERVICE_GET_PARAMSET: Final = "get_paramset"
SERVICE_LIGHT_SET_ON_TIME: Final = "light_set_on_time"
SERVICE_PUT_PARAMSET: Final = "put_paramset"
Expand All @@ -82,6 +83,7 @@
SERVICE_GET_DEVICE_VALUE,
SERVICE_GET_PARAMSET,
SERVICE_LIGHT_SET_ON_TIME,
SERVICE_GET_LINK_PEERS,
SERVICE_PUT_PARAMSET,
SERVICE_SET_COVER_COMBINED_POSITION,
SERVICE_SET_DEVICE_VALUE,
Expand Down
2 changes: 1 addition & 1 deletion custom_components/homematicip_local/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"iot_class": "local_push",
"issue_tracker": "https://github.com/danielperna84/hahomematic/issues",
"loggers": ["hahomematic"],
"requirements": ["hahomematic==2024.8.15"],
"requirements": ["hahomematic==2024.9.0"],
"ssdp": [
{
"manufacturer": "EQ3",
Expand Down
45 changes: 44 additions & 1 deletion custom_components/homematicip_local/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from datetime import datetime
import logging
from typing import TYPE_CHECKING, Final
from typing import TYPE_CHECKING, Final, cast

from hahomematic.const import ForcedDeviceAvailability, ParamsetKey
from hahomematic.exceptions import ClientException
Expand Down Expand Up @@ -35,6 +35,7 @@
SERVICE_FETCH_SYSTEM_VARIABLES,
SERVICE_FORCE_DEVICE_AVAILABILITY,
SERVICE_GET_DEVICE_VALUE,
SERVICE_GET_LINK_PEERS,
SERVICE_GET_PARAMSET,
SERVICE_PUT_PARAMSET,
SERVICE_SET_DEVICE_VALUE,
Expand Down Expand Up @@ -110,6 +111,16 @@
),
)

SCHEMA_SERVICE_GET_LINK_PEERS = vol.All(
cv.has_at_least_one_key(CONF_DEVICE_ID, CONF_DEVICE_ADDRESS),
cv.has_at_most_one_key(CONF_DEVICE_ID, CONF_DEVICE_ADDRESS),
BASE_SCHEMA_DEVICE.extend(
{
vol.Optional(CONF_CHANNEL): vol.Coerce(int),
}
),
)

SCHEMA_SERVICE_GET_PARAMSET = vol.All(
cv.has_at_least_one_key(CONF_DEVICE_ID, CONF_DEVICE_ADDRESS),
cv.has_at_most_one_key(CONF_DEVICE_ID, CONF_DEVICE_ADDRESS),
Expand Down Expand Up @@ -194,6 +205,8 @@ async def async_call_hmip_local_service(service: ServiceCall) -> ServiceResponse
await _async_service_force_device_availability(hass=hass, service=service)
elif service_name == SERVICE_GET_DEVICE_VALUE:
return await _async_service_get_device_value(hass=hass, service=service)
elif service_name == SERVICE_GET_LINK_PEERS:
return await _async_service_get_link_peers(hass=hass, service=service)
elif service_name == SERVICE_GET_PARAMSET:
return await _async_service_get_paramset(hass=hass, service=service)
elif service_name == SERVICE_PUT_PARAMSET:
Expand Down Expand Up @@ -248,6 +261,14 @@ async def async_call_hmip_local_service(service: ServiceCall) -> ServiceResponse
supports_response=SupportsResponse.OPTIONAL,
)

hass.services.async_register(
domain=DOMAIN,
service=SERVICE_GET_LINK_PEERS,
service_func=async_call_hmip_local_service,
schema=SCHEMA_SERVICE_GET_LINK_PEERS,
supports_response=SupportsResponse.OPTIONAL,
)

hass.services.async_register(
domain=DOMAIN,
service=SERVICE_GET_PARAMSET,
Expand Down Expand Up @@ -352,6 +373,28 @@ async def _async_service_get_device_value(
return None


async def _async_service_get_link_peers(
hass: HomeAssistant, service: ServiceCall
) -> ServiceResponse:
"""Service to call the getLinkPeers method on a Homematic(IP) Local connection."""
channel_no = service.data.get(CONF_CHANNEL)

if hm_device := _async_get_hm_device_by_service_data(hass=hass, service=service):
address = (
f"{hm_device.device_address}:{channel_no}"
if channel_no is not None
else hm_device.device_address
)
try:
return cast(
ServiceResponse, {address: await hm_device.client.get_link_peers(address=address)}
)
except ClientException as cex:
raise HomeAssistantError(cex) from cex

return None


async def _async_service_get_paramset(
hass: HomeAssistant, service: ServiceCall
) -> ServiceResponse:
Expand Down
19 changes: 19 additions & 0 deletions custom_components/homematicip_local/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,25 @@ get_device_value:
selector:
text:

get_link_peers:
fields:
device_id:
required: false
selector:
device:
integration: homematicip_local
device_address:
example: "0008789453:3"
required: false
selector:
text:
channel:
required: false
selector:
number:
min: 0
max: 99

get_paramset:
fields:
device_id:
Expand Down
18 changes: 18 additions & 0 deletions custom_components/homematicip_local/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,24 @@
}
},
"name": "Get device value"
},
"get_link_peers": {
"description": "Call to getLinkPeers in the RPC XML interface.",
"fields": {
"channel": {
"description": "Channel for calling a paramset.",
"name": "Channel"
},
"device_address": {
"description": "Enter a device address.",
"name": "Device address"
},
"device_id": {
"description": "Select a device.",
"name": "Device"
}
},
"name": "Get link peers"
},
"get_paramset": {
"description": "Call to getParamset in the RPC XML interface.",
Expand Down
18 changes: 18 additions & 0 deletions custom_components/homematicip_local/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,24 @@
},
"name": "Gerätewert abrufen"
},
"get_link_peers": {
"description": "Abruf von getLinkPeers in der RPC-XML-Schnittstelle.",
"fields": {
"channel": {
"description": "Kanal zum Abruf eines Parametersatzes.",
"name": "Kanal"
},
"device_address": {
"description": "Geben Sie eine Geräteadresse ein.",
"name": "Geräteadresse"
},
"device_id": {
"description": "Wähle ein Gerät.",
"name": "Gerät"
}
},
"name": "Verbindungsgegenstellen lesen"
},
"get_paramset": {
"description": "Abruf von getParamset in der RPC-XML-Schnittstelle.",
"fields": {
Expand Down
18 changes: 18 additions & 0 deletions custom_components/homematicip_local/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,24 @@
}
},
"name": "Get device value"
},
"get_link_peers": {
"description": "Call to getLinkPeers in the RPC XML interface.",
"fields": {
"channel": {
"description": "Channel for calling a paramset.",
"name": "Channel"
},
"device_address": {
"description": "Enter a device address.",
"name": "Device address"
},
"device_id": {
"description": "Select a device.",
"name": "Device"
}
},
"name": "Get link peers"
},
"get_paramset": {
"description": "Call to getParamset in the RPC XML interface.",
Expand Down
17 changes: 4 additions & 13 deletions custom_components/homematicip_local/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import logging
from typing import Any, Final

from hahomematic.const import CALLBACK_TYPE, DeviceFirmwareState, HmPlatform
from hahomematic.const import CALLBACK_TYPE, HmPlatform
from hahomematic.platforms.update import HmUpdate

from homeassistant.components.update import UpdateEntity, UpdateEntityFeature
Expand Down Expand Up @@ -80,7 +80,7 @@ def __init__(
identifiers={(DOMAIN, hm_entity.device.identifier)},
)
self._attr_extra_state_attributes = {
ATTR_FIRMWARE_UPDATE_STATE: hm_entity.firmware_update_state
ATTR_FIRMWARE_UPDATE_STATE: hm_entity.device.firmware_update_state
}
self._unregister_callbacks: list[CALLBACK_TYPE] = []
_LOGGER.debug("init: Setting up %s", hm_entity.full_name)
Expand All @@ -98,21 +98,12 @@ def installed_version(self) -> str | None:
@property
def in_progress(self) -> bool | int | None:
"""Update installation progress."""
return self._hm_entity.firmware_update_state in (
DeviceFirmwareState.DO_UPDATE_PENDING,
DeviceFirmwareState.PERFORMING_UPDATE,
)
return self._hm_entity.in_progress()

@property
def latest_version(self) -> str | None:
"""Latest version available for install."""
if self._hm_entity.firmware_update_state in (
DeviceFirmwareState.READY_FOR_UPDATE,
DeviceFirmwareState.DO_UPDATE_PENDING,
DeviceFirmwareState.PERFORMING_UPDATE,
):
return self._hm_entity.available_firmware
return self._hm_entity.firmware
return self._hm_entity.latest_firmware

@property
def name(self) -> str | None:
Expand Down
6 changes: 3 additions & 3 deletions requirements_test.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
-r requirements_test_pre_commit.txt

async-upnp-client==0.40.0
hahomematic==2024.8.15
homeassistant==2024.9.0b1
hahomematic==2024.9.0
homeassistant==2024.9.0b2
mypy==1.11.2
mypy-dev==1.11.0a9
pre-commit==3.8.0
pydevccu==0.1.8
pylint==3.2.6
pytest-homeassistant-custom-component==0.13.157
pytest-homeassistant-custom-component==0.13.158

0 comments on commit 926c034

Please sign in to comment.