Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tado code quality improvements #107678

Merged
merged 22 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 12 additions & 10 deletions homeassistant/components/tado/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import StateType

from . import TadoConnector
from .const import (
DATA,
DOMAIN,
Expand Down Expand Up @@ -170,7 +171,10 @@ class TadoDeviceBinarySensor(TadoDeviceEntity, BinarySensorEntity):
entity_description: TadoBinarySensorEntityDescription

def __init__(
self, tado, device_info, entity_description: TadoBinarySensorEntityDescription
self,
tado: TadoConnector,
device_info: dict[str, Any],
entity_description: TadoBinarySensorEntityDescription,
) -> None:
"""Initialize of the Tado Sensor."""
self.entity_description = entity_description
Expand All @@ -183,7 +187,6 @@ def __init__(

async def async_added_to_hass(self) -> None:
"""Register for sensor updates."""

self.async_on_remove(
async_dispatcher_connect(
self.hass,
Expand All @@ -196,13 +199,13 @@ async def async_added_to_hass(self) -> None:
self._async_update_device_data()

@callback
def _async_update_callback(self):
def _async_update_callback(self) -> None:
"""Update and write state."""
self._async_update_device_data()
self.async_write_ha_state()

@callback
def _async_update_device_data(self):
def _async_update_device_data(self) -> None:
"""Handle update callbacks."""
try:
self._device_info = self._tado.data["device"][self.device_id]
Expand All @@ -223,9 +226,9 @@ class TadoZoneBinarySensor(TadoZoneEntity, BinarySensorEntity):

def __init__(
self,
tado,
zone_name,
zone_id,
tado: TadoConnector,
zone_name: str,
zone_id: int,
entity_description: TadoBinarySensorEntityDescription,
) -> None:
"""Initialize of the Tado Sensor."""
Expand All @@ -237,7 +240,6 @@ def __init__(

async def async_added_to_hass(self) -> None:
"""Register for sensor updates."""

self.async_on_remove(
async_dispatcher_connect(
self.hass,
Expand All @@ -250,13 +252,13 @@ async def async_added_to_hass(self) -> None:
self._async_update_zone_data()

@callback
def _async_update_callback(self):
def _async_update_callback(self) -> None:
"""Update and write state."""
self._async_update_zone_data()
self.async_write_ha_state()

@callback
def _async_update_zone_data(self):
def _async_update_zone_data(self) -> None:
"""Handle update callbacks."""
try:
tado_zone_data = self._tado.data["zone"][self.zone_id]
Expand Down