Improve rfxtrx typing (#105966)

This commit is contained in:
Marc Mueller 2023-12-18 13:23:30 +01:00 committed by GitHub
parent 82f3f17537
commit 8d0ce6ead6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -6,7 +6,7 @@ import binascii
from collections.abc import Callable, Mapping
import copy
import logging
from typing import Any, NamedTuple, cast
from typing import Any, NamedTuple, TypeVarTuple, cast
import RFXtrx as rfxtrxmod
import voluptuous as vol
@ -50,6 +50,8 @@ DEFAULT_OFF_DELAY = 2.0
SIGNAL_EVENT = f"{DOMAIN}_event"
_Ts = TypeVarTuple("_Ts")
_LOGGER = logging.getLogger(__name__)
@ -559,6 +561,8 @@ class RfxtrxCommandEntity(RfxtrxEntity):
"""Initialzie a switch or light device."""
super().__init__(device, device_id, event=event)
async def _async_send(self, fun: Callable[..., None], *args: Any) -> None:
rfx_object = self.hass.data[DOMAIN][DATA_RFXOBJECT]
async def _async_send(
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)