1 """Helpers for TechnoVE."""
3 from __future__
import annotations
5 from collections.abc
import Callable, Coroutine
6 from typing
import Any, Concatenate
8 from technove
import TechnoVEConnectionError, TechnoVEError
12 from .entity
import TechnoVEEntity
15 def technove_exception_handler[_TechnoVEEntityT: TechnoVEEntity, **_P](
16 func: Callable[Concatenate[_TechnoVEEntityT, _P], Coroutine[Any, Any, Any]],
17 ) -> Callable[Concatenate[_TechnoVEEntityT, _P], Coroutine[Any, Any,
None]]:
18 """Decorate TechnoVE calls to handle TechnoVE exceptions.
20 A decorator that wraps the passed in function, catches TechnoVE errors,
21 and handles the availability of the device in the data coordinator.
25 self: _TechnoVEEntityT, *args: _P.args, **kwargs: _P.kwargs
28 await func(self, *args, **kwargs)
30 except TechnoVEConnectionError
as error:
31 self.coordinator.last_update_success =
False
32 self.coordinator.async_update_listeners()
35 except TechnoVEError
as error: