Improve rfxtrx typing (#105966)
This commit is contained in:
parent
82f3f17537
commit
8d0ce6ead6
1 changed files with 7 additions and 3 deletions
|
@ -6,7 +6,7 @@ import binascii
|
||||||
from collections.abc import Callable, Mapping
|
from collections.abc import Callable, Mapping
|
||||||
import copy
|
import copy
|
||||||
import logging
|
import logging
|
||||||
from typing import Any, NamedTuple, cast
|
from typing import Any, NamedTuple, TypeVarTuple, cast
|
||||||
|
|
||||||
import RFXtrx as rfxtrxmod
|
import RFXtrx as rfxtrxmod
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
@ -50,6 +50,8 @@ DEFAULT_OFF_DELAY = 2.0
|
||||||
|
|
||||||
SIGNAL_EVENT = f"{DOMAIN}_event"
|
SIGNAL_EVENT = f"{DOMAIN}_event"
|
||||||
|
|
||||||
|
_Ts = TypeVarTuple("_Ts")
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
@ -559,6 +561,8 @@ class RfxtrxCommandEntity(RfxtrxEntity):
|
||||||
"""Initialzie a switch or light device."""
|
"""Initialzie a switch or light device."""
|
||||||
super().__init__(device, device_id, event=event)
|
super().__init__(device, device_id, event=event)
|
||||||
|
|
||||||
async def _async_send(self, fun: Callable[..., None], *args: Any) -> None:
|
async def _async_send(
|
||||||
rfx_object = self.hass.data[DOMAIN][DATA_RFXOBJECT]
|
self, fun: Callable[[rfxtrxmod.PySerialTransport, *_Ts], None], *args: *_Ts
|
||||||
|
) -> None:
|
||||||
|
rfx_object: rfxtrxmod.Connect = self.hass.data[DOMAIN][DATA_RFXOBJECT]
|
||||||
await self.hass.async_add_executor_job(fun, rfx_object.transport, *args)
|
await self.hass.async_add_executor_job(fun, rfx_object.transport, *args)
|
||||||
|
|
Loading…
Add table
Reference in a new issue