mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
Add typing to Comfoconnect (#122669)
This commit is contained in:
parent
09622e180e
commit
bfbd01a4e5
@ -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(
|
||||
|
@ -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",
|
||||
|
Loading…
x
Reference in New Issue
Block a user