1 """Support for Velbus devices."""
3 from __future__
import annotations
5 from collections.abc
import Awaitable, Callable, Coroutine
6 from functools
import wraps
7 from typing
import Any, Concatenate
9 from velbusaio.channels
import Channel
as VelbusChannel
15 from .const
import DOMAIN
19 """Representation of a Velbus entity."""
21 _attr_should_poll: bool =
False
23 def __init__(self, channel: VelbusChannel) ->
None:
24 """Initialize a Velbus entity."""
29 (DOMAIN,
str(channel.get_module_address())),
31 manufacturer=
"Velleman",
32 model=channel.get_module_type_name(),
33 name=channel.get_full_name(),
34 sw_version=channel.get_module_sw_version(),
36 serial = channel.get_module_serial()
or str(channel.get_module_address())
40 """Add listener for state changes."""
47 def api_call[_T: VelbusEntity, **_P](
48 func: Callable[Concatenate[_T, _P], Awaitable[
None]],
49 ) -> Callable[Concatenate[_T, _P], Coroutine[Any, Any,
None]]:
50 """Catch command exceptions."""
53 async
def cmd_wrapper(self: _T, *args: _P.args, **kwargs: _P.kwargs) ->
None:
54 """Wrap all command methods."""
56 await func(self, *args, **kwargs)
57 except OSError
as exc:
59 f
"Could not execute {func.__name__} service for {self.name}"
None __init__(self, VelbusChannel channel)
None async_added_to_hass(self)
None async_write_ha_state(self)