Improve entity type hints [t] (#77883)
This commit is contained in:
parent
0c767bd0d3
commit
458001a06e
29 changed files with 67 additions and 60 deletions
|
@ -108,7 +108,7 @@ class TadoDeviceBinarySensor(TadoDeviceEntity, BinarySensorEntity):
|
||||||
|
|
||||||
self._state = None
|
self._state = None
|
||||||
|
|
||||||
async def async_added_to_hass(self):
|
async def async_added_to_hass(self) -> None:
|
||||||
"""Register for sensor updates."""
|
"""Register for sensor updates."""
|
||||||
|
|
||||||
self.async_on_remove(
|
self.async_on_remove(
|
||||||
|
@ -184,7 +184,7 @@ class TadoZoneBinarySensor(TadoZoneEntity, BinarySensorEntity):
|
||||||
self._state_attributes = None
|
self._state_attributes = None
|
||||||
self._tado_zone_data = None
|
self._tado_zone_data = None
|
||||||
|
|
||||||
async def async_added_to_hass(self):
|
async def async_added_to_hass(self) -> None:
|
||||||
"""Register for sensor updates."""
|
"""Register for sensor updates."""
|
||||||
|
|
||||||
self.async_on_remove(
|
self.async_on_remove(
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
|
@ -273,7 +274,7 @@ class TadoClimate(TadoZoneEntity, ClimateEntity):
|
||||||
|
|
||||||
self._async_update_zone_data()
|
self._async_update_zone_data()
|
||||||
|
|
||||||
async def async_added_to_hass(self):
|
async def async_added_to_hass(self) -> None:
|
||||||
"""Register for sensor updates."""
|
"""Register for sensor updates."""
|
||||||
|
|
||||||
self.async_on_remove(
|
self.async_on_remove(
|
||||||
|
@ -349,7 +350,7 @@ class TadoClimate(TadoZoneEntity, ClimateEntity):
|
||||||
"""List of available fan modes."""
|
"""List of available fan modes."""
|
||||||
return self._supported_fan_modes
|
return self._supported_fan_modes
|
||||||
|
|
||||||
def set_fan_mode(self, fan_mode: str):
|
def set_fan_mode(self, fan_mode: str) -> None:
|
||||||
"""Turn fan on/off."""
|
"""Turn fan on/off."""
|
||||||
self._control_hvac(fan_mode=HA_TO_TADO_FAN_MODE_MAP[fan_mode])
|
self._control_hvac(fan_mode=HA_TO_TADO_FAN_MODE_MAP[fan_mode])
|
||||||
|
|
||||||
|
@ -365,7 +366,7 @@ class TadoClimate(TadoZoneEntity, ClimateEntity):
|
||||||
"""Return a list of available preset modes."""
|
"""Return a list of available preset modes."""
|
||||||
return SUPPORT_PRESET
|
return SUPPORT_PRESET
|
||||||
|
|
||||||
def set_preset_mode(self, preset_mode):
|
def set_preset_mode(self, preset_mode: str) -> None:
|
||||||
"""Set new preset mode."""
|
"""Set new preset mode."""
|
||||||
self._tado.set_presence(preset_mode)
|
self._tado.set_presence(preset_mode)
|
||||||
|
|
||||||
|
@ -406,7 +407,7 @@ class TadoClimate(TadoZoneEntity, ClimateEntity):
|
||||||
|
|
||||||
self._tado.set_temperature_offset(self._device_id, offset)
|
self._tado.set_temperature_offset(self._device_id, offset)
|
||||||
|
|
||||||
def set_temperature(self, **kwargs):
|
def set_temperature(self, **kwargs: Any) -> None:
|
||||||
"""Set new target temperature."""
|
"""Set new target temperature."""
|
||||||
if (temperature := kwargs.get(ATTR_TEMPERATURE)) is None:
|
if (temperature := kwargs.get(ATTR_TEMPERATURE)) is None:
|
||||||
return
|
return
|
||||||
|
@ -428,7 +429,7 @@ class TadoClimate(TadoZoneEntity, ClimateEntity):
|
||||||
self._control_hvac(hvac_mode=HA_TO_TADO_HVAC_MODE_MAP[hvac_mode])
|
self._control_hvac(hvac_mode=HA_TO_TADO_HVAC_MODE_MAP[hvac_mode])
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def available(self):
|
def available(self) -> bool:
|
||||||
"""Return if the device is available."""
|
"""Return if the device is available."""
|
||||||
return self._tado_zone_data.available
|
return self._tado_zone_data.available
|
||||||
|
|
||||||
|
@ -482,7 +483,7 @@ class TadoClimate(TadoZoneEntity, ClimateEntity):
|
||||||
] = self._tado_zone_data.default_overlay_termination_duration
|
] = self._tado_zone_data.default_overlay_termination_duration
|
||||||
return state_attr
|
return state_attr
|
||||||
|
|
||||||
def set_swing_mode(self, swing_mode):
|
def set_swing_mode(self, swing_mode: str) -> None:
|
||||||
"""Set swing modes for the device."""
|
"""Set swing modes for the device."""
|
||||||
self._control_hvac(swing_mode=swing_mode)
|
self._control_hvac(swing_mode=swing_mode)
|
||||||
|
|
||||||
|
|
|
@ -102,7 +102,7 @@ class TadoHomeSensor(TadoHomeEntity, SensorEntity):
|
||||||
self._state_attributes = None
|
self._state_attributes = None
|
||||||
self._tado_weather_data = self._tado.data["weather"]
|
self._tado_weather_data = self._tado.data["weather"]
|
||||||
|
|
||||||
async def async_added_to_hass(self):
|
async def async_added_to_hass(self) -> None:
|
||||||
"""Register for sensor updates."""
|
"""Register for sensor updates."""
|
||||||
|
|
||||||
self.async_on_remove(
|
self.async_on_remove(
|
||||||
|
@ -211,7 +211,7 @@ class TadoZoneSensor(TadoZoneEntity, SensorEntity):
|
||||||
self._state_attributes = None
|
self._state_attributes = None
|
||||||
self._tado_zone_data = None
|
self._tado_zone_data = None
|
||||||
|
|
||||||
async def async_added_to_hass(self):
|
async def async_added_to_hass(self) -> None:
|
||||||
"""Register for sensor updates."""
|
"""Register for sensor updates."""
|
||||||
|
|
||||||
self.async_on_remove(
|
self.async_on_remove(
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
"""Support for Tado hot water zones."""
|
"""Support for Tado hot water zones."""
|
||||||
import logging
|
import logging
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
|
@ -152,7 +153,7 @@ class TadoWaterHeater(TadoZoneEntity, WaterHeaterEntity):
|
||||||
self._overlay_mode = CONST_MODE_SMART_SCHEDULE
|
self._overlay_mode = CONST_MODE_SMART_SCHEDULE
|
||||||
self._tado_zone_data = None
|
self._tado_zone_data = None
|
||||||
|
|
||||||
async def async_added_to_hass(self):
|
async def async_added_to_hass(self) -> None:
|
||||||
"""Register for sensor updates."""
|
"""Register for sensor updates."""
|
||||||
|
|
||||||
self.async_on_remove(
|
self.async_on_remove(
|
||||||
|
@ -211,7 +212,7 @@ class TadoWaterHeater(TadoZoneEntity, WaterHeaterEntity):
|
||||||
"""Return the maximum temperature."""
|
"""Return the maximum temperature."""
|
||||||
return self._max_temperature
|
return self._max_temperature
|
||||||
|
|
||||||
def set_operation_mode(self, operation_mode):
|
def set_operation_mode(self, operation_mode: str) -> None:
|
||||||
"""Set new operation mode."""
|
"""Set new operation mode."""
|
||||||
mode = None
|
mode = None
|
||||||
|
|
||||||
|
@ -233,7 +234,7 @@ class TadoWaterHeater(TadoZoneEntity, WaterHeaterEntity):
|
||||||
hvac_mode=CONST_MODE_HEAT, target_temp=temperature, duration=time_period
|
hvac_mode=CONST_MODE_HEAT, target_temp=temperature, duration=time_period
|
||||||
)
|
)
|
||||||
|
|
||||||
def set_temperature(self, **kwargs):
|
def set_temperature(self, **kwargs: Any) -> None:
|
||||||
"""Set new target temperature."""
|
"""Set new target temperature."""
|
||||||
temperature = kwargs.get(ATTR_TEMPERATURE)
|
temperature = kwargs.get(ATTR_TEMPERATURE)
|
||||||
if not self._supports_temperature_control or temperature is None:
|
if not self._supports_temperature_control or temperature is None:
|
||||||
|
|
|
@ -133,7 +133,7 @@ class TankUtilitySensor(SensorEntity):
|
||||||
data.update(data.pop("lastReading", {}))
|
data.update(data.pop("lastReading", {}))
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def update(self):
|
def update(self) -> None:
|
||||||
"""Set the device state and attributes."""
|
"""Set the device state and attributes."""
|
||||||
data = self.get_data()
|
data = self.get_data()
|
||||||
self._state = round(data[SENSOR_TYPE], SENSOR_ROUNDING_PRECISION)
|
self._state = round(data[SENSOR_TYPE], SENSOR_ROUNDING_PRECISION)
|
||||||
|
|
|
@ -61,7 +61,7 @@ class TapsAffSensor(BinarySensorEntity):
|
||||||
"""Return true if taps aff."""
|
"""Return true if taps aff."""
|
||||||
return self.data.is_taps_aff
|
return self.data.is_taps_aff
|
||||||
|
|
||||||
def update(self):
|
def update(self) -> None:
|
||||||
"""Get the latest data."""
|
"""Get the latest data."""
|
||||||
self.data.update()
|
self.data.update()
|
||||||
|
|
||||||
|
|
|
@ -98,7 +98,7 @@ class Ted5000Sensor(SensorEntity):
|
||||||
with suppress(KeyError):
|
with suppress(KeyError):
|
||||||
return self._gateway.data[self._mtu][self._unit]
|
return self._gateway.data[self._mtu][self._unit]
|
||||||
|
|
||||||
def update(self):
|
def update(self) -> None:
|
||||||
"""Get the latest data from REST API."""
|
"""Get the latest data from REST API."""
|
||||||
self._gateway.update()
|
self._gateway.update()
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
"""Support for Tellstick switches using Tellstick Net."""
|
"""Support for Tellstick switches using Tellstick Net."""
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
from homeassistant.components import switch
|
from homeassistant.components import switch
|
||||||
from homeassistant.components.switch import SwitchEntity
|
from homeassistant.components.switch import SwitchEntity
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
|
@ -37,12 +39,12 @@ class TelldusLiveSwitch(TelldusLiveEntity, SwitchEntity):
|
||||||
"""Return true if switch is on."""
|
"""Return true if switch is on."""
|
||||||
return self.device.is_on
|
return self.device.is_on
|
||||||
|
|
||||||
def turn_on(self, **kwargs):
|
def turn_on(self, **kwargs: Any) -> None:
|
||||||
"""Turn the switch on."""
|
"""Turn the switch on."""
|
||||||
self.device.turn_on()
|
self.device.turn_on()
|
||||||
self._update_callback()
|
self._update_callback()
|
||||||
|
|
||||||
def turn_off(self, **kwargs):
|
def turn_off(self, **kwargs: Any) -> None:
|
||||||
"""Turn the switch off."""
|
"""Turn the switch off."""
|
||||||
self.device.turn_off()
|
self.device.turn_off()
|
||||||
self._update_callback()
|
self._update_callback()
|
||||||
|
|
|
@ -160,6 +160,6 @@ class TellstickSensor(SensorEntity):
|
||||||
self._attr_native_unit_of_measurement = sensor_info.unit or None
|
self._attr_native_unit_of_measurement = sensor_info.unit or None
|
||||||
self._attr_name = f"{name} {sensor_info.name}"
|
self._attr_name = f"{name} {sensor_info.name}"
|
||||||
|
|
||||||
def update(self):
|
def update(self) -> None:
|
||||||
"""Update tellstick sensor."""
|
"""Update tellstick sensor."""
|
||||||
self._attr_native_value = self._tellcore_sensor.value(self._datatype).value
|
self._attr_native_value = self._tellcore_sensor.value(self._datatype).value
|
||||||
|
|
|
@ -146,14 +146,14 @@ class TelnetSwitch(SwitchEntity):
|
||||||
return None
|
return None
|
||||||
self._attr_is_on = rendered == "True"
|
self._attr_is_on = rendered == "True"
|
||||||
|
|
||||||
def turn_on(self, **kwargs) -> None:
|
def turn_on(self, **kwargs: Any) -> None:
|
||||||
"""Turn the device on."""
|
"""Turn the device on."""
|
||||||
self._telnet_command(self._command_on)
|
self._telnet_command(self._command_on)
|
||||||
if self.assumed_state:
|
if self.assumed_state:
|
||||||
self._attr_is_on = True
|
self._attr_is_on = True
|
||||||
self.schedule_update_ha_state()
|
self.schedule_update_ha_state()
|
||||||
|
|
||||||
def turn_off(self, **kwargs) -> None:
|
def turn_off(self, **kwargs: Any) -> None:
|
||||||
"""Turn the device off."""
|
"""Turn the device off."""
|
||||||
self._telnet_command(self._command_off)
|
self._telnet_command(self._command_off)
|
||||||
if self.assumed_state:
|
if self.assumed_state:
|
||||||
|
|
|
@ -91,7 +91,7 @@ class TemperSensor(SensorEntity):
|
||||||
# set calibration data
|
# set calibration data
|
||||||
self.temper_device.set_calibration_data(scale=self.scale, offset=self.offset)
|
self.temper_device.set_calibration_data(scale=self.scale, offset=self.offset)
|
||||||
|
|
||||||
def update(self):
|
def update(self) -> None:
|
||||||
"""Retrieve latest state."""
|
"""Retrieve latest state."""
|
||||||
try:
|
try:
|
||||||
sensor_value = self.temper_device.get_temperature("celsius")
|
sensor_value = self.temper_device.get_temperature("celsius")
|
||||||
|
|
|
@ -4,6 +4,7 @@ from __future__ import annotations
|
||||||
from concurrent import futures
|
from concurrent import futures
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
from pytfiac import Tfiac
|
from pytfiac import Tfiac
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
@ -94,7 +95,7 @@ class TfiacClimate(ClimateEntity):
|
||||||
"""Return if the device is available."""
|
"""Return if the device is available."""
|
||||||
return self._available
|
return self._available
|
||||||
|
|
||||||
async def async_update(self):
|
async def async_update(self) -> None:
|
||||||
"""Update status via socket polling."""
|
"""Update status via socket polling."""
|
||||||
try:
|
try:
|
||||||
await self._client.update()
|
await self._client.update()
|
||||||
|
@ -167,7 +168,7 @@ class TfiacClimate(ClimateEntity):
|
||||||
"""List of available swing modes."""
|
"""List of available swing modes."""
|
||||||
return SUPPORT_SWING
|
return SUPPORT_SWING
|
||||||
|
|
||||||
async def async_set_temperature(self, **kwargs):
|
async def async_set_temperature(self, **kwargs: Any) -> None:
|
||||||
"""Set new target temperature."""
|
"""Set new target temperature."""
|
||||||
if (temp := kwargs.get(ATTR_TEMPERATURE)) is not None:
|
if (temp := kwargs.get(ATTR_TEMPERATURE)) is not None:
|
||||||
await self._client.set_state(TARGET_TEMP, temp)
|
await self._client.set_state(TARGET_TEMP, temp)
|
||||||
|
@ -179,18 +180,18 @@ class TfiacClimate(ClimateEntity):
|
||||||
else:
|
else:
|
||||||
await self._client.set_state(OPERATION_MODE, HVAC_MAP[hvac_mode])
|
await self._client.set_state(OPERATION_MODE, HVAC_MAP[hvac_mode])
|
||||||
|
|
||||||
async def async_set_fan_mode(self, fan_mode):
|
async def async_set_fan_mode(self, fan_mode: str) -> None:
|
||||||
"""Set new fan mode."""
|
"""Set new fan mode."""
|
||||||
await self._client.set_state(FAN_MODE, fan_mode.capitalize())
|
await self._client.set_state(FAN_MODE, fan_mode.capitalize())
|
||||||
|
|
||||||
async def async_set_swing_mode(self, swing_mode):
|
async def async_set_swing_mode(self, swing_mode: str) -> None:
|
||||||
"""Set new swing mode."""
|
"""Set new swing mode."""
|
||||||
await self._client.set_swing(swing_mode.capitalize())
|
await self._client.set_swing(swing_mode.capitalize())
|
||||||
|
|
||||||
async def async_turn_on(self):
|
async def async_turn_on(self) -> None:
|
||||||
"""Turn device on."""
|
"""Turn device on."""
|
||||||
await self._client.set_state(OPERATION_MODE)
|
await self._client.set_state(OPERATION_MODE)
|
||||||
|
|
||||||
async def async_turn_off(self):
|
async def async_turn_off(self) -> None:
|
||||||
"""Turn device off."""
|
"""Turn device off."""
|
||||||
await self._client.set_state(ON_MODE, "off")
|
await self._client.set_state(ON_MODE, "off")
|
||||||
|
|
|
@ -127,7 +127,7 @@ class ThermoworksSmokeSensor(SensorEntity):
|
||||||
else:
|
else:
|
||||||
self._attr_native_unit_of_measurement = self.mgr.units(self.serial, PROBE_1)
|
self._attr_native_unit_of_measurement = self.mgr.units(self.serial, PROBE_1)
|
||||||
|
|
||||||
def update(self):
|
def update(self) -> None:
|
||||||
"""Get the monitored data from firebase."""
|
"""Get the monitored data from firebase."""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -109,7 +109,7 @@ class TtnDataSensor(SensorEntity):
|
||||||
ATTR_TIME: self._state["time"],
|
ATTR_TIME: self._state["time"],
|
||||||
}
|
}
|
||||||
|
|
||||||
async def async_update(self):
|
async def async_update(self) -> None:
|
||||||
"""Get the current state."""
|
"""Get the current state."""
|
||||||
await self._ttn_data_storage.async_update()
|
await self._ttn_data_storage.async_update()
|
||||||
self._state = self._ttn_data_storage.data
|
self._state = self._ttn_data_storage.data
|
||||||
|
|
|
@ -107,7 +107,7 @@ class ThinkingCleanerSensor(SensorEntity):
|
||||||
|
|
||||||
self._attr_name = f"{tc_object.name} {description.name}"
|
self._attr_name = f"{tc_object.name} {description.name}"
|
||||||
|
|
||||||
def update(self):
|
def update(self) -> None:
|
||||||
"""Update the sensor."""
|
"""Update the sensor."""
|
||||||
self._update_devices()
|
self._update_devices()
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ from __future__ import annotations
|
||||||
|
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import time
|
import time
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
from pythinkingcleaner import Discovery, ThinkingCleaner
|
from pythinkingcleaner import Discovery, ThinkingCleaner
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
@ -130,7 +131,7 @@ class ThinkingCleanerSwitch(SwitchEntity):
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def turn_on(self, **kwargs):
|
def turn_on(self, **kwargs: Any) -> None:
|
||||||
"""Turn the device on."""
|
"""Turn the device on."""
|
||||||
sensor_type = self.entity_description.key
|
sensor_type = self.entity_description.key
|
||||||
if sensor_type == "clean":
|
if sensor_type == "clean":
|
||||||
|
@ -141,13 +142,13 @@ class ThinkingCleanerSwitch(SwitchEntity):
|
||||||
elif sensor_type == "find":
|
elif sensor_type == "find":
|
||||||
self._tc_object.find_me()
|
self._tc_object.find_me()
|
||||||
|
|
||||||
def turn_off(self, **kwargs):
|
def turn_off(self, **kwargs: Any) -> None:
|
||||||
"""Turn the device off."""
|
"""Turn the device off."""
|
||||||
if self.entity_description.key == "clean":
|
if self.entity_description.key == "clean":
|
||||||
self.set_graceful_lock(False)
|
self.set_graceful_lock(False)
|
||||||
self._tc_object.stop_cleaning()
|
self._tc_object.stop_cleaning()
|
||||||
|
|
||||||
def update(self):
|
def update(self) -> None:
|
||||||
"""Update the switch state (Only for clean)."""
|
"""Update the switch state (Only for clean)."""
|
||||||
if self.entity_description.key == "clean" and not self.is_update_locked():
|
if self.entity_description.key == "clean" and not self.is_update_locked():
|
||||||
self._tc_object.update()
|
self._tc_object.update()
|
||||||
|
|
|
@ -350,7 +350,7 @@ class TibberSensorElPrice(TibberSensor):
|
||||||
|
|
||||||
self._device_name = self._home_name
|
self._device_name = self._home_name
|
||||||
|
|
||||||
async def async_update(self):
|
async def async_update(self) -> None:
|
||||||
"""Get the latest data and updates the states."""
|
"""Get the latest data and updates the states."""
|
||||||
now = dt_util.now()
|
now = dt_util.now()
|
||||||
if (
|
if (
|
||||||
|
@ -448,7 +448,7 @@ class TibberSensorRT(TibberSensor, CoordinatorEntity["TibberRtDataCoordinator"])
|
||||||
self._attr_native_unit_of_measurement = tibber_home.currency
|
self._attr_native_unit_of_measurement = tibber_home.currency
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def available(self):
|
def available(self) -> bool:
|
||||||
"""Return True if entity is available."""
|
"""Return True if entity is available."""
|
||||||
return self._tibber_home.rt_subscription_running
|
return self._tibber_home.rt_subscription_running
|
||||||
|
|
||||||
|
|
|
@ -119,7 +119,7 @@ class TMBSensor(SensorEntity):
|
||||||
}
|
}
|
||||||
|
|
||||||
@Throttle(MIN_TIME_BETWEEN_UPDATES)
|
@Throttle(MIN_TIME_BETWEEN_UPDATES)
|
||||||
def update(self):
|
def update(self) -> None:
|
||||||
"""Get the next bus information."""
|
"""Get the next bus information."""
|
||||||
try:
|
try:
|
||||||
self._state = self._ibus_client.get_stop_forecast(self._stop, self._line)
|
self._state = self._ibus_client.get_stop_forecast(self._stop, self._line)
|
||||||
|
|
|
@ -225,7 +225,7 @@ class TodSensor(BinarySensorEntity):
|
||||||
# Offset is already there
|
# Offset is already there
|
||||||
self._time_before += timedelta(days=1)
|
self._time_before += timedelta(days=1)
|
||||||
|
|
||||||
async def async_added_to_hass(self):
|
async def async_added_to_hass(self) -> None:
|
||||||
"""Call when entity about to be added to Home Assistant."""
|
"""Call when entity about to be added to Home Assistant."""
|
||||||
self._calculate_boundary_time()
|
self._calculate_boundary_time()
|
||||||
self._calculate_next_update()
|
self._calculate_next_update()
|
||||||
|
|
|
@ -308,7 +308,7 @@ class TodoistProjectEntity(CalendarEntity):
|
||||||
"""Return the name of the entity."""
|
"""Return the name of the entity."""
|
||||||
return self._name
|
return self._name
|
||||||
|
|
||||||
def update(self):
|
def update(self) -> None:
|
||||||
"""Update all Todoist Calendars."""
|
"""Update all Todoist Calendars."""
|
||||||
self.data.update()
|
self.data.update()
|
||||||
# Set Todoist-specific data that can't easily be grabbed
|
# Set Todoist-specific data that can't easily be grabbed
|
||||||
|
|
|
@ -103,7 +103,7 @@ class ToonThermostatDevice(ToonDisplayDeviceEntity, ClimateEntity):
|
||||||
return {"heating_type": self.coordinator.data.agreement.heating_type}
|
return {"heating_type": self.coordinator.data.agreement.heating_type}
|
||||||
|
|
||||||
@toon_exception_handler
|
@toon_exception_handler
|
||||||
async def async_set_temperature(self, **kwargs) -> None:
|
async def async_set_temperature(self, **kwargs: Any) -> None:
|
||||||
"""Change the setpoint of the thermostat."""
|
"""Change the setpoint of the thermostat."""
|
||||||
temperature = kwargs.get(ATTR_TEMPERATURE)
|
temperature = kwargs.get(ATTR_TEMPERATURE)
|
||||||
await self.coordinator.toon.set_current_setpoint(temperature)
|
await self.coordinator.toon.set_current_setpoint(temperature)
|
||||||
|
|
|
@ -49,7 +49,7 @@ class TotalConnectBinarySensor(BinarySensorEntity):
|
||||||
"""Return the name of the device."""
|
"""Return the name of the device."""
|
||||||
return self._name
|
return self._name
|
||||||
|
|
||||||
def update(self):
|
def update(self) -> None:
|
||||||
"""Return the state of the device."""
|
"""Return the state of the device."""
|
||||||
self._is_tampered = self._zone.is_tampered()
|
self._is_tampered = self._zone.is_tampered()
|
||||||
self._is_low_battery = self._zone.is_low_battery()
|
self._is_low_battery = self._zone.is_low_battery()
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
"""Platform for Roth Touchline floor heating controller."""
|
"""Platform for Roth Touchline floor heating controller."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from typing import NamedTuple
|
from typing import Any, NamedTuple
|
||||||
|
|
||||||
from pytouchline import PyTouchline
|
from pytouchline import PyTouchline
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
@ -75,7 +75,7 @@ class Touchline(ClimateEntity):
|
||||||
self._current_operation_mode = None
|
self._current_operation_mode = None
|
||||||
self._preset_mode = None
|
self._preset_mode = None
|
||||||
|
|
||||||
def update(self):
|
def update(self) -> None:
|
||||||
"""Update thermostat attributes."""
|
"""Update thermostat attributes."""
|
||||||
self.unit.update()
|
self.unit.update()
|
||||||
self._name = self.unit.get_name()
|
self._name = self.unit.get_name()
|
||||||
|
@ -120,7 +120,7 @@ class Touchline(ClimateEntity):
|
||||||
"""Set new target hvac mode."""
|
"""Set new target hvac mode."""
|
||||||
self._current_operation_mode = HVACMode.HEAT
|
self._current_operation_mode = HVACMode.HEAT
|
||||||
|
|
||||||
def set_temperature(self, **kwargs):
|
def set_temperature(self, **kwargs: Any) -> None:
|
||||||
"""Set new target temperature."""
|
"""Set new target temperature."""
|
||||||
if kwargs.get(ATTR_TEMPERATURE) is not None:
|
if kwargs.get(ATTR_TEMPERATURE) is not None:
|
||||||
self._target_temperature = kwargs.get(ATTR_TEMPERATURE)
|
self._target_temperature = kwargs.get(ATTR_TEMPERATURE)
|
||||||
|
|
|
@ -411,7 +411,7 @@ class TraccarEntity(TrackerEntity, RestoreEntity):
|
||||||
"""Return the source type, eg gps or router, of the device."""
|
"""Return the source type, eg gps or router, of the device."""
|
||||||
return SourceType.GPS
|
return SourceType.GPS
|
||||||
|
|
||||||
async def async_added_to_hass(self):
|
async def async_added_to_hass(self) -> None:
|
||||||
"""Register state update callback."""
|
"""Register state update callback."""
|
||||||
await super().async_added_to_hass()
|
await super().async_added_to_hass()
|
||||||
self._unsub_dispatcher = async_dispatcher_connect(
|
self._unsub_dispatcher = async_dispatcher_connect(
|
||||||
|
@ -445,7 +445,7 @@ class TraccarEntity(TrackerEntity, RestoreEntity):
|
||||||
}
|
}
|
||||||
self._battery = attr.get(ATTR_BATTERY)
|
self._battery = attr.get(ATTR_BATTERY)
|
||||||
|
|
||||||
async def async_will_remove_from_hass(self):
|
async def async_will_remove_from_hass(self) -> None:
|
||||||
"""Clean up after entity before removal."""
|
"""Clean up after entity before removal."""
|
||||||
await super().async_will_remove_from_hass()
|
await super().async_will_remove_from_hass()
|
||||||
self._unsub_dispatcher()
|
self._unsub_dispatcher()
|
||||||
|
|
|
@ -75,11 +75,11 @@ class TransmissionSensor(SensorEntity):
|
||||||
return self._state
|
return self._state
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def available(self):
|
def available(self) -> bool:
|
||||||
"""Could the device be accessed during the last update call."""
|
"""Could the device be accessed during the last update call."""
|
||||||
return self._tm_client.api.available
|
return self._tm_client.api.available
|
||||||
|
|
||||||
async def async_added_to_hass(self):
|
async def async_added_to_hass(self) -> None:
|
||||||
"""Handle entity which will be added."""
|
"""Handle entity which will be added."""
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
|
@ -102,7 +102,7 @@ class TransmissionSpeedSensor(TransmissionSensor):
|
||||||
"""Return the unit of measurement of this entity, if any."""
|
"""Return the unit of measurement of this entity, if any."""
|
||||||
return DATA_RATE_MEGABYTES_PER_SECOND
|
return DATA_RATE_MEGABYTES_PER_SECOND
|
||||||
|
|
||||||
def update(self):
|
def update(self) -> None:
|
||||||
"""Get the latest data from Transmission and updates the state."""
|
"""Get the latest data from Transmission and updates the state."""
|
||||||
if data := self._tm_client.api.data:
|
if data := self._tm_client.api.data:
|
||||||
mb_spd = (
|
mb_spd = (
|
||||||
|
@ -117,7 +117,7 @@ class TransmissionSpeedSensor(TransmissionSensor):
|
||||||
class TransmissionStatusSensor(TransmissionSensor):
|
class TransmissionStatusSensor(TransmissionSensor):
|
||||||
"""Representation of a Transmission status sensor."""
|
"""Representation of a Transmission status sensor."""
|
||||||
|
|
||||||
def update(self):
|
def update(self) -> None:
|
||||||
"""Get the latest data from Transmission and updates the state."""
|
"""Get the latest data from Transmission and updates the state."""
|
||||||
if data := self._tm_client.api.data:
|
if data := self._tm_client.api.data:
|
||||||
upload = data.uploadSpeed
|
upload = data.uploadSpeed
|
||||||
|
@ -163,7 +163,7 @@ class TransmissionTorrentsSensor(TransmissionSensor):
|
||||||
STATE_ATTR_TORRENT_INFO: info,
|
STATE_ATTR_TORRENT_INFO: info,
|
||||||
}
|
}
|
||||||
|
|
||||||
def update(self):
|
def update(self) -> None:
|
||||||
"""Get the latest data from Transmission and updates the state."""
|
"""Get the latest data from Transmission and updates the state."""
|
||||||
torrents = _filter_torrents(
|
torrents = _filter_torrents(
|
||||||
self._tm_client.api.torrents, statuses=self.SUBTYPE_MODES[self._sub_type]
|
self._tm_client.api.torrents, statuses=self.SUBTYPE_MODES[self._sub_type]
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
"""Support for setting the Transmission BitTorrent client Turtle Mode."""
|
"""Support for setting the Transmission BitTorrent client Turtle Mode."""
|
||||||
import logging
|
import logging
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
from homeassistant.components.switch import SwitchEntity
|
from homeassistant.components.switch import SwitchEntity
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
|
@ -61,11 +62,11 @@ class TransmissionSwitch(SwitchEntity):
|
||||||
return self._state == STATE_ON
|
return self._state == STATE_ON
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def available(self):
|
def available(self) -> bool:
|
||||||
"""Could the device be accessed during the last update call."""
|
"""Could the device be accessed during the last update call."""
|
||||||
return self._tm_client.api.available
|
return self._tm_client.api.available
|
||||||
|
|
||||||
def turn_on(self, **kwargs):
|
def turn_on(self, **kwargs: Any) -> None:
|
||||||
"""Turn the device on."""
|
"""Turn the device on."""
|
||||||
if self.type == "on_off":
|
if self.type == "on_off":
|
||||||
_LOGGING.debug("Starting all torrents")
|
_LOGGING.debug("Starting all torrents")
|
||||||
|
@ -75,7 +76,7 @@ class TransmissionSwitch(SwitchEntity):
|
||||||
self._tm_client.api.set_alt_speed_enabled(True)
|
self._tm_client.api.set_alt_speed_enabled(True)
|
||||||
self._tm_client.api.update()
|
self._tm_client.api.update()
|
||||||
|
|
||||||
def turn_off(self, **kwargs):
|
def turn_off(self, **kwargs: Any) -> None:
|
||||||
"""Turn the device off."""
|
"""Turn the device off."""
|
||||||
if self.type == "on_off":
|
if self.type == "on_off":
|
||||||
_LOGGING.debug("Stopping all torrents")
|
_LOGGING.debug("Stopping all torrents")
|
||||||
|
@ -85,7 +86,7 @@ class TransmissionSwitch(SwitchEntity):
|
||||||
self._tm_client.api.set_alt_speed_enabled(False)
|
self._tm_client.api.set_alt_speed_enabled(False)
|
||||||
self._tm_client.api.update()
|
self._tm_client.api.update()
|
||||||
|
|
||||||
async def async_added_to_hass(self):
|
async def async_added_to_hass(self) -> None:
|
||||||
"""Handle entity which will be added."""
|
"""Handle entity which will be added."""
|
||||||
self.unsub_update = async_dispatcher_connect(
|
self.unsub_update = async_dispatcher_connect(
|
||||||
self.hass,
|
self.hass,
|
||||||
|
@ -103,7 +104,7 @@ class TransmissionSwitch(SwitchEntity):
|
||||||
self.unsub_update()
|
self.unsub_update()
|
||||||
self.unsub_update = None
|
self.unsub_update = None
|
||||||
|
|
||||||
def update(self):
|
def update(self) -> None:
|
||||||
"""Get the latest data from Transmission and updates the state."""
|
"""Get the latest data from Transmission and updates the state."""
|
||||||
active = None
|
active = None
|
||||||
if self.type == "on_off":
|
if self.type == "on_off":
|
||||||
|
|
|
@ -120,7 +120,7 @@ class TransportNSWSensor(SensorEntity):
|
||||||
"""Icon to use in the frontend, if any."""
|
"""Icon to use in the frontend, if any."""
|
||||||
return self._icon
|
return self._icon
|
||||||
|
|
||||||
def update(self):
|
def update(self) -> None:
|
||||||
"""Get the latest data from Transport NSW and update the states."""
|
"""Get the latest data from Transport NSW and update the states."""
|
||||||
self.data.update()
|
self.data.update()
|
||||||
self._times = self.data.info
|
self._times = self.data.info
|
||||||
|
|
|
@ -174,7 +174,7 @@ class TravisCISensor(SensorEntity):
|
||||||
|
|
||||||
return attrs
|
return attrs
|
||||||
|
|
||||||
def update(self):
|
def update(self) -> None:
|
||||||
"""Get the latest data and updates the states."""
|
"""Get the latest data and updates the states."""
|
||||||
_LOGGER.debug("Updating sensor %s", self.name)
|
_LOGGER.debug("Updating sensor %s", self.name)
|
||||||
|
|
||||||
|
|
|
@ -169,7 +169,7 @@ class SensorTrend(BinarySensorEntity):
|
||||||
ATTR_SAMPLE_DURATION: self._sample_duration,
|
ATTR_SAMPLE_DURATION: self._sample_duration,
|
||||||
}
|
}
|
||||||
|
|
||||||
async def async_added_to_hass(self):
|
async def async_added_to_hass(self) -> None:
|
||||||
"""Complete device setup after being added to hass."""
|
"""Complete device setup after being added to hass."""
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
|
@ -195,7 +195,7 @@ class SensorTrend(BinarySensorEntity):
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_update(self):
|
async def async_update(self) -> None:
|
||||||
"""Get the latest data and update the states."""
|
"""Get the latest data and update the states."""
|
||||||
# Remove outdated samples
|
# Remove outdated samples
|
||||||
if self._sample_duration > 0:
|
if self._sample_duration > 0:
|
||||||
|
|
Loading…
Add table
Reference in a new issue