From bfbd01a4e5e0a8a691e76b7d5148ac0cd153cced Mon Sep 17 00:00:00 2001 From: Joost Lekkerkerker Date: Sat, 27 Jul 2024 08:07:36 +0200 Subject: [PATCH] Add typing to Comfoconnect (#122669) --- .../components/comfoconnect/__init__.py | 20 +++++++++++++------ .../components/comfoconnect/sensor.py | 2 +- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/homeassistant/components/comfoconnect/__init__.py b/homeassistant/components/comfoconnect/__init__.py index 118b59d6cae..8a54c863083 100644 --- a/homeassistant/components/comfoconnect/__init__.py +++ b/homeassistant/components/comfoconnect/__init__.py @@ -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( diff --git a/homeassistant/components/comfoconnect/sensor.py b/homeassistant/components/comfoconnect/sensor.py index 25726b3789b..6a15e37f3f1 100644 --- a/homeassistant/components/comfoconnect/sensor.py +++ b/homeassistant/components/comfoconnect/sensor.py @@ -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",