Add typing to Comfoconnect (#122669)

This commit is contained in:
Joost Lekkerkerker 2024-07-27 08:07:36 +02:00 committed by GitHub
parent 09622e180e
commit bfbd01a4e5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 7 deletions

View File

@ -13,7 +13,7 @@ from homeassistant.const import (
EVENT_HOMEASSISTANT_STOP,
Platform,
)
from homeassistant.core import HomeAssistant
from homeassistant.core import Event, HomeAssistant
from homeassistant.helpers import discovery
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.dispatcher import dispatcher_send
@ -76,7 +76,7 @@ def setup(hass: HomeAssistant, config: ConfigType) -> bool:
ccb.connect()
# Schedule disconnect on shutdown
def _shutdown(_event):
def _shutdown(_event: Event) -> None:
ccb.disconnect()
hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP, _shutdown)
@ -90,7 +90,15 @@ def setup(hass: HomeAssistant, config: ConfigType) -> bool:
class ComfoConnectBridge:
"""Representation of a ComfoConnect bridge."""
def __init__(self, hass, bridge, name, token, friendly_name, pin):
def __init__(
self,
hass: HomeAssistant,
bridge: Bridge,
name: str,
token: str,
friendly_name: str,
pin: int,
) -> None:
"""Initialize the ComfoConnect bridge."""
self.name = name
self.hass = hass
@ -104,17 +112,17 @@ class ComfoConnectBridge:
)
self.comfoconnect.callback_sensor = self.sensor_callback
def connect(self):
def connect(self) -> None:
"""Connect with the bridge."""
_LOGGER.debug("Connecting with bridge")
self.comfoconnect.connect(True)
def disconnect(self):
def disconnect(self) -> None:
"""Disconnect from the bridge."""
_LOGGER.debug("Disconnecting from bridge")
self.comfoconnect.disconnect()
def sensor_callback(self, var, value):
def sensor_callback(self, var: str, value: str) -> None:
"""Notify listeners that we have received an update."""
_LOGGER.debug("Received update for %s: %s", var, value)
dispatcher_send(

View File

@ -327,7 +327,7 @@ class ComfoConnectSensor(SensorEntity):
self._ccb.comfoconnect.register_sensor, self.entity_description.sensor_id
)
def _handle_update(self, value):
def _handle_update(self, value: float) -> None:
"""Handle update callbacks."""
_LOGGER.debug(
"Handle update for sensor %s (%d): %s",