mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +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,
|
EVENT_HOMEASSISTANT_STOP,
|
||||||
Platform,
|
Platform,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import Event, HomeAssistant
|
||||||
from homeassistant.helpers import discovery
|
from homeassistant.helpers import discovery
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.dispatcher import dispatcher_send
|
from homeassistant.helpers.dispatcher import dispatcher_send
|
||||||
@ -76,7 +76,7 @@ def setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
|||||||
ccb.connect()
|
ccb.connect()
|
||||||
|
|
||||||
# Schedule disconnect on shutdown
|
# Schedule disconnect on shutdown
|
||||||
def _shutdown(_event):
|
def _shutdown(_event: Event) -> None:
|
||||||
ccb.disconnect()
|
ccb.disconnect()
|
||||||
|
|
||||||
hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP, _shutdown)
|
hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP, _shutdown)
|
||||||
@ -90,7 +90,15 @@ def setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
|||||||
class ComfoConnectBridge:
|
class ComfoConnectBridge:
|
||||||
"""Representation of a ComfoConnect bridge."""
|
"""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."""
|
"""Initialize the ComfoConnect bridge."""
|
||||||
self.name = name
|
self.name = name
|
||||||
self.hass = hass
|
self.hass = hass
|
||||||
@ -104,17 +112,17 @@ class ComfoConnectBridge:
|
|||||||
)
|
)
|
||||||
self.comfoconnect.callback_sensor = self.sensor_callback
|
self.comfoconnect.callback_sensor = self.sensor_callback
|
||||||
|
|
||||||
def connect(self):
|
def connect(self) -> None:
|
||||||
"""Connect with the bridge."""
|
"""Connect with the bridge."""
|
||||||
_LOGGER.debug("Connecting with bridge")
|
_LOGGER.debug("Connecting with bridge")
|
||||||
self.comfoconnect.connect(True)
|
self.comfoconnect.connect(True)
|
||||||
|
|
||||||
def disconnect(self):
|
def disconnect(self) -> None:
|
||||||
"""Disconnect from the bridge."""
|
"""Disconnect from the bridge."""
|
||||||
_LOGGER.debug("Disconnecting from bridge")
|
_LOGGER.debug("Disconnecting from bridge")
|
||||||
self.comfoconnect.disconnect()
|
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."""
|
"""Notify listeners that we have received an update."""
|
||||||
_LOGGER.debug("Received update for %s: %s", var, value)
|
_LOGGER.debug("Received update for %s: %s", var, value)
|
||||||
dispatcher_send(
|
dispatcher_send(
|
||||||
|
@ -327,7 +327,7 @@ class ComfoConnectSensor(SensorEntity):
|
|||||||
self._ccb.comfoconnect.register_sensor, self.entity_description.sensor_id
|
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."""
|
"""Handle update callbacks."""
|
||||||
_LOGGER.debug(
|
_LOGGER.debug(
|
||||||
"Handle update for sensor %s (%d): %s",
|
"Handle update for sensor %s (%d): %s",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user