mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
Improve entity type hints [e] (#77041)
This commit is contained in:
parent
21cd2f5db7
commit
3a3f41f3df
@ -184,7 +184,7 @@ class EBoxSensor(SensorEntity):
|
||||
self._attr_name = f"{name} {description.name}"
|
||||
self.ebox_data = ebox_data
|
||||
|
||||
async def async_update(self):
|
||||
async def async_update(self) -> None:
|
||||
"""Get the latest data from EBox and update the state."""
|
||||
await self.ebox_data.async_update()
|
||||
if self.entity_description.key in self.ebox_data.data:
|
||||
|
@ -111,7 +111,7 @@ class EbusdSensor(SensorEntity):
|
||||
return self._unit_of_measurement
|
||||
|
||||
@Throttle(MIN_TIME_BETWEEN_UPDATES)
|
||||
def update(self):
|
||||
def update(self) -> None:
|
||||
"""Fetch new state data for the sensor."""
|
||||
try:
|
||||
self.data.update(self._name, self._type)
|
||||
|
@ -39,7 +39,7 @@ class EcoalTempSensor(SensorEntity):
|
||||
self._attr_name = name
|
||||
self._status_attr = status_attr
|
||||
|
||||
def update(self):
|
||||
def update(self) -> None:
|
||||
"""Fetch new state data for the sensor.
|
||||
|
||||
This is the only method that should fetch new data for Home Assistant.
|
||||
|
@ -1,6 +1,8 @@
|
||||
"""Allows to configuration ecoal (esterownik.pl) pumps as switches."""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from homeassistant.components.switch import SwitchEntity
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
@ -45,7 +47,7 @@ class EcoalSwitch(SwitchEntity):
|
||||
# status.<attr>
|
||||
self._contr_set_fun = getattr(self._ecoal_contr, f"set_{state_attr}")
|
||||
|
||||
def update(self):
|
||||
def update(self) -> None:
|
||||
"""Fetch new state data for the sensor.
|
||||
|
||||
This is the only method that should fetch new data for Home Assistant.
|
||||
@ -60,12 +62,12 @@ class EcoalSwitch(SwitchEntity):
|
||||
"""
|
||||
self._ecoal_contr.status = None
|
||||
|
||||
def turn_on(self, **kwargs) -> None:
|
||||
def turn_on(self, **kwargs: Any) -> None:
|
||||
"""Turn the device on."""
|
||||
self._contr_set_fun(1)
|
||||
self.invalidate_ecoal_cache()
|
||||
|
||||
def turn_off(self, **kwargs) -> None:
|
||||
def turn_off(self, **kwargs: Any) -> None:
|
||||
"""Turn the device off."""
|
||||
self._contr_set_fun(0)
|
||||
self.invalidate_ecoal_cache()
|
||||
|
@ -91,7 +91,7 @@ class EcobeeBinarySensor(BinarySensorEntity):
|
||||
return None
|
||||
|
||||
@property
|
||||
def available(self):
|
||||
def available(self) -> bool:
|
||||
"""Return true if device is available."""
|
||||
thermostat = self.data.ecobee.get_thermostat(self.index)
|
||||
return thermostat["runtime"]["connected"]
|
||||
@ -106,7 +106,7 @@ class EcobeeBinarySensor(BinarySensorEntity):
|
||||
"""Return the class of this sensor, from DEVICE_CLASSES."""
|
||||
return BinarySensorDeviceClass.OCCUPANCY
|
||||
|
||||
async def async_update(self):
|
||||
async def async_update(self) -> None:
|
||||
"""Get the latest state of the sensor."""
|
||||
await self.data.update()
|
||||
for sensor in self.data.ecobee.get_remote_sensors(self.index):
|
||||
|
@ -2,6 +2,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import collections
|
||||
from typing import Any
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
@ -330,7 +331,7 @@ class Thermostat(ClimateEntity):
|
||||
self._fan_modes = [FAN_AUTO, FAN_ON]
|
||||
self.update_without_throttle = False
|
||||
|
||||
async def async_update(self):
|
||||
async def async_update(self) -> None:
|
||||
"""Get the latest state from the thermostat."""
|
||||
if self.update_without_throttle:
|
||||
await self.data.update(no_throttle=True)
|
||||
@ -342,12 +343,12 @@ class Thermostat(ClimateEntity):
|
||||
self._last_active_hvac_mode = self.hvac_mode
|
||||
|
||||
@property
|
||||
def available(self):
|
||||
def available(self) -> bool:
|
||||
"""Return if device is available."""
|
||||
return self.thermostat["runtime"]["connected"]
|
||||
|
||||
@property
|
||||
def supported_features(self):
|
||||
def supported_features(self) -> int:
|
||||
"""Return the list of supported features."""
|
||||
if self.has_humidifier_control:
|
||||
return SUPPORT_FLAGS | ClimateEntityFeature.TARGET_HUMIDITY
|
||||
@ -563,7 +564,7 @@ class Thermostat(ClimateEntity):
|
||||
if self.is_aux_heat:
|
||||
_LOGGER.warning("# Changing aux heat is not supported")
|
||||
|
||||
def set_preset_mode(self, preset_mode):
|
||||
def set_preset_mode(self, preset_mode: str) -> None:
|
||||
"""Activate a preset."""
|
||||
if preset_mode == self.preset_mode:
|
||||
return
|
||||
@ -653,7 +654,7 @@ class Thermostat(ClimateEntity):
|
||||
|
||||
self.update_without_throttle = True
|
||||
|
||||
def set_fan_mode(self, fan_mode):
|
||||
def set_fan_mode(self, fan_mode: str) -> None:
|
||||
"""Set the fan mode. Valid values are "on" or "auto"."""
|
||||
if fan_mode.lower() not in (FAN_ON, FAN_AUTO):
|
||||
error = "Invalid fan_mode value: Valid values are 'on' or 'auto'"
|
||||
@ -689,7 +690,7 @@ class Thermostat(ClimateEntity):
|
||||
cool_temp = temp + delta
|
||||
self.set_auto_temp_hold(heat_temp, cool_temp)
|
||||
|
||||
def set_temperature(self, **kwargs):
|
||||
def 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)
|
||||
@ -704,7 +705,7 @@ class Thermostat(ClimateEntity):
|
||||
else:
|
||||
_LOGGER.error("Missing valid arguments for set_temperature in %s", kwargs)
|
||||
|
||||
def set_humidity(self, humidity):
|
||||
def set_humidity(self, humidity: int) -> None:
|
||||
"""Set the humidity level."""
|
||||
if humidity not in range(0, 101):
|
||||
raise ValueError(
|
||||
@ -714,7 +715,7 @@ class Thermostat(ClimateEntity):
|
||||
self.data.ecobee.set_humidity(self.thermostat_index, int(humidity))
|
||||
self.update_without_throttle = True
|
||||
|
||||
def set_hvac_mode(self, hvac_mode):
|
||||
def set_hvac_mode(self, hvac_mode: HVACMode) -> None:
|
||||
"""Set HVAC mode (auto, auxHeatOnly, cool, heat, off)."""
|
||||
ecobee_value = next(
|
||||
(k for k, v in ECOBEE_HVAC_TO_HASS.items() if v == hvac_mode), None
|
||||
@ -821,7 +822,7 @@ class Thermostat(ClimateEntity):
|
||||
)
|
||||
self.data.ecobee.delete_vacation(self.thermostat_index, vacation_name)
|
||||
|
||||
def turn_on(self):
|
||||
def turn_on(self) -> None:
|
||||
"""Set the thermostat to the last active HVAC mode."""
|
||||
_LOGGER.debug(
|
||||
"Turning on ecobee thermostat %s in %s mode",
|
||||
|
@ -105,6 +105,8 @@ async def async_setup_entry(
|
||||
class EcobeeSensor(SensorEntity):
|
||||
"""Representation of an Ecobee sensor."""
|
||||
|
||||
entity_description: EcobeeSensorEntityDescription
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
data,
|
||||
@ -163,7 +165,7 @@ class EcobeeSensor(SensorEntity):
|
||||
return None
|
||||
|
||||
@property
|
||||
def available(self):
|
||||
def available(self) -> bool:
|
||||
"""Return true if device is available."""
|
||||
thermostat = self.data.ecobee.get_thermostat(self.index)
|
||||
return thermostat["runtime"]["connected"]
|
||||
@ -183,7 +185,7 @@ class EcobeeSensor(SensorEntity):
|
||||
|
||||
return self._state
|
||||
|
||||
async def async_update(self):
|
||||
async def async_update(self) -> None:
|
||||
"""Get the latest state of the sensor."""
|
||||
await self.data.update()
|
||||
for sensor in self.data.ecobee.get_remote_sensors(self.index):
|
||||
|
@ -188,7 +188,7 @@ class EcobeeWeather(WeatherEntity):
|
||||
return forecasts
|
||||
return None
|
||||
|
||||
async def async_update(self):
|
||||
async def async_update(self) -> None:
|
||||
"""Get the latest weather data."""
|
||||
await self.data.update()
|
||||
thermostat = self.data.ecobee.get_thermostat(self._index)
|
||||
|
@ -1,4 +1,6 @@
|
||||
"""Support for Rheem EcoNet thermostats."""
|
||||
from typing import Any
|
||||
|
||||
from pyeconet.equipment import EquipmentType
|
||||
from pyeconet.equipment.thermostat import ThermostatFanMode, ThermostatOperationMode
|
||||
|
||||
@ -79,7 +81,7 @@ class EcoNetThermostat(EcoNetEntity, ClimateEntity):
|
||||
self.op_list.append(ha_mode)
|
||||
|
||||
@property
|
||||
def supported_features(self):
|
||||
def supported_features(self) -> int:
|
||||
"""Return the list of supported features."""
|
||||
if self._econet.supports_humidifier:
|
||||
return SUPPORT_FLAGS_THERMOSTAT | ClimateEntityFeature.TARGET_HUMIDITY
|
||||
@ -125,7 +127,7 @@ class EcoNetThermostat(EcoNetEntity, ClimateEntity):
|
||||
return self._econet.cool_set_point
|
||||
return None
|
||||
|
||||
def set_temperature(self, **kwargs):
|
||||
def set_temperature(self, **kwargs: Any) -> None:
|
||||
"""Set new target temperature."""
|
||||
target_temp = kwargs.get(ATTR_TEMPERATURE)
|
||||
target_temp_low = kwargs.get(ATTR_TARGET_TEMP_LOW)
|
||||
@ -161,14 +163,14 @@ class EcoNetThermostat(EcoNetEntity, ClimateEntity):
|
||||
|
||||
return _current_op
|
||||
|
||||
def set_hvac_mode(self, hvac_mode):
|
||||
def set_hvac_mode(self, hvac_mode: HVACMode) -> None:
|
||||
"""Set new target hvac mode."""
|
||||
hvac_mode_to_set = HA_STATE_TO_ECONET.get(hvac_mode)
|
||||
if hvac_mode_to_set is None:
|
||||
raise ValueError(f"{hvac_mode} is not a valid mode.")
|
||||
self._econet.set_mode(hvac_mode_to_set)
|
||||
|
||||
def set_humidity(self, humidity: int):
|
||||
def set_humidity(self, humidity: int) -> None:
|
||||
"""Set new target humidity."""
|
||||
self._econet.set_dehumidifier_set_point(humidity)
|
||||
|
||||
@ -201,15 +203,15 @@ class EcoNetThermostat(EcoNetEntity, ClimateEntity):
|
||||
fan_list.append(ECONET_FAN_STATE_TO_HA[mode])
|
||||
return fan_list
|
||||
|
||||
def set_fan_mode(self, fan_mode):
|
||||
def set_fan_mode(self, fan_mode: str) -> None:
|
||||
"""Set the fan mode."""
|
||||
self._econet.set_fan_mode(HA_FAN_STATE_TO_ECONET[fan_mode])
|
||||
|
||||
def turn_aux_heat_on(self):
|
||||
def turn_aux_heat_on(self) -> None:
|
||||
"""Turn auxiliary heater on."""
|
||||
self._econet.set_mode(ThermostatOperationMode.EMERGENCY_HEAT)
|
||||
|
||||
def turn_aux_heat_off(self):
|
||||
def turn_aux_heat_off(self) -> None:
|
||||
"""Turn auxiliary heater off."""
|
||||
self._econet.set_mode(ThermostatOperationMode.HEATING)
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
"""Support for Rheem EcoNet water heaters."""
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
from pyeconet.equipment import EquipmentType
|
||||
from pyeconet.equipment.water_heater import WaterHeaterOperationMode
|
||||
@ -118,14 +119,14 @@ class EcoNetWaterHeater(EcoNetEntity, WaterHeaterEntity):
|
||||
)
|
||||
return WaterHeaterEntityFeature.TARGET_TEMPERATURE
|
||||
|
||||
def set_temperature(self, **kwargs):
|
||||
def set_temperature(self, **kwargs: Any) -> None:
|
||||
"""Set new target temperature."""
|
||||
if (target_temp := kwargs.get(ATTR_TEMPERATURE)) is not None:
|
||||
self.water_heater.set_set_point(target_temp)
|
||||
else:
|
||||
_LOGGER.error("A target temperature must be provided")
|
||||
|
||||
def set_operation_mode(self, operation_mode):
|
||||
def set_operation_mode(self, operation_mode: str) -> None:
|
||||
"""Set operation mode."""
|
||||
op_mode_to_set = HA_STATE_TO_ECONET.get(operation_mode)
|
||||
if op_mode_to_set is not None:
|
||||
@ -156,17 +157,17 @@ class EcoNetWaterHeater(EcoNetEntity, WaterHeaterEntity):
|
||||
"""
|
||||
return self._poll
|
||||
|
||||
async def async_update(self):
|
||||
async def async_update(self) -> None:
|
||||
"""Get the latest energy usage."""
|
||||
await self.water_heater.get_energy_usage()
|
||||
await self.water_heater.get_water_usage()
|
||||
self.async_write_ha_state()
|
||||
self._poll = False
|
||||
|
||||
def turn_away_mode_on(self):
|
||||
def turn_away_mode_on(self) -> None:
|
||||
"""Turn away mode on."""
|
||||
self.water_heater.set_away_mode(True)
|
||||
|
||||
def turn_away_mode_off(self):
|
||||
def turn_away_mode_off(self) -> None:
|
||||
"""Turn away mode off."""
|
||||
self.water_heater.set_away_mode(False)
|
||||
|
@ -2,6 +2,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
import sucks
|
||||
|
||||
@ -107,7 +108,7 @@ class EcovacsVacuum(VacuumEntity):
|
||||
"""Return the status of the vacuum cleaner."""
|
||||
return self.device.vacuum_status
|
||||
|
||||
def return_to_base(self, **kwargs):
|
||||
def return_to_base(self, **kwargs: Any) -> None:
|
||||
"""Set the vacuum cleaner to return to the dock."""
|
||||
|
||||
self.device.run(sucks.Charge())
|
||||
@ -132,37 +133,42 @@ class EcovacsVacuum(VacuumEntity):
|
||||
"""Return the fan speed of the vacuum cleaner."""
|
||||
return self.device.fan_speed
|
||||
|
||||
def turn_on(self, **kwargs):
|
||||
def turn_on(self, **kwargs: Any) -> None:
|
||||
"""Turn the vacuum on and start cleaning."""
|
||||
|
||||
self.device.run(sucks.Clean())
|
||||
|
||||
def turn_off(self, **kwargs):
|
||||
def turn_off(self, **kwargs: Any) -> None:
|
||||
"""Turn the vacuum off stopping the cleaning and returning home."""
|
||||
self.return_to_base()
|
||||
|
||||
def stop(self, **kwargs):
|
||||
def stop(self, **kwargs: Any) -> None:
|
||||
"""Stop the vacuum cleaner."""
|
||||
|
||||
self.device.run(sucks.Stop())
|
||||
|
||||
def clean_spot(self, **kwargs):
|
||||
def clean_spot(self, **kwargs: Any) -> None:
|
||||
"""Perform a spot clean-up."""
|
||||
|
||||
self.device.run(sucks.Spot())
|
||||
|
||||
def locate(self, **kwargs):
|
||||
def locate(self, **kwargs: Any) -> None:
|
||||
"""Locate the vacuum cleaner."""
|
||||
|
||||
self.device.run(sucks.PlaySound())
|
||||
|
||||
def set_fan_speed(self, fan_speed, **kwargs):
|
||||
def set_fan_speed(self, fan_speed: str, **kwargs: Any) -> None:
|
||||
"""Set fan speed."""
|
||||
if self.is_on:
|
||||
|
||||
self.device.run(sucks.Clean(mode=self.device.clean_status, speed=fan_speed))
|
||||
|
||||
def send_command(self, command, params=None, **kwargs):
|
||||
def send_command(
|
||||
self,
|
||||
command: str,
|
||||
params: dict[str, Any] | list[Any] | None = None,
|
||||
**kwargs: Any,
|
||||
) -> None:
|
||||
"""Send a command to a vacuum cleaner."""
|
||||
self.device.run(sucks.VacBotCommand(command, params))
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
"""Support for Edimax switches."""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from pyedimax.smartplug import SmartPlug
|
||||
import voluptuous as vol
|
||||
|
||||
@ -67,15 +69,15 @@ class SmartPlugSwitch(SwitchEntity):
|
||||
"""Return true if switch is on."""
|
||||
return self._state
|
||||
|
||||
def turn_on(self, **kwargs):
|
||||
def turn_on(self, **kwargs: Any) -> None:
|
||||
"""Turn the switch on."""
|
||||
self.smartplug.state = "ON"
|
||||
|
||||
def turn_off(self, **kwargs):
|
||||
def turn_off(self, **kwargs: Any) -> None:
|
||||
"""Turn the switch off."""
|
||||
self.smartplug.state = "OFF"
|
||||
|
||||
def update(self):
|
||||
def update(self) -> None:
|
||||
"""Update edimax switch."""
|
||||
if not self._info:
|
||||
self._info = self.smartplug.info
|
||||
|
@ -386,7 +386,7 @@ class EDL21Entity(SensorEntity):
|
||||
self._async_remove_dispatcher = None
|
||||
self.entity_description = entity_description
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
async def async_added_to_hass(self) -> None:
|
||||
"""Run when entity about to be added to hass."""
|
||||
|
||||
@callback
|
||||
@ -411,7 +411,7 @@ class EDL21Entity(SensorEntity):
|
||||
self.hass, SIGNAL_EDL21_TELEGRAM, handle_telegram
|
||||
)
|
||||
|
||||
async def async_will_remove_from_hass(self):
|
||||
async def async_will_remove_from_hass(self) -> None:
|
||||
"""Run when entity will be removed from hass."""
|
||||
if self._async_remove_dispatcher:
|
||||
self._async_remove_dispatcher()
|
||||
|
@ -58,7 +58,7 @@ class EgardiaBinarySensor(BinarySensorEntity):
|
||||
self._device_class = device_class
|
||||
self._egardia_system = egardia_system
|
||||
|
||||
def update(self):
|
||||
def update(self) -> None:
|
||||
"""Update the status."""
|
||||
egardia_input = self._egardia_system.getsensorstate(self._id)
|
||||
self._state = STATE_ON if egardia_input else STATE_OFF
|
||||
|
@ -97,7 +97,7 @@ class EliqSensor(SensorEntity):
|
||||
"""Return the state of the device."""
|
||||
return self._state
|
||||
|
||||
async def async_update(self):
|
||||
async def async_update(self) -> None:
|
||||
"""Get the latest data."""
|
||||
try:
|
||||
response = await self._api.get_data_now(channelid=self._channel_id)
|
||||
|
@ -2,6 +2,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
import pypca
|
||||
from serial import SerialException
|
||||
@ -72,15 +73,15 @@ class SmartPlugSwitch(SwitchEntity):
|
||||
"""Return true if switch is on."""
|
||||
return self._state
|
||||
|
||||
def turn_on(self, **kwargs):
|
||||
def turn_on(self, **kwargs: Any) -> None:
|
||||
"""Turn the switch on."""
|
||||
self._pca.turn_on(self._device_id)
|
||||
|
||||
def turn_off(self, **kwargs):
|
||||
def turn_off(self, **kwargs: Any) -> None:
|
||||
"""Turn the switch off."""
|
||||
self._pca.turn_off(self._device_id)
|
||||
|
||||
def update(self):
|
||||
def update(self) -> None:
|
||||
"""Update the PCA switch's state."""
|
||||
try:
|
||||
self._state = self._pca.get_state(self._device_id)
|
||||
|
@ -153,7 +153,7 @@ class EmbyDevice(MediaPlayerEntity):
|
||||
self.media_status_last_position = None
|
||||
self.media_status_received = None
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
async def async_added_to_hass(self) -> None:
|
||||
"""Register callback."""
|
||||
self.emby.add_update_callback(self.async_update_callback, self.device_id)
|
||||
|
||||
@ -311,26 +311,26 @@ class EmbyDevice(MediaPlayerEntity):
|
||||
return SUPPORT_EMBY
|
||||
return 0
|
||||
|
||||
async def async_media_play(self):
|
||||
async def async_media_play(self) -> None:
|
||||
"""Play media."""
|
||||
await self.device.media_play()
|
||||
|
||||
async def async_media_pause(self):
|
||||
async def async_media_pause(self) -> None:
|
||||
"""Pause the media player."""
|
||||
await self.device.media_pause()
|
||||
|
||||
async def async_media_stop(self):
|
||||
async def async_media_stop(self) -> None:
|
||||
"""Stop the media player."""
|
||||
await self.device.media_stop()
|
||||
|
||||
async def async_media_next_track(self):
|
||||
async def async_media_next_track(self) -> None:
|
||||
"""Send next track command."""
|
||||
await self.device.media_next()
|
||||
|
||||
async def async_media_previous_track(self):
|
||||
async def async_media_previous_track(self) -> None:
|
||||
"""Send next track command."""
|
||||
await self.device.media_previous()
|
||||
|
||||
async def async_media_seek(self, position):
|
||||
async def async_media_seek(self, position: float) -> None:
|
||||
"""Send seek command."""
|
||||
await self.device.media_seek(position)
|
||||
|
@ -225,7 +225,7 @@ class EmonCmsSensor(SensorEntity):
|
||||
ATTR_LASTUPDATETIMESTR: template.timestamp_local(float(self._elem["time"])),
|
||||
}
|
||||
|
||||
def update(self):
|
||||
def update(self) -> None:
|
||||
"""Get the latest data and updates the state."""
|
||||
self._data.update()
|
||||
|
||||
|
@ -140,15 +140,15 @@ class Enigma2Device(MediaPlayerEntity):
|
||||
return STATE_OFF if self.e2_box.in_standby else STATE_ON
|
||||
|
||||
@property
|
||||
def available(self):
|
||||
def available(self) -> bool:
|
||||
"""Return True if the device is available."""
|
||||
return not self.e2_box.is_offline
|
||||
|
||||
def turn_off(self):
|
||||
def turn_off(self) -> None:
|
||||
"""Turn off media player."""
|
||||
self.e2_box.turn_off()
|
||||
|
||||
def turn_on(self):
|
||||
def turn_on(self) -> None:
|
||||
"""Turn the media player on."""
|
||||
self.e2_box.turn_on()
|
||||
|
||||
@ -187,15 +187,15 @@ class Enigma2Device(MediaPlayerEntity):
|
||||
"""Picon url for the channel."""
|
||||
return self.e2_box.picon_url
|
||||
|
||||
def set_volume_level(self, volume):
|
||||
def set_volume_level(self, volume: float) -> None:
|
||||
"""Set volume level, range 0..1."""
|
||||
self.e2_box.set_volume(int(volume * 100))
|
||||
|
||||
def volume_up(self):
|
||||
def volume_up(self) -> None:
|
||||
"""Volume up the media player."""
|
||||
self.e2_box.set_volume(int(self.e2_box.volume * 100) + 5)
|
||||
|
||||
def volume_down(self):
|
||||
def volume_down(self) -> None:
|
||||
"""Volume down media player."""
|
||||
self.e2_box.set_volume(int(self.e2_box.volume * 100) - 5)
|
||||
|
||||
@ -204,27 +204,27 @@ class Enigma2Device(MediaPlayerEntity):
|
||||
"""Volume level of the media player (0..1)."""
|
||||
return self.e2_box.volume
|
||||
|
||||
def media_stop(self):
|
||||
def media_stop(self) -> None:
|
||||
"""Send stop command."""
|
||||
self.e2_box.set_stop()
|
||||
|
||||
def media_play(self):
|
||||
def media_play(self) -> None:
|
||||
"""Play media."""
|
||||
self.e2_box.toggle_play_pause()
|
||||
|
||||
def media_pause(self):
|
||||
def media_pause(self) -> None:
|
||||
"""Pause the media player."""
|
||||
self.e2_box.toggle_play_pause()
|
||||
|
||||
def media_next_track(self):
|
||||
def media_next_track(self) -> None:
|
||||
"""Send next track command."""
|
||||
self.e2_box.set_channel_up()
|
||||
|
||||
def media_previous_track(self):
|
||||
def media_previous_track(self) -> None:
|
||||
"""Send next track command."""
|
||||
self.e2_box.set_channel_down()
|
||||
|
||||
def mute_volume(self, mute):
|
||||
def mute_volume(self, mute: bool) -> None:
|
||||
"""Mute or unmute."""
|
||||
self.e2_box.mute_volume()
|
||||
|
||||
@ -238,11 +238,11 @@ class Enigma2Device(MediaPlayerEntity):
|
||||
"""List of available input sources."""
|
||||
return self.e2_box.source_list
|
||||
|
||||
def select_source(self, source):
|
||||
def select_source(self, source: str) -> None:
|
||||
"""Select input source."""
|
||||
self.e2_box.select_source(self.e2_box.sources[source])
|
||||
|
||||
def update(self):
|
||||
def update(self) -> None:
|
||||
"""Update state of the media_player."""
|
||||
self.e2_box.update()
|
||||
|
||||
|
@ -162,7 +162,7 @@ class EnOceanSensor(EnOceanEntity, RestoreEntity, SensorEntity):
|
||||
self._attr_name = f"{description.name} {dev_name}"
|
||||
self._attr_unique_id = description.unique_id(dev_id)
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
async def async_added_to_hass(self) -> None:
|
||||
"""Call when entity about to be added to hass."""
|
||||
# If not None, we got an initial value.
|
||||
await super().async_added_to_hass()
|
||||
|
@ -1,6 +1,8 @@
|
||||
"""Support for EnOcean switches."""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from enocean.utils import combine_hex
|
||||
import voluptuous as vol
|
||||
|
||||
@ -94,7 +96,7 @@ class EnOceanSwitch(EnOceanEntity, SwitchEntity):
|
||||
"""Return the device name."""
|
||||
return self.dev_name
|
||||
|
||||
def turn_on(self, **kwargs):
|
||||
def turn_on(self, **kwargs: Any) -> None:
|
||||
"""Turn on the switch."""
|
||||
optional = [0x03]
|
||||
optional.extend(self.dev_id)
|
||||
@ -106,7 +108,7 @@ class EnOceanSwitch(EnOceanEntity, SwitchEntity):
|
||||
)
|
||||
self._on_state = True
|
||||
|
||||
def turn_off(self, **kwargs):
|
||||
def turn_off(self, **kwargs: Any) -> None:
|
||||
"""Turn off the switch."""
|
||||
optional = [0x03]
|
||||
optional.extend(self.dev_id)
|
||||
|
@ -62,7 +62,7 @@ class EnvisalinkBinarySensor(EnvisalinkDevice, BinarySensorEntity):
|
||||
_LOGGER.debug("Setting up zone: %s", zone_name)
|
||||
super().__init__(zone_name, info, controller)
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
async def async_added_to_hass(self) -> None:
|
||||
"""Register callbacks."""
|
||||
self.async_on_remove(
|
||||
async_dispatcher_connect(
|
||||
|
@ -59,7 +59,7 @@ class EnvisalinkSensor(EnvisalinkDevice, SensorEntity):
|
||||
_LOGGER.debug("Setting up sensor for partition: %s", partition_name)
|
||||
super().__init__(f"{partition_name} Keypad", info, controller)
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
async def async_added_to_hass(self) -> None:
|
||||
"""Register callbacks."""
|
||||
self.async_on_remove(
|
||||
async_dispatcher_connect(
|
||||
|
@ -2,6 +2,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
from homeassistant.components.switch import SwitchEntity
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
@ -58,7 +59,7 @@ class EnvisalinkSwitch(EnvisalinkDevice, SwitchEntity):
|
||||
|
||||
super().__init__(zone_name, info, controller)
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
async def async_added_to_hass(self) -> None:
|
||||
"""Register callbacks."""
|
||||
self.async_on_remove(
|
||||
async_dispatcher_connect(
|
||||
@ -71,11 +72,11 @@ class EnvisalinkSwitch(EnvisalinkDevice, SwitchEntity):
|
||||
"""Return the boolean response if the zone is bypassed."""
|
||||
return self._info["bypassed"]
|
||||
|
||||
async def async_turn_on(self, **kwargs):
|
||||
async def async_turn_on(self, **kwargs: Any) -> None:
|
||||
"""Send the bypass keypress sequence to toggle the zone bypass."""
|
||||
self._controller.toggle_zone_bypass(self._zone_number)
|
||||
|
||||
async def async_turn_off(self, **kwargs):
|
||||
async def async_turn_off(self, **kwargs: Any) -> None:
|
||||
"""Send the bypass keypress sequence to toggle the zone bypass."""
|
||||
self._controller.toggle_zone_bypass(self._zone_number)
|
||||
|
||||
|
@ -3,6 +3,7 @@ from __future__ import annotations
|
||||
|
||||
from datetime import timedelta
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
from pyephember.pyephember import (
|
||||
EphEmber,
|
||||
@ -141,7 +142,7 @@ class EphEmberThermostat(ClimateEntity):
|
||||
"""Return the supported operations."""
|
||||
return OPERATION_LIST
|
||||
|
||||
def set_hvac_mode(self, hvac_mode):
|
||||
def set_hvac_mode(self, hvac_mode: HVACMode) -> None:
|
||||
"""Set the operation mode."""
|
||||
mode = self.map_mode_hass_eph(hvac_mode)
|
||||
if mode is not None:
|
||||
@ -155,17 +156,17 @@ class EphEmberThermostat(ClimateEntity):
|
||||
|
||||
return zone_is_boost_active(self._zone)
|
||||
|
||||
def turn_aux_heat_on(self):
|
||||
def turn_aux_heat_on(self) -> None:
|
||||
"""Turn auxiliary heater on."""
|
||||
self._ember.activate_boost_by_name(
|
||||
self._zone_name, zone_target_temperature(self._zone)
|
||||
)
|
||||
|
||||
def turn_aux_heat_off(self):
|
||||
def turn_aux_heat_off(self) -> None:
|
||||
"""Turn auxiliary heater off."""
|
||||
self._ember.deactivate_boost_by_name(self._zone_name)
|
||||
|
||||
def set_temperature(self, **kwargs):
|
||||
def set_temperature(self, **kwargs: Any) -> None:
|
||||
"""Set new target temperature."""
|
||||
if (temperature := kwargs.get(ATTR_TEMPERATURE)) is None:
|
||||
return
|
||||
@ -198,7 +199,7 @@ class EphEmberThermostat(ClimateEntity):
|
||||
|
||||
return 35.0
|
||||
|
||||
def update(self):
|
||||
def update(self) -> None:
|
||||
"""Get the latest data."""
|
||||
self._zone = self._ember.get_zone(self._zone_name)
|
||||
|
||||
|
@ -114,7 +114,7 @@ class EpsonProjectorMediaPlayer(MediaPlayerEntity):
|
||||
)
|
||||
return True
|
||||
|
||||
async def async_update(self):
|
||||
async def async_update(self) -> None:
|
||||
"""Update state of device."""
|
||||
power_state = await self._projector.get_power()
|
||||
_LOGGER.debug("Projector status: %s", power_state)
|
||||
@ -175,13 +175,13 @@ class EpsonProjectorMediaPlayer(MediaPlayerEntity):
|
||||
"""Return if projector is available."""
|
||||
return self._available
|
||||
|
||||
async def async_turn_on(self):
|
||||
async def async_turn_on(self) -> None:
|
||||
"""Turn on epson."""
|
||||
if self._state == STATE_OFF:
|
||||
await self._projector.send_command(TURN_ON)
|
||||
self._state = STATE_ON
|
||||
|
||||
async def async_turn_off(self):
|
||||
async def async_turn_off(self) -> None:
|
||||
"""Turn off epson."""
|
||||
if self._state == STATE_ON:
|
||||
await self._projector.send_command(TURN_OFF)
|
||||
@ -206,36 +206,36 @@ class EpsonProjectorMediaPlayer(MediaPlayerEntity):
|
||||
"""Set color mode in Epson."""
|
||||
await self._projector.send_command(CMODE_LIST_SET[cmode])
|
||||
|
||||
async def async_select_source(self, source):
|
||||
async def async_select_source(self, source: str) -> None:
|
||||
"""Select input source."""
|
||||
selected_source = INV_SOURCES[source]
|
||||
await self._projector.send_command(selected_source)
|
||||
|
||||
async def async_mute_volume(self, mute):
|
||||
async def async_mute_volume(self, mute: bool) -> None:
|
||||
"""Mute (true) or unmute (false) sound."""
|
||||
await self._projector.send_command(MUTE)
|
||||
|
||||
async def async_volume_up(self):
|
||||
async def async_volume_up(self) -> None:
|
||||
"""Increase volume."""
|
||||
await self._projector.send_command(VOL_UP)
|
||||
|
||||
async def async_volume_down(self):
|
||||
async def async_volume_down(self) -> None:
|
||||
"""Decrease volume."""
|
||||
await self._projector.send_command(VOL_DOWN)
|
||||
|
||||
async def async_media_play(self):
|
||||
async def async_media_play(self) -> None:
|
||||
"""Play media via Epson."""
|
||||
await self._projector.send_command(PLAY)
|
||||
|
||||
async def async_media_pause(self):
|
||||
async def async_media_pause(self) -> None:
|
||||
"""Pause media via Epson."""
|
||||
await self._projector.send_command(PAUSE)
|
||||
|
||||
async def async_media_next_track(self):
|
||||
async def async_media_next_track(self) -> None:
|
||||
"""Skip to next."""
|
||||
await self._projector.send_command(FAST)
|
||||
|
||||
async def async_media_previous_track(self):
|
||||
async def async_media_previous_track(self) -> None:
|
||||
"""Skip to previous."""
|
||||
await self._projector.send_command(BACK)
|
||||
|
||||
|
@ -94,7 +94,9 @@ def setup_platform(
|
||||
class EpsonPrinterCartridge(SensorEntity):
|
||||
"""Representation of a cartridge sensor."""
|
||||
|
||||
def __init__(self, api, description: SensorEntityDescription):
|
||||
def __init__(
|
||||
self, api: EpsonPrinterAPI, description: SensorEntityDescription
|
||||
) -> None:
|
||||
"""Initialize a cartridge sensor."""
|
||||
self._api = api
|
||||
self.entity_description = description
|
||||
@ -105,10 +107,10 @@ class EpsonPrinterCartridge(SensorEntity):
|
||||
return self._api.getSensorValue(self.entity_description.key)
|
||||
|
||||
@property
|
||||
def available(self):
|
||||
def available(self) -> bool:
|
||||
"""Could the device be accessed during the last update call."""
|
||||
return self._api.available
|
||||
|
||||
def update(self):
|
||||
def update(self) -> None:
|
||||
"""Get the latest data from the Epson printer."""
|
||||
self._api.update()
|
||||
|
@ -2,6 +2,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
import eq3bt as eq3 # pylint: disable=import-error
|
||||
import voluptuous as vol
|
||||
@ -140,7 +141,7 @@ class EQ3BTSmartThermostat(ClimateEntity):
|
||||
"""Return the temperature we try to reach."""
|
||||
return self._thermostat.target_temperature
|
||||
|
||||
def set_temperature(self, **kwargs):
|
||||
def set_temperature(self, **kwargs: Any) -> None:
|
||||
"""Set new target temperature."""
|
||||
if (temperature := kwargs.get(ATTR_TEMPERATURE)) is None:
|
||||
return
|
||||
@ -158,7 +159,7 @@ class EQ3BTSmartThermostat(ClimateEntity):
|
||||
"""Return the list of available operation modes."""
|
||||
return list(HA_TO_EQ_HVAC)
|
||||
|
||||
def set_hvac_mode(self, hvac_mode):
|
||||
def set_hvac_mode(self, hvac_mode: HVACMode) -> None:
|
||||
"""Set operation mode."""
|
||||
self._thermostat.mode = HA_TO_EQ_HVAC[hvac_mode]
|
||||
|
||||
@ -206,13 +207,13 @@ class EQ3BTSmartThermostat(ClimateEntity):
|
||||
"""Return the MAC address of the thermostat."""
|
||||
return format_mac(self._mac)
|
||||
|
||||
def set_preset_mode(self, preset_mode):
|
||||
def set_preset_mode(self, preset_mode: str) -> None:
|
||||
"""Set new preset mode."""
|
||||
if preset_mode == PRESET_NONE:
|
||||
self.set_hvac_mode(HVACMode.HEAT)
|
||||
self._thermostat.mode = HA_TO_EQ_PRESET[preset_mode]
|
||||
|
||||
def update(self):
|
||||
def update(self) -> None:
|
||||
"""Update the data from the thermostat."""
|
||||
|
||||
try:
|
||||
|
@ -83,7 +83,7 @@ class EtherscanSensor(SensorEntity):
|
||||
"""Return the state attributes of the sensor."""
|
||||
return {ATTR_ATTRIBUTION: ATTRIBUTION}
|
||||
|
||||
def update(self):
|
||||
def update(self) -> None:
|
||||
"""Get the latest state of the sensor."""
|
||||
|
||||
if self._token_address:
|
||||
|
@ -1,6 +1,8 @@
|
||||
"""Support for Eufy switches."""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
import lakeside
|
||||
|
||||
from homeassistant.components.switch import SwitchEntity
|
||||
@ -35,7 +37,7 @@ class EufySwitch(SwitchEntity):
|
||||
self._switch = lakeside.switch(self._address, self._code, self._type)
|
||||
self._switch.connect()
|
||||
|
||||
def update(self):
|
||||
def update(self) -> None:
|
||||
"""Synchronise state from the switch."""
|
||||
self._switch.update()
|
||||
self._state = self._switch.power
|
||||
@ -55,7 +57,7 @@ class EufySwitch(SwitchEntity):
|
||||
"""Return true if device is on."""
|
||||
return self._state
|
||||
|
||||
def turn_on(self, **kwargs):
|
||||
def turn_on(self, **kwargs: Any) -> None:
|
||||
"""Turn the specified switch on."""
|
||||
try:
|
||||
self._switch.set_state(True)
|
||||
@ -63,7 +65,7 @@ class EufySwitch(SwitchEntity):
|
||||
self._switch.connect()
|
||||
self._switch.set_state(power=True)
|
||||
|
||||
def turn_off(self, **kwargs):
|
||||
def turn_off(self, **kwargs: Any) -> None:
|
||||
"""Turn the specified switch off."""
|
||||
try:
|
||||
self._switch.set_state(False)
|
||||
|
@ -3,6 +3,7 @@ from __future__ import annotations
|
||||
|
||||
from datetime import timedelta
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
import pyeverlights
|
||||
import voluptuous as vol
|
||||
@ -155,11 +156,11 @@ class EverLightsLight(LightEntity):
|
||||
self._brightness = brightness
|
||||
self._effect = effect
|
||||
|
||||
async def async_turn_off(self, **kwargs):
|
||||
async def async_turn_off(self, **kwargs: Any) -> None:
|
||||
"""Turn the light off."""
|
||||
await self._api.clear_pattern(self._channel)
|
||||
|
||||
async def async_update(self):
|
||||
async def async_update(self) -> None:
|
||||
"""Synchronize state with control box."""
|
||||
try:
|
||||
self._status = await self._api.get_status()
|
||||
|
@ -110,11 +110,11 @@ class EvoDHW(EvoChild, WaterHeaterEntity):
|
||||
self._evo_device.set_dhw_off(until=until)
|
||||
)
|
||||
|
||||
async def async_turn_away_mode_on(self):
|
||||
async def async_turn_away_mode_on(self) -> None:
|
||||
"""Turn away mode on."""
|
||||
await self._evo_broker.call_client_api(self._evo_device.set_dhw_off())
|
||||
|
||||
async def async_turn_away_mode_off(self):
|
||||
async def async_turn_away_mode_off(self) -> None:
|
||||
"""Turn away mode off."""
|
||||
await self._evo_broker.call_client_api(self._evo_device.set_dhw_auto())
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user