Improve entity type hints [w] (#77886)
This commit is contained in:
parent
050cb275ff
commit
a6b6949793
12 changed files with 24 additions and 21 deletions
|
@ -138,6 +138,6 @@ class W800rf32BinarySensor(BinarySensorEntity):
|
|||
self._state = state
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
async def async_added_to_hass(self) -> None:
|
||||
"""Register update callback."""
|
||||
async_dispatcher_connect(self.hass, self._signal, self.binary_sensor_update)
|
||||
|
|
|
@ -3,6 +3,7 @@ from __future__ import annotations
|
|||
|
||||
import logging
|
||||
import subprocess as sp
|
||||
from typing import Any
|
||||
|
||||
import voluptuous as vol
|
||||
import wakeonlan
|
||||
|
@ -125,7 +126,7 @@ class WolSwitch(SwitchEntity):
|
|||
"""Return the unique id of this switch."""
|
||||
return self._unique_id
|
||||
|
||||
def turn_on(self, **kwargs):
|
||||
def turn_on(self, **kwargs: Any) -> None:
|
||||
"""Turn the device on."""
|
||||
service_kwargs = {}
|
||||
if self._broadcast_address is not None:
|
||||
|
@ -146,7 +147,7 @@ class WolSwitch(SwitchEntity):
|
|||
self._state = True
|
||||
self.async_write_ha_state()
|
||||
|
||||
def turn_off(self, **kwargs):
|
||||
def turn_off(self, **kwargs: Any) -> None:
|
||||
"""Turn the device off if an off action is present."""
|
||||
if self._off_script is not None:
|
||||
self._off_script.run(context=self._context)
|
||||
|
@ -155,7 +156,7 @@ class WolSwitch(SwitchEntity):
|
|||
self._state = False
|
||||
self.async_write_ha_state()
|
||||
|
||||
def update(self):
|
||||
def update(self) -> None:
|
||||
"""Check if device is on and update the state. Only called if assumed state is false."""
|
||||
ping_cmd = [
|
||||
"ping",
|
||||
|
|
|
@ -183,7 +183,7 @@ class WaqiSensor(SensorEntity):
|
|||
except (IndexError, KeyError):
|
||||
return {ATTR_ATTRIBUTION: ATTRIBUTION}
|
||||
|
||||
async def async_update(self):
|
||||
async def async_update(self) -> None:
|
||||
"""Get the latest data and updates the states."""
|
||||
if self.uid:
|
||||
result = await self._client.get_station_by_number(self.uid)
|
||||
|
|
|
@ -133,7 +133,7 @@ class WaterFurnaceSensor(SensorEntity):
|
|||
"""Return the units of measurement."""
|
||||
return self._unit_of_measurement
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
async def async_added_to_hass(self) -> None:
|
||||
"""Register callbacks."""
|
||||
self.async_on_remove(
|
||||
async_dispatcher_connect(
|
||||
|
|
|
@ -161,7 +161,7 @@ class WazeTravelTime(SensorEntity):
|
|||
await self.hass.async_add_executor_job(self.update)
|
||||
self.async_write_ha_state()
|
||||
|
||||
def update(self):
|
||||
def update(self) -> None:
|
||||
"""Fetch new state data for the sensor."""
|
||||
_LOGGER.debug("Fetching Route for %s", self._attr_name)
|
||||
self._waze_data.origin = find_coordinates(self.hass, self._origin)
|
||||
|
|
|
@ -101,7 +101,7 @@ class WirelessTagBinarySensor(WirelessTagBaseSensor, BinarySensorEntity):
|
|||
self._sensor_type = sensor_type
|
||||
self._name = f"{self._tag.name} {self.event.human_readable_name}"
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
async def async_added_to_hass(self) -> None:
|
||||
"""Register callbacks."""
|
||||
tag_id = self.tag_id
|
||||
event_type = self.device_class
|
||||
|
|
|
@ -109,7 +109,7 @@ class WirelessTagSensor(WirelessTagBaseSensor, SensorEntity):
|
|||
f"sensor.{WIRELESSTAG_DOMAIN}_{self.underscored_name}_{self._sensor_type}"
|
||||
)
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
async def async_added_to_hass(self) -> None:
|
||||
"""Register callbacks."""
|
||||
self.async_on_remove(
|
||||
async_dispatcher_connect(
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
"""Switch implementation for Wireless Sensor Tags (wirelesstag.net)."""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.switch import (
|
||||
|
@ -81,11 +83,11 @@ class WirelessTagSwitch(WirelessTagBaseSensor, SwitchEntity):
|
|||
self.entity_description = description
|
||||
self._name = f"{self._tag.name} {description.name}"
|
||||
|
||||
def turn_on(self, **kwargs):
|
||||
def turn_on(self, **kwargs: Any) -> None:
|
||||
"""Turn on the switch."""
|
||||
self._api.arm(self)
|
||||
|
||||
def turn_off(self, **kwargs):
|
||||
def turn_off(self, **kwargs: Any) -> None:
|
||||
"""Turn on the switch."""
|
||||
self._api.disarm(self)
|
||||
|
||||
|
|
|
@ -110,7 +110,7 @@ class WorldTidesInfoSensor(SensorEntity):
|
|||
return None
|
||||
return None
|
||||
|
||||
def update(self):
|
||||
def update(self) -> None:
|
||||
"""Get the latest data from WorldTidesInfo API."""
|
||||
start = int(time.time())
|
||||
resource = (
|
||||
|
|
|
@ -89,7 +89,7 @@ class WorxLandroidSensor(SensorEntity):
|
|||
return PERCENTAGE
|
||||
return None
|
||||
|
||||
async def async_update(self):
|
||||
async def async_update(self) -> None:
|
||||
"""Update the sensor data from the mower."""
|
||||
connection_error = False
|
||||
|
||||
|
|
|
@ -106,7 +106,7 @@ class Ws66iZone(CoordinatorEntity[Ws66iDataUpdateCoordinator], MediaPlayerEntity
|
|||
self._set_attrs_from_status()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_select_source(self, source):
|
||||
async def async_select_source(self, source: str) -> None:
|
||||
"""Set input source."""
|
||||
idx = self._ws66i_data.sources.name_id[source]
|
||||
await self.hass.async_add_executor_job(
|
||||
|
@ -115,7 +115,7 @@ class Ws66iZone(CoordinatorEntity[Ws66iDataUpdateCoordinator], MediaPlayerEntity
|
|||
self._status.source = idx
|
||||
self._async_update_attrs_write_ha_state()
|
||||
|
||||
async def async_turn_on(self):
|
||||
async def async_turn_on(self) -> None:
|
||||
"""Turn the media player on."""
|
||||
await self.hass.async_add_executor_job(
|
||||
self._ws66i.set_power, self._zone_id, True
|
||||
|
@ -123,7 +123,7 @@ class Ws66iZone(CoordinatorEntity[Ws66iDataUpdateCoordinator], MediaPlayerEntity
|
|||
self._status.power = True
|
||||
self._async_update_attrs_write_ha_state()
|
||||
|
||||
async def async_turn_off(self):
|
||||
async def async_turn_off(self) -> None:
|
||||
"""Turn the media player off."""
|
||||
await self.hass.async_add_executor_job(
|
||||
self._ws66i.set_power, self._zone_id, False
|
||||
|
@ -131,7 +131,7 @@ class Ws66iZone(CoordinatorEntity[Ws66iDataUpdateCoordinator], MediaPlayerEntity
|
|||
self._status.power = False
|
||||
self._async_update_attrs_write_ha_state()
|
||||
|
||||
async def async_mute_volume(self, mute):
|
||||
async def async_mute_volume(self, mute: bool) -> None:
|
||||
"""Mute (true) or unmute (false) media player."""
|
||||
await self.hass.async_add_executor_job(
|
||||
self._ws66i.set_mute, self._zone_id, mute
|
||||
|
@ -139,19 +139,19 @@ class Ws66iZone(CoordinatorEntity[Ws66iDataUpdateCoordinator], MediaPlayerEntity
|
|||
self._status.mute = bool(mute)
|
||||
self._async_update_attrs_write_ha_state()
|
||||
|
||||
async def async_set_volume_level(self, volume):
|
||||
async def async_set_volume_level(self, volume: float) -> None:
|
||||
"""Set volume level, range 0..1."""
|
||||
await self.hass.async_add_executor_job(self._set_volume, int(volume * MAX_VOL))
|
||||
self._async_update_attrs_write_ha_state()
|
||||
|
||||
async def async_volume_up(self):
|
||||
async def async_volume_up(self) -> None:
|
||||
"""Volume up the media player."""
|
||||
await self.hass.async_add_executor_job(
|
||||
self._set_volume, min(self._status.volume + 1, MAX_VOL)
|
||||
)
|
||||
self._async_update_attrs_write_ha_state()
|
||||
|
||||
async def async_volume_down(self):
|
||||
async def async_volume_down(self) -> None:
|
||||
"""Volume down media player."""
|
||||
await self.hass.async_add_executor_job(
|
||||
self._set_volume, max(self._status.volume - 1, 0)
|
||||
|
|
|
@ -113,7 +113,7 @@ class WashingtonStateTravelTimeSensor(WashingtonStateTransportSensor):
|
|||
self._travel_time_id = travel_time_id
|
||||
WashingtonStateTransportSensor.__init__(self, name, access_code)
|
||||
|
||||
def update(self):
|
||||
def update(self) -> None:
|
||||
"""Get the latest data from WSDOT."""
|
||||
params = {
|
||||
ATTR_ACCESS_CODE: self._access_code,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue