Improve entity type hints [z] (#77890)
parent
23052dc7b5
commit
3a0eae3986
|
@ -117,7 +117,7 @@ class ZabbixTriggerCountSensor(SensorEntity):
|
|||
output="extend", only_true=1, monitored=1, filter={"value": 1}
|
||||
)
|
||||
|
||||
def update(self):
|
||||
def update(self) -> None:
|
||||
"""Update the sensor."""
|
||||
_LOGGER.debug("Updating ZabbixTriggerCountSensor: %s", str(self._name))
|
||||
triggers = self._call_zabbix_api()
|
||||
|
|
|
@ -264,7 +264,7 @@ class ZamgSensor(SensorEntity):
|
|||
ATTR_UPDATED: self.probe.last_update.isoformat(),
|
||||
}
|
||||
|
||||
def update(self):
|
||||
def update(self) -> None:
|
||||
"""Delegate update to probe."""
|
||||
self.probe.update()
|
||||
|
||||
|
|
|
@ -139,6 +139,6 @@ class ZamgWeather(WeatherEntity):
|
|||
"""Return the wind bearing."""
|
||||
return self.zamg_data.get_data(ATTR_WEATHER_WIND_BEARING)
|
||||
|
||||
def update(self):
|
||||
def update(self) -> None:
|
||||
"""Update current conditions."""
|
||||
self.zamg_data.update()
|
||||
|
|
|
@ -69,7 +69,7 @@ class BinarySensor(ZhaEntity, BinarySensorEntity):
|
|||
super().__init__(unique_id, zha_device, channels, **kwargs)
|
||||
self._channel = channels[0]
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
async def async_added_to_hass(self) -> None:
|
||||
"""Run when about to be added to hass."""
|
||||
await super().async_added_to_hass()
|
||||
self.async_accept_signal(
|
||||
|
@ -97,7 +97,7 @@ class BinarySensor(ZhaEntity, BinarySensorEntity):
|
|||
self._state = bool(value)
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_update(self):
|
||||
async def async_update(self) -> None:
|
||||
"""Attempt to retrieve on off state from the binary sensor."""
|
||||
await super().async_update()
|
||||
attribute = getattr(self._channel, "value_attribute", "on_off")
|
||||
|
@ -167,7 +167,7 @@ class IASZone(BinarySensor):
|
|||
"""Return device class from component DEVICE_CLASSES."""
|
||||
return CLASS_MAPPING.get(self._channel.cluster.get("zone_type"))
|
||||
|
||||
async def async_update(self):
|
||||
async def async_update(self) -> None:
|
||||
"""Attempt to retrieve on off state from the binary sensor."""
|
||||
await super().async_update()
|
||||
value = await self._channel.get_attribute_value("zone_status")
|
||||
|
|
|
@ -9,6 +9,7 @@ from __future__ import annotations
|
|||
from datetime import datetime, timedelta
|
||||
import functools
|
||||
from random import randint
|
||||
from typing import Any
|
||||
|
||||
from zigpy.zcl.clusters.hvac import Fan as F, Thermostat as T
|
||||
|
||||
|
@ -276,7 +277,7 @@ class Thermostat(ZhaEntity, ClimateEntity):
|
|||
return self._presets
|
||||
|
||||
@property
|
||||
def supported_features(self):
|
||||
def supported_features(self) -> int:
|
||||
"""Return the list of supported features."""
|
||||
features = self._supported_flags
|
||||
if HVACMode.HEAT_COOL in self.hvac_modes:
|
||||
|
@ -358,7 +359,7 @@ class Thermostat(ZhaEntity, ClimateEntity):
|
|||
return self.DEFAULT_MIN_TEMP
|
||||
return round(min(temps) / ZCL_TEMP, 1)
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
async def async_added_to_hass(self) -> None:
|
||||
"""Run when about to be added to hass."""
|
||||
await super().async_added_to_hass()
|
||||
self.async_accept_signal(
|
||||
|
@ -427,7 +428,7 @@ class Thermostat(ZhaEntity, ClimateEntity):
|
|||
self._preset = preset_mode
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_set_temperature(self, **kwargs):
|
||||
async def async_set_temperature(self, **kwargs: Any) -> None:
|
||||
"""Set new target temperature."""
|
||||
low_temp = kwargs.get(ATTR_TARGET_TEMP_LOW)
|
||||
high_temp = kwargs.get(ATTR_TARGET_TEMP_HIGH)
|
||||
|
@ -533,7 +534,7 @@ class SinopeTechnologiesThermostat(Thermostat):
|
|||
)
|
||||
)
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
async def async_added_to_hass(self) -> None:
|
||||
"""Run when about to be added to Hass."""
|
||||
await super().async_added_to_hass()
|
||||
async_track_time_interval(
|
||||
|
|
|
@ -59,7 +59,7 @@ class ZHADeviceScannerEntity(ScannerEntity, ZhaEntity):
|
|||
self._keepalive_interval = 60
|
||||
self._battery_level = None
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
async def async_added_to_hass(self) -> None:
|
||||
"""Run when about to be added to hass."""
|
||||
await super().async_added_to_hass()
|
||||
if self._battery_channel:
|
||||
|
@ -69,7 +69,7 @@ class ZHADeviceScannerEntity(ScannerEntity, ZhaEntity):
|
|||
self.async_battery_percentage_remaining_updated,
|
||||
)
|
||||
|
||||
async def async_update(self):
|
||||
async def async_update(self) -> None:
|
||||
"""Handle polling."""
|
||||
if self.zha_device.last_seen is None:
|
||||
self._connected = False
|
||||
|
|
|
@ -260,7 +260,7 @@ class IkeaFan(BaseFan, ZhaEntity):
|
|||
super().__init__(unique_id, zha_device, channels, **kwargs)
|
||||
self._fan_channel = self.cluster_channels.get("ikea_airpurifier")
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
async def async_added_to_hass(self) -> None:
|
||||
"""Run when about to be added to hass."""
|
||||
await super().async_added_to_hass()
|
||||
self.async_accept_signal(
|
||||
|
@ -317,7 +317,7 @@ class IkeaFan(BaseFan, ZhaEntity):
|
|||
]
|
||||
await self.async_set_percentage(percentage)
|
||||
|
||||
async def async_turn_off(self, **kwargs) -> None:
|
||||
async def async_turn_off(self, **kwargs: Any) -> None:
|
||||
"""Turn the entity off."""
|
||||
await self.async_set_percentage(0)
|
||||
|
||||
|
|
|
@ -168,7 +168,7 @@ class BaseLight(LogMixin, light.LightEntity):
|
|||
self._attr_brightness = value
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_turn_on(self, **kwargs):
|
||||
async def async_turn_on(self, **kwargs: Any) -> None:
|
||||
"""Turn the entity on."""
|
||||
transition = kwargs.get(light.ATTR_TRANSITION)
|
||||
duration = (
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
import voluptuous as vol
|
||||
from zhong_hong_hvac.hub import ZhongHongGateway
|
||||
|
@ -141,7 +142,7 @@ class ZhongHongClimate(ClimateEntity):
|
|||
self._current_fan_mode = None
|
||||
self.is_initialized = False
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
async def async_added_to_hass(self) -> None:
|
||||
"""Register callbacks."""
|
||||
self._device.register_update_callback(self._after_update)
|
||||
self.is_initialized = True
|
||||
|
@ -219,15 +220,15 @@ class ZhongHongClimate(ClimateEntity):
|
|||
"""Return the maximum temperature."""
|
||||
return self._device.max_temp
|
||||
|
||||
def turn_on(self):
|
||||
def turn_on(self) -> None:
|
||||
"""Turn on ac."""
|
||||
return self._device.turn_on()
|
||||
|
||||
def turn_off(self):
|
||||
def turn_off(self) -> None:
|
||||
"""Turn off ac."""
|
||||
return self._device.turn_off()
|
||||
|
||||
def set_temperature(self, **kwargs):
|
||||
def set_temperature(self, **kwargs: Any) -> None:
|
||||
"""Set new target temperature."""
|
||||
if (temperature := kwargs.get(ATTR_TEMPERATURE)) is not None:
|
||||
self._device.set_temperature(temperature)
|
||||
|
@ -247,6 +248,6 @@ class ZhongHongClimate(ClimateEntity):
|
|||
|
||||
self._device.set_operation_mode(hvac_mode.upper())
|
||||
|
||||
def set_fan_mode(self, fan_mode):
|
||||
def set_fan_mode(self, fan_mode: str) -> None:
|
||||
"""Set new target fan mode."""
|
||||
self._device.set_fan_mode(fan_mode)
|
||||
|
|
|
@ -107,7 +107,7 @@ class ZiggoMediaboxXLDevice(MediaPlayerEntity):
|
|||
self._available = available
|
||||
self._state = None
|
||||
|
||||
def update(self):
|
||||
def update(self) -> None:
|
||||
"""Retrieve the state of the device."""
|
||||
try:
|
||||
if self._mediabox.test_connection():
|
||||
|
@ -153,25 +153,25 @@ class ZiggoMediaboxXLDevice(MediaPlayerEntity):
|
|||
for c in sorted(self._mediabox.channels().keys())
|
||||
]
|
||||
|
||||
def turn_on(self):
|
||||
def turn_on(self) -> None:
|
||||
"""Turn the media player on."""
|
||||
self.send_keys(["POWER"])
|
||||
|
||||
def turn_off(self):
|
||||
def turn_off(self) -> None:
|
||||
"""Turn off media player."""
|
||||
self.send_keys(["POWER"])
|
||||
|
||||
def media_play(self):
|
||||
def media_play(self) -> None:
|
||||
"""Send play command."""
|
||||
self.send_keys(["PLAY"])
|
||||
self._state = STATE_PLAYING
|
||||
|
||||
def media_pause(self):
|
||||
def media_pause(self) -> None:
|
||||
"""Send pause command."""
|
||||
self.send_keys(["PAUSE"])
|
||||
self._state = STATE_PAUSED
|
||||
|
||||
def media_play_pause(self):
|
||||
def media_play_pause(self) -> None:
|
||||
"""Simulate play pause media player."""
|
||||
self.send_keys(["PAUSE"])
|
||||
if self._state == STATE_PAUSED:
|
||||
|
@ -179,12 +179,12 @@ class ZiggoMediaboxXLDevice(MediaPlayerEntity):
|
|||
else:
|
||||
self._state = STATE_PAUSED
|
||||
|
||||
def media_next_track(self):
|
||||
def media_next_track(self) -> None:
|
||||
"""Channel up."""
|
||||
self.send_keys(["CHAN_UP"])
|
||||
self._state = STATE_PLAYING
|
||||
|
||||
def media_previous_track(self):
|
||||
def media_previous_track(self) -> None:
|
||||
"""Channel down."""
|
||||
self.send_keys(["CHAN_DOWN"])
|
||||
self._state = STATE_PLAYING
|
||||
|
|
|
@ -49,6 +49,6 @@ class ZMAvailabilitySensor(BinarySensorEntity):
|
|||
"""Return the class of this device, from component DEVICE_CLASSES."""
|
||||
return BinarySensorDeviceClass.CONNECTIVITY
|
||||
|
||||
def update(self):
|
||||
def update(self) -> None:
|
||||
"""Update the state of this sensor (availability of ZoneMinder)."""
|
||||
self._state = self._client.is_available
|
||||
|
|
|
@ -50,7 +50,7 @@ class ZoneMinderCamera(MjpegCamera):
|
|||
self._is_available = None
|
||||
self._monitor = monitor
|
||||
|
||||
def update(self):
|
||||
def update(self) -> None:
|
||||
"""Update our recording state from the ZM API."""
|
||||
_LOGGER.debug("Updating camera state for monitor %i", self._monitor.id)
|
||||
self._is_recording = self._monitor.is_recording
|
||||
|
|
|
@ -116,7 +116,7 @@ class ZMSensorMonitors(SensorEntity):
|
|||
"""Return True if Monitor is available."""
|
||||
return self._is_available
|
||||
|
||||
def update(self):
|
||||
def update(self) -> None:
|
||||
"""Update the sensor."""
|
||||
if not (state := self._monitor.function):
|
||||
self._state = None
|
||||
|
@ -143,7 +143,7 @@ class ZMSensorEvents(SensorEntity):
|
|||
"""Return the name of the sensor."""
|
||||
return f"{self._monitor.name} {self.time_period.title}"
|
||||
|
||||
def update(self):
|
||||
def update(self) -> None:
|
||||
"""Update the sensor."""
|
||||
self._attr_native_value = self._monitor.get_events(
|
||||
self.time_period, self._include_archived
|
||||
|
@ -174,7 +174,7 @@ class ZMSensorRunState(SensorEntity):
|
|||
"""Return True if ZoneMinder is available."""
|
||||
return self._is_available
|
||||
|
||||
def update(self):
|
||||
def update(self) -> None:
|
||||
"""Update the sensor."""
|
||||
self._state = self._client.get_active_state()
|
||||
self._is_available = self._client.is_available
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
import voluptuous as vol
|
||||
from zoneminder.monitor import MonitorState
|
||||
|
@ -64,7 +65,7 @@ class ZMSwitchMonitors(SwitchEntity):
|
|||
"""Return the name of the switch."""
|
||||
return f"{self._monitor.name} State"
|
||||
|
||||
def update(self):
|
||||
def update(self) -> None:
|
||||
"""Update the switch value."""
|
||||
self._state = self._monitor.function == self._on_state
|
||||
|
||||
|
@ -73,10 +74,10 @@ class ZMSwitchMonitors(SwitchEntity):
|
|||
"""Return True if entity is on."""
|
||||
return self._state
|
||||
|
||||
def turn_on(self, **kwargs):
|
||||
def turn_on(self, **kwargs: Any) -> None:
|
||||
"""Turn the entity on."""
|
||||
self._monitor.function = self._on_state
|
||||
|
||||
def turn_off(self, **kwargs):
|
||||
def turn_off(self, **kwargs: Any) -> None:
|
||||
"""Turn the entity off."""
|
||||
self._monitor.function = self._off_state
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
"""Representation of a thermostat."""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from zwave_me_ws import ZWaveMeData
|
||||
|
||||
from homeassistant.components.climate import ClimateEntity
|
||||
|
@ -52,7 +54,7 @@ class ZWaveMeClimate(ZWaveMeEntity, ClimateEntity):
|
|||
_attr_hvac_modes = [HVACMode.HEAT]
|
||||
_attr_supported_features = ClimateEntityFeature.TARGET_TEMPERATURE
|
||||
|
||||
def set_temperature(self, **kwargs) -> None:
|
||||
def set_temperature(self, **kwargs: Any) -> None:
|
||||
"""Set new target temperature."""
|
||||
if (temperature := kwargs.get(ATTR_TEMPERATURE)) is None:
|
||||
return
|
||||
|
|
Loading…
Reference in New Issue