Improve entity type hints [s] (part 1/2) (#77881)
parent
34da463df0
commit
0c767bd0d3
|
@ -167,7 +167,7 @@ class SabnzbdSensor(SensorEntity):
|
|||
name=DEFAULT_NAME,
|
||||
)
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
async def async_added_to_hass(self) -> None:
|
||||
"""Call when entity about to be added to hass."""
|
||||
self.async_on_remove(
|
||||
async_dispatcher_connect(
|
||||
|
|
|
@ -73,7 +73,7 @@ class SatelIntegraBinarySensor(BinarySensorEntity):
|
|||
self._react_to_signal = react_to_signal
|
||||
self._satel = controller
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
async def async_added_to_hass(self) -> None:
|
||||
"""Register callbacks."""
|
||||
if self._react_to_signal == SIGNAL_OUTPUTS_UPDATED:
|
||||
if self._device_number in self._satel.violated_outputs:
|
||||
|
|
|
@ -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
|
||||
|
@ -61,7 +62,7 @@ class SatelIntegraSwitch(SwitchEntity):
|
|||
self._code = code
|
||||
self._satel = controller
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
async def async_added_to_hass(self) -> None:
|
||||
"""Register callbacks."""
|
||||
async_dispatcher_connect(
|
||||
self.hass, SIGNAL_OUTPUTS_UPDATED, self._devices_updated
|
||||
|
@ -78,13 +79,13 @@ class SatelIntegraSwitch(SwitchEntity):
|
|||
self._state = new_state
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_turn_on(self, **kwargs):
|
||||
async def async_turn_on(self, **kwargs: Any) -> None:
|
||||
"""Turn the device on."""
|
||||
_LOGGER.debug("Switch: %s status: %s, turning on", self._name, self._state)
|
||||
await self._satel.set_output(self._code, self._device_number, True)
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_turn_off(self, **kwargs):
|
||||
async def async_turn_off(self, **kwargs: Any) -> None:
|
||||
"""Turn the device off."""
|
||||
_LOGGER.debug(
|
||||
"Switch name: %s status: %s, turning off", self._name, self._state
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
from requests import RequestException
|
||||
import voluptuous as vol
|
||||
|
@ -131,7 +132,7 @@ class SchluterThermostat(CoordinatorEntity, ClimateEntity):
|
|||
async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None:
|
||||
"""Mode is always heating, so do nothing."""
|
||||
|
||||
def set_temperature(self, **kwargs):
|
||||
def set_temperature(self, **kwargs: Any) -> None:
|
||||
"""Set new target temperature."""
|
||||
target_temp = None
|
||||
target_temp = kwargs.get(ATTR_TEMPERATURE)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
"""Support for a ScreenLogic heating device."""
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
from screenlogicpy.const import DATA as SL_DATA, EQUIPMENT, HEAT_MODE
|
||||
|
||||
|
@ -130,7 +131,7 @@ class ScreenLogicClimate(ScreenlogicEntity, ClimateEntity, RestoreEntity):
|
|||
HEAT_MODE.NAME_FOR_NUM[mode_num] for mode_num in self._configured_heat_modes
|
||||
]
|
||||
|
||||
async def async_set_temperature(self, **kwargs) -> None:
|
||||
async def async_set_temperature(self, **kwargs: Any) -> None:
|
||||
"""Change the setpoint of the heater."""
|
||||
if (temperature := kwargs.get(ATTR_TEMPERATURE)) is None:
|
||||
raise ValueError(f"Expected attribute {ATTR_TEMPERATURE}")
|
||||
|
@ -144,7 +145,7 @@ class ScreenLogicClimate(ScreenlogicEntity, ClimateEntity, RestoreEntity):
|
|||
f"Failed to set_temperature {temperature} on body {self.body['body_type']['value']}"
|
||||
)
|
||||
|
||||
async def async_set_hvac_mode(self, hvac_mode) -> None:
|
||||
async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None:
|
||||
"""Set the operation mode."""
|
||||
if hvac_mode == HVACMode.OFF:
|
||||
mode = HEAT_MODE.OFF
|
||||
|
@ -172,7 +173,7 @@ class ScreenLogicClimate(ScreenlogicEntity, ClimateEntity, RestoreEntity):
|
|||
f"Failed to set_preset_mode {mode} on body {self.body['body_type']['value']}"
|
||||
)
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
async def async_added_to_hass(self) -> None:
|
||||
"""Run when entity is about to be added."""
|
||||
await super().async_added_to_hass()
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
from scsgate.messages import ScenarioTriggeredMessage, StateMessage
|
||||
from scsgate.tasks import ToggleStatusTask
|
||||
|
@ -116,7 +117,7 @@ class SCSGateSwitch(SwitchEntity):
|
|||
"""Return true if switch is on."""
|
||||
return self._toggled
|
||||
|
||||
def turn_on(self, **kwargs):
|
||||
def turn_on(self, **kwargs: Any) -> None:
|
||||
"""Turn the device on."""
|
||||
|
||||
self._scsgate.append_task(ToggleStatusTask(target=self._scs_id, toggled=True))
|
||||
|
@ -124,7 +125,7 @@ class SCSGateSwitch(SwitchEntity):
|
|||
self._toggled = True
|
||||
self.schedule_update_ha_state()
|
||||
|
||||
def turn_off(self, **kwargs):
|
||||
def turn_off(self, **kwargs: Any) -> None:
|
||||
"""Turn the device off."""
|
||||
|
||||
self._scsgate.append_task(ToggleStatusTask(target=self._scs_id, toggled=False))
|
||||
|
|
|
@ -126,7 +126,7 @@ class SenseDevice(BinarySensorEntity):
|
|||
"""Return the device class of the binary sensor."""
|
||||
return BinarySensorDeviceClass.POWER
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
async def async_added_to_hass(self) -> None:
|
||||
"""Register callbacks."""
|
||||
self.async_on_remove(
|
||||
async_dispatcher_connect(
|
||||
|
|
|
@ -182,7 +182,7 @@ class SenseActiveSensor(SensorEntity):
|
|||
self._variant_id = variant_id
|
||||
self._variant_name = variant_name
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
async def async_added_to_hass(self) -> None:
|
||||
"""Register callbacks."""
|
||||
self.async_on_remove(
|
||||
async_dispatcher_connect(
|
||||
|
@ -230,7 +230,7 @@ class SenseVoltageSensor(SensorEntity):
|
|||
self._sense_monitor_id = sense_monitor_id
|
||||
self._voltage_index = index
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
async def async_added_to_hass(self) -> None:
|
||||
"""Register callbacks."""
|
||||
self.async_on_remove(
|
||||
async_dispatcher_connect(
|
||||
|
@ -323,7 +323,7 @@ class SenseEnergyDevice(SensorEntity):
|
|||
self._attr_icon = sense_to_mdi(device["icon"])
|
||||
self._sense_devices_data = sense_devices_data
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
async def async_added_to_hass(self) -> None:
|
||||
"""Register callbacks."""
|
||||
self.async_on_remove(
|
||||
async_dispatcher_connect(
|
||||
|
|
|
@ -143,7 +143,7 @@ class SerialSensor(SensorEntity):
|
|||
self._template = value_template
|
||||
self._attributes = None
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
async def async_added_to_hass(self) -> None:
|
||||
"""Handle when an entity is about to be added to Home Assistant."""
|
||||
self._serial_loop_task = self.hass.loop.create_task(
|
||||
self.serial_read(
|
||||
|
|
|
@ -90,7 +90,7 @@ class ParticulateMatterSensor(SensorEntity):
|
|||
"""Return the unit of measurement of this entity, if any."""
|
||||
return CONCENTRATION_MICROGRAMS_PER_CUBIC_METER
|
||||
|
||||
def update(self):
|
||||
def update(self) -> None:
|
||||
"""Read from sensor and update the state."""
|
||||
_LOGGER.debug("Reading data from PM sensor")
|
||||
try:
|
||||
|
|
|
@ -134,7 +134,7 @@ class SeventeenTrackSummarySensor(SensorEntity):
|
|||
"""Return the state."""
|
||||
return self._state
|
||||
|
||||
async def async_update(self):
|
||||
async def async_update(self) -> None:
|
||||
"""Update the sensor."""
|
||||
await self._data.async_update()
|
||||
|
||||
|
@ -189,7 +189,7 @@ class SeventeenTrackPackageSensor(SensorEntity):
|
|||
)
|
||||
|
||||
@property
|
||||
def available(self):
|
||||
def available(self) -> bool:
|
||||
"""Return whether the entity is available."""
|
||||
return self._data.packages.get(self._tracking_number) is not None
|
||||
|
||||
|
@ -205,7 +205,7 @@ class SeventeenTrackPackageSensor(SensorEntity):
|
|||
"""Return the state."""
|
||||
return self._state
|
||||
|
||||
async def async_update(self):
|
||||
async def async_update(self) -> None:
|
||||
"""Update the sensor."""
|
||||
await self._data.async_update()
|
||||
|
||||
|
|
|
@ -149,7 +149,7 @@ class SigfoxDevice(SensorEntity):
|
|||
"time": epoch_to_datetime(epoch_time),
|
||||
}
|
||||
|
||||
def update(self):
|
||||
def update(self) -> None:
|
||||
"""Fetch the latest device message."""
|
||||
self._message_data = self.get_last_message()
|
||||
self._state = self._message_data["payload"]
|
||||
|
|
|
@ -121,7 +121,7 @@ class SimulatedSensor(SensorEntity):
|
|||
noise = self._random.gauss(mu=0, sigma=fwhm)
|
||||
return round(mean + periodic + noise, 3)
|
||||
|
||||
async def async_update(self):
|
||||
async def async_update(self) -> None:
|
||||
"""Update the sensor."""
|
||||
self._state = self.signal_calc()
|
||||
|
||||
|
|
|
@ -65,11 +65,11 @@ class SisyphusPlayer(MediaPlayerEntity):
|
|||
self._host = host
|
||||
self._table = table
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
async def async_added_to_hass(self) -> None:
|
||||
"""Add listeners after this object has been initialized."""
|
||||
self._table.add_listener(self.async_write_ha_state)
|
||||
|
||||
async def async_update(self):
|
||||
async def async_update(self) -> None:
|
||||
"""Force update table state."""
|
||||
await self._table.refresh()
|
||||
|
||||
|
@ -79,7 +79,7 @@ class SisyphusPlayer(MediaPlayerEntity):
|
|||
return self._table.id
|
||||
|
||||
@property
|
||||
def available(self):
|
||||
def available(self) -> bool:
|
||||
"""Return true if the table is responding to heartbeats."""
|
||||
return self._table.is_connected
|
||||
|
||||
|
@ -113,7 +113,7 @@ class SisyphusPlayer(MediaPlayerEntity):
|
|||
"""Return True if the current playlist is in shuffle mode."""
|
||||
return self._table.is_shuffle
|
||||
|
||||
async def async_set_shuffle(self, shuffle):
|
||||
async def async_set_shuffle(self, shuffle: bool) -> None:
|
||||
"""Change the shuffle mode of the current playlist."""
|
||||
await self._table.set_shuffle(shuffle)
|
||||
|
||||
|
@ -164,35 +164,35 @@ class SisyphusPlayer(MediaPlayerEntity):
|
|||
|
||||
return super().media_image_url
|
||||
|
||||
async def async_turn_on(self):
|
||||
async def async_turn_on(self) -> None:
|
||||
"""Wake up a sleeping table."""
|
||||
await self._table.wakeup()
|
||||
|
||||
async def async_turn_off(self):
|
||||
async def async_turn_off(self) -> None:
|
||||
"""Put the table to sleep."""
|
||||
await self._table.sleep()
|
||||
|
||||
async def async_volume_down(self):
|
||||
async def async_volume_down(self) -> None:
|
||||
"""Slow down playback."""
|
||||
await self._table.set_speed(max(0, self._table.speed - 0.1))
|
||||
|
||||
async def async_volume_up(self):
|
||||
async def async_volume_up(self) -> None:
|
||||
"""Speed up playback."""
|
||||
await self._table.set_speed(min(1.0, self._table.speed + 0.1))
|
||||
|
||||
async def async_set_volume_level(self, volume):
|
||||
async def async_set_volume_level(self, volume: float) -> None:
|
||||
"""Set playback speed (0..1)."""
|
||||
await self._table.set_speed(volume)
|
||||
|
||||
async def async_media_play(self):
|
||||
async def async_media_play(self) -> None:
|
||||
"""Start playing."""
|
||||
await self._table.play()
|
||||
|
||||
async def async_media_pause(self):
|
||||
async def async_media_pause(self) -> None:
|
||||
"""Pause."""
|
||||
await self._table.pause()
|
||||
|
||||
async def async_media_next_track(self):
|
||||
async def async_media_next_track(self) -> None:
|
||||
"""Skip to next track."""
|
||||
cur_track_index = self._get_current_track_index()
|
||||
|
||||
|
@ -200,7 +200,7 @@ class SisyphusPlayer(MediaPlayerEntity):
|
|||
self._table.active_playlist.tracks[cur_track_index + 1]
|
||||
)
|
||||
|
||||
async def async_media_previous_track(self):
|
||||
async def async_media_previous_track(self) -> None:
|
||||
"""Skip to previous track."""
|
||||
cur_track_index = self._get_current_track_index()
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
from typing import Any
|
||||
|
||||
from aioslimproto.client import PlayerState, SlimClient
|
||||
from aioslimproto.const import EventType, SlimEvent
|
||||
|
@ -175,7 +176,9 @@ class SlimProtoPlayer(MediaPlayerEntity):
|
|||
"""Turn off device."""
|
||||
await self.player.power(False)
|
||||
|
||||
async def async_play_media(self, media_type: str, media_id: str, **kwargs) -> None:
|
||||
async def async_play_media(
|
||||
self, media_type: str, media_id: str, **kwargs: Any
|
||||
) -> None:
|
||||
"""Send the play_media command to the media player."""
|
||||
to_send_media_type: str | None = media_type
|
||||
# Handle media_source
|
||||
|
@ -193,7 +196,7 @@ class SlimProtoPlayer(MediaPlayerEntity):
|
|||
await self.player.play_url(media_id, mime_type=to_send_media_type)
|
||||
|
||||
async def async_browse_media(
|
||||
self, media_content_type=None, media_content_id=None
|
||||
self, media_content_type: str | None = None, media_content_id: str | None = None
|
||||
) -> BrowseMedia:
|
||||
"""Implement the websocket media browsing helper."""
|
||||
return await media_source.async_browse_media(
|
||||
|
|
|
@ -91,7 +91,7 @@ class SmappeePresence(BinarySensorEntity):
|
|||
sw_version=self._service_location.firmware_version,
|
||||
)
|
||||
|
||||
async def async_update(self):
|
||||
async def async_update(self) -> None:
|
||||
"""Get the latest data from Smappee and update the state."""
|
||||
await self._smappee_base.async_update()
|
||||
|
||||
|
@ -174,7 +174,7 @@ class SmappeeAppliance(BinarySensorEntity):
|
|||
sw_version=self._service_location.firmware_version,
|
||||
)
|
||||
|
||||
async def async_update(self):
|
||||
async def async_update(self) -> None:
|
||||
"""Get the latest data from Smappee and update the state."""
|
||||
await self._smappee_base.async_update()
|
||||
|
||||
|
|
|
@ -388,7 +388,7 @@ class SmappeeSensor(SensorEntity):
|
|||
sw_version=self._service_location.firmware_version,
|
||||
)
|
||||
|
||||
async def async_update(self):
|
||||
async def async_update(self) -> None:
|
||||
"""Get the latest data from Smappee and update the state."""
|
||||
await self._smappee_base.async_update()
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
"""Support for interacting with Smappee Comport Plugs, Switches and Output Modules."""
|
||||
from typing import Any
|
||||
|
||||
from homeassistant.components.switch import SwitchEntity
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
@ -108,7 +110,7 @@ class SmappeeActuator(SwitchEntity):
|
|||
"""Icon to use in the frontend."""
|
||||
return ICON
|
||||
|
||||
def turn_on(self, **kwargs):
|
||||
def turn_on(self, **kwargs: Any) -> None:
|
||||
"""Turn on Comport Plug."""
|
||||
if self._actuator_type in ("SWITCH", "COMFORT_PLUG"):
|
||||
self._service_location.set_actuator_state(self._actuator_id, state="ON_ON")
|
||||
|
@ -117,7 +119,7 @@ class SmappeeActuator(SwitchEntity):
|
|||
self._actuator_id, state=self._actuator_state_option
|
||||
)
|
||||
|
||||
def turn_off(self, **kwargs):
|
||||
def turn_off(self, **kwargs: Any) -> None:
|
||||
"""Turn off Comport Plug."""
|
||||
if self._actuator_type in ("SWITCH", "COMFORT_PLUG"):
|
||||
self._service_location.set_actuator_state(
|
||||
|
@ -129,7 +131,7 @@ class SmappeeActuator(SwitchEntity):
|
|||
)
|
||||
|
||||
@property
|
||||
def available(self):
|
||||
def available(self) -> bool:
|
||||
"""Return True if entity is available. Unavailable for COMFORT_PLUGS."""
|
||||
return (
|
||||
self._connection_state == "CONNECTED"
|
||||
|
@ -166,7 +168,7 @@ class SmappeeActuator(SwitchEntity):
|
|||
sw_version=self._service_location.firmware_version,
|
||||
)
|
||||
|
||||
async def async_update(self):
|
||||
async def async_update(self) -> None:
|
||||
"""Get the latest data from Smappee and update the state."""
|
||||
await self._smappee_base.async_update()
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ from __future__ import annotations
|
|||
import asyncio
|
||||
from collections.abc import Iterable, Sequence
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
from pysmartthings import Attribute, Capability
|
||||
|
||||
|
@ -160,7 +161,7 @@ class SmartThingsThermostat(SmartThingsEntity, ClimateEntity):
|
|||
flags |= ClimateEntityFeature.FAN_MODE
|
||||
return flags
|
||||
|
||||
async def async_set_fan_mode(self, fan_mode):
|
||||
async def async_set_fan_mode(self, fan_mode: str) -> None:
|
||||
"""Set new target fan mode."""
|
||||
await self._device.set_thermostat_fan_mode(fan_mode, set_status=True)
|
||||
|
||||
|
@ -177,7 +178,7 @@ class SmartThingsThermostat(SmartThingsEntity, ClimateEntity):
|
|||
# the entity state ahead of receiving the confirming push updates
|
||||
self.async_schedule_update_ha_state(True)
|
||||
|
||||
async def async_set_temperature(self, **kwargs):
|
||||
async def async_set_temperature(self, **kwargs: Any) -> None:
|
||||
"""Set new operation mode and target temperatures."""
|
||||
# Operation state
|
||||
if operation_state := kwargs.get(ATTR_HVAC_MODE):
|
||||
|
@ -214,7 +215,7 @@ class SmartThingsThermostat(SmartThingsEntity, ClimateEntity):
|
|||
# the entity state ahead of receiving the confirming push updates
|
||||
self.async_schedule_update_ha_state(True)
|
||||
|
||||
async def async_update(self):
|
||||
async def async_update(self) -> None:
|
||||
"""Update the attributes of the climate device."""
|
||||
thermostat_mode = self._device.status.thermostat_mode
|
||||
self._hvac_mode = MODE_TO_STATE.get(thermostat_mode)
|
||||
|
@ -326,7 +327,7 @@ class SmartThingsAirConditioner(SmartThingsEntity, ClimateEntity):
|
|||
super().__init__(device)
|
||||
self._hvac_modes = None
|
||||
|
||||
async def async_set_fan_mode(self, fan_mode):
|
||||
async def async_set_fan_mode(self, fan_mode: str) -> None:
|
||||
"""Set new target fan mode."""
|
||||
await self._device.set_fan_mode(fan_mode, set_status=True)
|
||||
# State is set optimistically in the command above, therefore update
|
||||
|
@ -352,7 +353,7 @@ class SmartThingsAirConditioner(SmartThingsEntity, ClimateEntity):
|
|||
# the entity state ahead of receiving the confirming push updates
|
||||
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."""
|
||||
tasks = []
|
||||
# operation mode
|
||||
|
@ -372,21 +373,21 @@ class SmartThingsAirConditioner(SmartThingsEntity, ClimateEntity):
|
|||
# the entity state ahead of receiving the confirming push updates
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_turn_on(self):
|
||||
async def async_turn_on(self) -> None:
|
||||
"""Turn device on."""
|
||||
await self._device.switch_on(set_status=True)
|
||||
# State is set optimistically in the command above, therefore update
|
||||
# the entity state ahead of receiving the confirming push updates
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_turn_off(self):
|
||||
async def async_turn_off(self) -> None:
|
||||
"""Turn device off."""
|
||||
await self._device.switch_off(set_status=True)
|
||||
# State is set optimistically in the command above, therefore update
|
||||
# the entity state ahead of receiving the confirming push updates
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_update(self):
|
||||
async def async_update(self) -> None:
|
||||
"""Update the calculated fields of the AC."""
|
||||
modes = {HVACMode.OFF}
|
||||
for mode in self._device.status.supported_ac_modes:
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Sequence
|
||||
from typing import Any
|
||||
|
||||
from pysmartthings import Capability
|
||||
|
||||
|
@ -41,14 +42,14 @@ def get_capabilities(capabilities: Sequence[str]) -> Sequence[str] | None:
|
|||
class SmartThingsSwitch(SmartThingsEntity, SwitchEntity):
|
||||
"""Define a SmartThings switch."""
|
||||
|
||||
async def async_turn_off(self, **kwargs) -> None:
|
||||
async def async_turn_off(self, **kwargs: Any) -> None:
|
||||
"""Turn the switch off."""
|
||||
await self._device.switch_off(set_status=True)
|
||||
# State is set optimistically in the command above, therefore update
|
||||
# the entity state ahead of receiving the confirming push updates
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_turn_on(self, **kwargs) -> None:
|
||||
async def async_turn_on(self, **kwargs: Any) -> None:
|
||||
"""Turn the switch on."""
|
||||
await self._device.switch_on(set_status=True)
|
||||
# State is set optimistically in the command above, therefore update
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
"""Platform for climate integration."""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from smarttub import Spa
|
||||
|
||||
from homeassistant.components.climate import ClimateEntity
|
||||
|
@ -72,7 +74,7 @@ class SmartTubThermostat(SmartTubEntity, ClimateEntity):
|
|||
"""Return the current running hvac operation."""
|
||||
return HVAC_ACTIONS.get(self.spa_status.heater)
|
||||
|
||||
async def async_set_hvac_mode(self, hvac_mode: HVACMode):
|
||||
async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None:
|
||||
"""Set new target hvac mode.
|
||||
|
||||
As with hvac_mode, we don't really have an option here.
|
||||
|
@ -113,13 +115,13 @@ class SmartTubThermostat(SmartTubEntity, ClimateEntity):
|
|||
"""Return the target water temperature."""
|
||||
return self.spa_status.set_temperature
|
||||
|
||||
async def async_set_temperature(self, **kwargs):
|
||||
async def async_set_temperature(self, **kwargs: Any) -> None:
|
||||
"""Set new target temperature."""
|
||||
temperature = kwargs[ATTR_TEMPERATURE]
|
||||
await self.spa.set_temperature(temperature)
|
||||
await self.coordinator.async_refresh()
|
||||
|
||||
async def async_set_preset_mode(self, preset_mode: str):
|
||||
async def async_set_preset_mode(self, preset_mode: str) -> None:
|
||||
"""Activate the specified preset mode."""
|
||||
heat_mode = HEAT_MODES[preset_mode]
|
||||
await self.spa.set_heat_mode(heat_mode)
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
"""Platform for switch integration."""
|
||||
from typing import Any
|
||||
|
||||
import async_timeout
|
||||
from smarttub import SpaPump
|
||||
|
||||
|
@ -62,21 +64,21 @@ class SmartTubPump(SmartTubEntity, SwitchEntity):
|
|||
"""Return True if the pump is on."""
|
||||
return self.pump.state != SpaPump.PumpState.OFF
|
||||
|
||||
async def async_turn_on(self, **kwargs) -> None:
|
||||
async def async_turn_on(self, **kwargs: Any) -> None:
|
||||
"""Turn the pump on."""
|
||||
|
||||
# the API only supports toggling
|
||||
if not self.is_on:
|
||||
await self.async_toggle()
|
||||
|
||||
async def async_turn_off(self, **kwargs) -> None:
|
||||
async def async_turn_off(self, **kwargs: Any) -> None:
|
||||
"""Turn the pump off."""
|
||||
|
||||
# the API only supports toggling
|
||||
if self.is_on:
|
||||
await self.async_toggle()
|
||||
|
||||
async def async_toggle(self, **kwargs) -> None:
|
||||
async def async_toggle(self, **kwargs: Any) -> None:
|
||||
"""Toggle the pump on or off."""
|
||||
async with async_timeout.timeout(API_TIMEOUT):
|
||||
await self.pump.toggle()
|
||||
|
|
|
@ -181,19 +181,19 @@ class SnapcastGroupDevice(MediaPlayerEntity):
|
|||
name = f"{self._group.friendly_name} {GROUP_SUFFIX}"
|
||||
return {"friendly_name": name}
|
||||
|
||||
async def async_select_source(self, source):
|
||||
async def async_select_source(self, source: str) -> None:
|
||||
"""Set input source."""
|
||||
streams = self._group.streams_by_name()
|
||||
if source in streams:
|
||||
await self._group.set_stream(streams[source].identifier)
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_mute_volume(self, mute):
|
||||
async def async_mute_volume(self, mute: bool) -> None:
|
||||
"""Send the mute command."""
|
||||
await self._group.set_muted(mute)
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_set_volume_level(self, volume):
|
||||
async def async_set_volume_level(self, volume: float) -> None:
|
||||
"""Set the volume level."""
|
||||
await self._group.set_volume(round(volume * 100))
|
||||
self.async_write_ha_state()
|
||||
|
@ -292,19 +292,19 @@ class SnapcastClientDevice(MediaPlayerEntity):
|
|||
"""Latency for Client."""
|
||||
return self._client.latency
|
||||
|
||||
async def async_select_source(self, source):
|
||||
async def async_select_source(self, source: str) -> None:
|
||||
"""Set input source."""
|
||||
streams = self._client.group.streams_by_name()
|
||||
if source in streams:
|
||||
await self._client.group.set_stream(streams[source].identifier)
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_mute_volume(self, mute):
|
||||
async def async_mute_volume(self, mute: bool) -> None:
|
||||
"""Send the mute command."""
|
||||
await self._client.set_muted(mute)
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_set_volume_level(self, volume):
|
||||
async def async_set_volume_level(self, volume: float) -> None:
|
||||
"""Set the volume level."""
|
||||
await self._client.set_volume(round(volume * 100))
|
||||
self.async_write_ha_state()
|
||||
|
|
|
@ -166,7 +166,7 @@ class SnmpSensor(TemplateSensor):
|
|||
"""Return the state of the sensor."""
|
||||
return self._state
|
||||
|
||||
async def async_update(self):
|
||||
async def async_update(self) -> None:
|
||||
"""Get the latest data and updates the states."""
|
||||
await self.data.async_update()
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
import pysnmp.hlapi.asyncio as hlapi
|
||||
from pysnmp.hlapi.asyncio import (
|
||||
|
@ -235,12 +236,12 @@ class SnmpSwitch(SwitchEntity):
|
|||
ContextData(),
|
||||
]
|
||||
|
||||
async def async_turn_on(self, **kwargs):
|
||||
async def async_turn_on(self, **kwargs: Any) -> None:
|
||||
"""Turn on the switch."""
|
||||
# If vartype set, use it - http://snmplabs.com/pysnmp/docs/api-reference.html#pysnmp.smi.rfc1902.ObjectType
|
||||
await self._execute_command(self._command_payload_on)
|
||||
|
||||
async def async_turn_off(self, **kwargs):
|
||||
async def async_turn_off(self, **kwargs: Any) -> None:
|
||||
"""Turn off the switch."""
|
||||
await self._execute_command(self._command_payload_off)
|
||||
|
||||
|
@ -256,7 +257,7 @@ class SnmpSwitch(SwitchEntity):
|
|||
else:
|
||||
await self._set(MAP_SNMP_VARTYPES.get(self._vartype, Integer)(command))
|
||||
|
||||
async def async_update(self):
|
||||
async def async_update(self) -> None:
|
||||
"""Update the state."""
|
||||
errindication, errstatus, errindex, restable = await getCmd(
|
||||
*self._request_args, ObjectType(ObjectIdentity(self._baseoid))
|
||||
|
|
Loading…
Reference in New Issue