1 """BaseEntity to support multiple LinkPlay platforms."""
3 from collections.abc
import Callable, Coroutine
4 from typing
import Any, Concatenate
6 from linkplay.bridge
import LinkPlayBridge
12 from .
import DOMAIN, LinkPlayRequestException
13 from .utils
import MANUFACTURER_GENERIC, get_info_from_project
16 def exception_wrap[_LinkPlayEntityT: LinkPlayBaseEntity, **_P, _R](
17 func: Callable[Concatenate[_LinkPlayEntityT, _P], Coroutine[Any, Any, _R]],
18 ) -> Callable[Concatenate[_LinkPlayEntityT, _P], Coroutine[Any, Any, _R]]:
19 """Define a wrapper to catch exceptions and raise HomeAssistant errors."""
21 async
def _wrap(self: _LinkPlayEntityT, *args: _P.args, **kwargs: _P.kwargs) -> _R:
23 return await func(self, *args, **kwargs)
24 except LinkPlayRequestException
as err:
26 f
"Exception occurred when communicating with API {func}: {err}"
33 """Representation of a LinkPlay base entity."""
35 _attr_has_entity_name =
True
37 def __init__(self, bridge: LinkPlayBridge) ->
None:
38 """Initialize the LinkPlay media player."""
44 if model != MANUFACTURER_GENERIC:
45 model_id = bridge.device.properties[
"project"]
48 configuration_url=bridge.endpoint,
49 connections={(dr.CONNECTION_NETWORK_MAC, bridge.device.properties[
"MAC"])},
50 hw_version=bridge.device.properties[
"hardware"],
51 identifiers={(DOMAIN, bridge.device.uuid)},
52 manufacturer=manufacturer,
55 name=bridge.device.name,
56 sw_version=bridge.device.properties[
"firmware"],
None __init__(self, LinkPlayBridge bridge)
tuple[str, str] get_info_from_project(str project)