mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 17:27:10 +00:00
Improve entity type hints [h] (#77468)
This commit is contained in:
parent
05264cedfa
commit
a1374963d1
@ -154,7 +154,7 @@ class HabitipySensor(SensorEntity):
|
||||
self._state = None
|
||||
self._updater = updater
|
||||
|
||||
async def async_update(self):
|
||||
async def async_update(self) -> None:
|
||||
"""Update Condition and Forecast."""
|
||||
await self._updater.update()
|
||||
data = self._updater.data
|
||||
@ -194,7 +194,7 @@ class HabitipyTaskSensor(SensorEntity):
|
||||
self._state = None
|
||||
self._updater = updater
|
||||
|
||||
async def async_update(self):
|
||||
async def async_update(self) -> None:
|
||||
"""Update Condition and Forecast."""
|
||||
await self._updater.update()
|
||||
all_tasks = self._updater.tasks
|
||||
|
@ -69,7 +69,7 @@ class HkAvrDevice(MediaPlayerEntity):
|
||||
self._muted = avr.muted
|
||||
self._current_source = avr.current_source
|
||||
|
||||
def update(self):
|
||||
def update(self) -> None:
|
||||
"""Update the state of this media_player."""
|
||||
if self._avr.is_on():
|
||||
self._state = STATE_ON
|
||||
@ -106,26 +106,26 @@ class HkAvrDevice(MediaPlayerEntity):
|
||||
"""Available sources."""
|
||||
return self._source_list
|
||||
|
||||
def turn_on(self):
|
||||
def turn_on(self) -> None:
|
||||
"""Turn the AVR on."""
|
||||
self._avr.power_on()
|
||||
|
||||
def turn_off(self):
|
||||
def turn_off(self) -> None:
|
||||
"""Turn off the AVR."""
|
||||
self._avr.power_off()
|
||||
|
||||
def select_source(self, source):
|
||||
def select_source(self, source: str) -> None:
|
||||
"""Select input source."""
|
||||
return self._avr.select_source(source)
|
||||
|
||||
def volume_up(self):
|
||||
def volume_up(self) -> None:
|
||||
"""Volume up the AVR."""
|
||||
return self._avr.volume_up()
|
||||
|
||||
def volume_down(self):
|
||||
def volume_down(self) -> None:
|
||||
"""Volume down AVR."""
|
||||
return self._avr.volume_down()
|
||||
|
||||
def mute_volume(self, mute):
|
||||
def mute_volume(self, mute: bool) -> None:
|
||||
"""Send mute command."""
|
||||
return self._avr.mute(mute)
|
||||
|
@ -1,6 +1,8 @@
|
||||
"""Support for Harmony Hub devices."""
|
||||
from collections.abc import Iterable
|
||||
import json
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
@ -124,7 +126,7 @@ class HarmonyRemote(HarmonyEntity, RemoteEntity, RestoreEntity):
|
||||
self._activity_starting = None
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
async def async_added_to_hass(self) -> None:
|
||||
"""Complete the initialization."""
|
||||
await super().async_added_to_hass()
|
||||
|
||||
@ -205,7 +207,7 @@ class HarmonyRemote(HarmonyEntity, RemoteEntity, RestoreEntity):
|
||||
self.async_new_activity(self._data.current_activity)
|
||||
await self.hass.async_add_executor_job(self.write_config_file)
|
||||
|
||||
async def async_turn_on(self, **kwargs):
|
||||
async def async_turn_on(self, **kwargs: Any) -> None:
|
||||
"""Start an activity from the Harmony device."""
|
||||
_LOGGER.debug("%s: Turn On", self.name)
|
||||
|
||||
@ -223,11 +225,11 @@ class HarmonyRemote(HarmonyEntity, RemoteEntity, RestoreEntity):
|
||||
else:
|
||||
_LOGGER.error("%s: No activity specified with turn_on service", self.name)
|
||||
|
||||
async def async_turn_off(self, **kwargs):
|
||||
async def async_turn_off(self, **kwargs: Any) -> None:
|
||||
"""Start the PowerOff activity."""
|
||||
await self._data.async_power_off()
|
||||
|
||||
async def async_send_command(self, command, **kwargs):
|
||||
async def async_send_command(self, command: Iterable[str], **kwargs: Any) -> None:
|
||||
"""Send a list of commands to one device."""
|
||||
_LOGGER.debug("%s: Send Command", self.name)
|
||||
if (device := kwargs.get(ATTR_DEVICE)) is None:
|
||||
|
@ -1,5 +1,6 @@
|
||||
"""Support for Harmony Hub activities."""
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
from homeassistant.components.switch import SwitchEntity
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
@ -50,11 +51,11 @@ class HarmonyActivitySwitch(HarmonyEntity, SwitchEntity):
|
||||
_, activity_name = self._data.current_activity
|
||||
return activity_name == self._activity_name
|
||||
|
||||
async def async_turn_on(self, **kwargs):
|
||||
async def async_turn_on(self, **kwargs: Any) -> None:
|
||||
"""Start this activity."""
|
||||
await self._data.async_start_activity(self._activity_name)
|
||||
|
||||
async def async_turn_off(self, **kwargs):
|
||||
async def async_turn_off(self, **kwargs: Any) -> None:
|
||||
"""Stop this activity."""
|
||||
await self._data.async_power_off()
|
||||
|
||||
|
@ -101,7 +101,7 @@ class SupervisorAddonUpdateEntity(HassioAddonEntity, UpdateEntity):
|
||||
return self.coordinator.data[DATA_KEY_ADDONS][self._addon_slug]
|
||||
|
||||
@property
|
||||
def auto_update(self):
|
||||
def auto_update(self) -> bool:
|
||||
"""Return true if auto-update is enabled for the add-on."""
|
||||
return self._addon_data[ATTR_AUTO_UPDATE]
|
||||
|
||||
@ -159,7 +159,7 @@ class SupervisorAddonUpdateEntity(HassioAddonEntity, UpdateEntity):
|
||||
async def async_install(
|
||||
self,
|
||||
version: str | None = None,
|
||||
backup: bool | None = False,
|
||||
backup: bool = False,
|
||||
**kwargs: Any,
|
||||
) -> None:
|
||||
"""Install an update."""
|
||||
|
@ -100,7 +100,7 @@ class HaveIBeenPwnedSensor(SensorEntity):
|
||||
|
||||
return val
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
async def async_added_to_hass(self) -> None:
|
||||
"""Get initial data."""
|
||||
# To make sure we get initial data for the sensors ignoring the normal
|
||||
# throttle of 15 minutes but using an update throttle of 5 seconds
|
||||
@ -126,7 +126,7 @@ class HaveIBeenPwnedSensor(SensorEntity):
|
||||
self._state = len(self._data.data[self._email])
|
||||
self.schedule_update_ha_state()
|
||||
|
||||
def update(self):
|
||||
def update(self) -> None:
|
||||
"""Update data and see if it contains data for our email."""
|
||||
self._data.update()
|
||||
|
||||
|
@ -91,7 +91,7 @@ class HddTempSensor(SensorEntity):
|
||||
if self._details is not None:
|
||||
return {ATTR_DEVICE: self._details[0], ATTR_MODEL: self._details[1]}
|
||||
|
||||
def update(self):
|
||||
def update(self) -> None:
|
||||
"""Get the latest data from HDDTemp daemon and updates the state."""
|
||||
self.hddtemp.update()
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
from pycec.commands import CecCommand, KeyPressCommand, KeyReleaseCommand
|
||||
from pycec.const import (
|
||||
@ -83,69 +84,69 @@ class CecPlayerEntity(CecEntity, MediaPlayerEntity):
|
||||
"""Send playback status to CEC adapter."""
|
||||
self._device.async_send_command(CecCommand(key, dst=self._logical_address))
|
||||
|
||||
def mute_volume(self, mute):
|
||||
def mute_volume(self, mute: bool) -> None:
|
||||
"""Mute volume."""
|
||||
self.send_keypress(KEY_MUTE_TOGGLE)
|
||||
|
||||
def media_previous_track(self):
|
||||
def media_previous_track(self) -> None:
|
||||
"""Go to previous track."""
|
||||
self.send_keypress(KEY_BACKWARD)
|
||||
|
||||
def turn_on(self):
|
||||
def turn_on(self) -> None:
|
||||
"""Turn device on."""
|
||||
self._device.turn_on()
|
||||
self._state = STATE_ON
|
||||
|
||||
def clear_playlist(self):
|
||||
def clear_playlist(self) -> None:
|
||||
"""Clear players playlist."""
|
||||
raise NotImplementedError()
|
||||
|
||||
def turn_off(self):
|
||||
def turn_off(self) -> None:
|
||||
"""Turn device off."""
|
||||
self._device.turn_off()
|
||||
self._state = STATE_OFF
|
||||
|
||||
def media_stop(self):
|
||||
def media_stop(self) -> None:
|
||||
"""Stop playback."""
|
||||
self.send_keypress(KEY_STOP)
|
||||
self._state = STATE_IDLE
|
||||
|
||||
def play_media(self, media_type, media_id, **kwargs):
|
||||
def play_media(self, media_type: str, media_id: str, **kwargs: Any) -> None:
|
||||
"""Not supported."""
|
||||
raise NotImplementedError()
|
||||
|
||||
def media_next_track(self):
|
||||
def media_next_track(self) -> None:
|
||||
"""Skip to next track."""
|
||||
self.send_keypress(KEY_FORWARD)
|
||||
|
||||
def media_seek(self, position):
|
||||
def media_seek(self, position: float) -> None:
|
||||
"""Not supported."""
|
||||
raise NotImplementedError()
|
||||
|
||||
def set_volume_level(self, volume):
|
||||
def set_volume_level(self, volume: float) -> None:
|
||||
"""Set volume level, range 0..1."""
|
||||
raise NotImplementedError()
|
||||
|
||||
def media_pause(self):
|
||||
def media_pause(self) -> None:
|
||||
"""Pause playback."""
|
||||
self.send_keypress(KEY_PAUSE)
|
||||
self._state = STATE_PAUSED
|
||||
|
||||
def select_source(self, source):
|
||||
def select_source(self, source: str) -> None:
|
||||
"""Not supported."""
|
||||
raise NotImplementedError()
|
||||
|
||||
def media_play(self):
|
||||
def media_play(self) -> None:
|
||||
"""Start playback."""
|
||||
self.send_keypress(KEY_PLAY)
|
||||
self._state = STATE_PLAYING
|
||||
|
||||
def volume_up(self):
|
||||
def volume_up(self) -> None:
|
||||
"""Increase volume."""
|
||||
_LOGGER.debug("%s: volume up", self._logical_address)
|
||||
self.send_keypress(KEY_VOLUME_UP)
|
||||
|
||||
def volume_down(self):
|
||||
def volume_down(self) -> None:
|
||||
"""Decrease volume."""
|
||||
_LOGGER.debug("%s: volume down", self._logical_address)
|
||||
self.send_keypress(KEY_VOLUME_DOWN)
|
||||
@ -155,7 +156,7 @@ class CecPlayerEntity(CecEntity, MediaPlayerEntity):
|
||||
"""Cache state of device."""
|
||||
return self._state
|
||||
|
||||
def update(self):
|
||||
def update(self) -> None:
|
||||
"""Update device status."""
|
||||
device = self._device
|
||||
if device.power_status in [POWER_OFF, 3]:
|
||||
|
@ -2,6 +2,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN, SwitchEntity
|
||||
from homeassistant.const import STATE_OFF, STATE_ON
|
||||
@ -40,13 +41,13 @@ class CecSwitchEntity(CecEntity, SwitchEntity):
|
||||
CecEntity.__init__(self, device, logical)
|
||||
self.entity_id = f"{SWITCH_DOMAIN}.hdmi_{hex(self._logical_address)[2:]}"
|
||||
|
||||
def turn_on(self, **kwargs) -> None:
|
||||
def turn_on(self, **kwargs: Any) -> None:
|
||||
"""Turn device on."""
|
||||
self._device.turn_on()
|
||||
self._state = STATE_ON
|
||||
self.schedule_update_ha_state(force_refresh=False)
|
||||
|
||||
def turn_off(self, **kwargs) -> None:
|
||||
def turn_off(self, **kwargs: Any) -> None:
|
||||
"""Turn device off."""
|
||||
self._device.turn_off()
|
||||
self._state = STATE_OFF
|
||||
|
@ -112,7 +112,7 @@ class HeatmiserV3Thermostat(ClimateEntity):
|
||||
self._target_temperature = int(temperature)
|
||||
self.therm.set_target_temp(self._target_temperature)
|
||||
|
||||
def update(self):
|
||||
def update(self) -> None:
|
||||
"""Get the latest data."""
|
||||
self.uh1.reopen()
|
||||
if not self.uh1.status:
|
||||
|
@ -17,6 +17,7 @@ from homeassistant.components.media_player import (
|
||||
MediaPlayerEntityFeature,
|
||||
)
|
||||
from homeassistant.components.media_player.browse_media import (
|
||||
BrowseMedia,
|
||||
async_process_play_media_url,
|
||||
)
|
||||
from homeassistant.components.media_player.const import (
|
||||
@ -136,11 +137,11 @@ class HeosMediaPlayer(MediaPlayerEntity):
|
||||
self._media_position_updated_at = utcnow()
|
||||
await self.async_update_ha_state(True)
|
||||
|
||||
async def _heos_updated(self):
|
||||
async def _heos_updated(self) -> None:
|
||||
"""Handle sources changed."""
|
||||
await self.async_update_ha_state(True)
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
async def async_added_to_hass(self) -> None:
|
||||
"""Device added to hass."""
|
||||
# Update state when attributes of the player change
|
||||
self._signals.append(
|
||||
@ -159,7 +160,7 @@ class HeosMediaPlayer(MediaPlayerEntity):
|
||||
async_dispatcher_send(self.hass, SIGNAL_HEOS_PLAYER_ADDED)
|
||||
|
||||
@log_command_error("clear playlist")
|
||||
async def async_clear_playlist(self):
|
||||
async def async_clear_playlist(self) -> None:
|
||||
"""Clear players playlist."""
|
||||
await self._player.clear_queue()
|
||||
|
||||
@ -169,37 +170,39 @@ class HeosMediaPlayer(MediaPlayerEntity):
|
||||
await self._group_manager.async_join_players(self.entity_id, group_members)
|
||||
|
||||
@log_command_error("pause")
|
||||
async def async_media_pause(self):
|
||||
async def async_media_pause(self) -> None:
|
||||
"""Send pause command."""
|
||||
await self._player.pause()
|
||||
|
||||
@log_command_error("play")
|
||||
async def async_media_play(self):
|
||||
async def async_media_play(self) -> None:
|
||||
"""Send play command."""
|
||||
await self._player.play()
|
||||
|
||||
@log_command_error("move to previous track")
|
||||
async def async_media_previous_track(self):
|
||||
async def async_media_previous_track(self) -> None:
|
||||
"""Send previous track command."""
|
||||
await self._player.play_previous()
|
||||
|
||||
@log_command_error("move to next track")
|
||||
async def async_media_next_track(self):
|
||||
async def async_media_next_track(self) -> None:
|
||||
"""Send next track command."""
|
||||
await self._player.play_next()
|
||||
|
||||
@log_command_error("stop")
|
||||
async def async_media_stop(self):
|
||||
async def async_media_stop(self) -> None:
|
||||
"""Send stop command."""
|
||||
await self._player.stop()
|
||||
|
||||
@log_command_error("set mute")
|
||||
async def async_mute_volume(self, mute):
|
||||
async def async_mute_volume(self, mute: bool) -> None:
|
||||
"""Mute the volume."""
|
||||
await self._player.set_mute(mute)
|
||||
|
||||
@log_command_error("play media")
|
||||
async def async_play_media(self, media_type, media_id, **kwargs):
|
||||
async def async_play_media(
|
||||
self, media_type: str, media_id: str, **kwargs: Any
|
||||
) -> None:
|
||||
"""Play a piece of media."""
|
||||
if media_source.is_media_source_id(media_id):
|
||||
media_type = MEDIA_TYPE_URL
|
||||
@ -218,7 +221,7 @@ class HeosMediaPlayer(MediaPlayerEntity):
|
||||
# media_id may be an int or a str
|
||||
selects = await self._player.get_quick_selects()
|
||||
try:
|
||||
index = int(media_id)
|
||||
index: int | None = int(media_id)
|
||||
except ValueError:
|
||||
# Try finding index by name
|
||||
index = next(
|
||||
@ -262,21 +265,21 @@ class HeosMediaPlayer(MediaPlayerEntity):
|
||||
raise ValueError(f"Unsupported media type '{media_type}'")
|
||||
|
||||
@log_command_error("select source")
|
||||
async def async_select_source(self, source):
|
||||
async def async_select_source(self, source: str) -> None:
|
||||
"""Select input source."""
|
||||
await self._source_manager.play_source(source, self._player)
|
||||
|
||||
@log_command_error("set shuffle")
|
||||
async def async_set_shuffle(self, shuffle):
|
||||
async def async_set_shuffle(self, shuffle: bool) -> None:
|
||||
"""Enable/disable shuffle mode."""
|
||||
await self._player.set_play_mode(self._player.repeat, shuffle)
|
||||
|
||||
@log_command_error("set volume level")
|
||||
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._player.set_volume(int(volume * 100))
|
||||
|
||||
async def async_update(self):
|
||||
async def async_update(self) -> None:
|
||||
"""Update supported features of the player."""
|
||||
controls = self._player.now_playing_media.supported_controls
|
||||
current_support = [CONTROL_TO_SUPPORT[control] for control in controls]
|
||||
@ -291,11 +294,11 @@ class HeosMediaPlayer(MediaPlayerEntity):
|
||||
self._source_manager = self.hass.data[HEOS_DOMAIN][DATA_SOURCE_MANAGER]
|
||||
|
||||
@log_command_error("unjoin_player")
|
||||
async def async_unjoin_player(self):
|
||||
async def async_unjoin_player(self) -> None:
|
||||
"""Remove this player from any group."""
|
||||
await self._group_manager.async_unjoin_player(self.entity_id)
|
||||
|
||||
async def async_will_remove_from_hass(self):
|
||||
async def async_will_remove_from_hass(self) -> None:
|
||||
"""Disconnect the device when removed."""
|
||||
for signal_remove in self._signals:
|
||||
signal_remove()
|
||||
@ -318,7 +321,7 @@ class HeosMediaPlayer(MediaPlayerEntity):
|
||||
)
|
||||
|
||||
@property
|
||||
def extra_state_attributes(self) -> dict:
|
||||
def extra_state_attributes(self) -> dict[str, Any]:
|
||||
"""Get additional attribute about the state."""
|
||||
return {
|
||||
"media_album_id": self._player.now_playing_media.album_id,
|
||||
@ -434,7 +437,9 @@ class HeosMediaPlayer(MediaPlayerEntity):
|
||||
"""Volume level of the media player (0..1)."""
|
||||
return self._player.volume / 100
|
||||
|
||||
async def async_browse_media(self, media_content_type=None, media_content_id=None):
|
||||
async def async_browse_media(
|
||||
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(
|
||||
self.hass,
|
||||
|
@ -2,6 +2,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
import hikvision.api
|
||||
from hikvision.error import HikvisionError, MissingParamError
|
||||
@ -88,17 +89,17 @@ class HikvisionMotionSwitch(SwitchEntity):
|
||||
"""Return true if device is on."""
|
||||
return self._state == STATE_ON
|
||||
|
||||
def turn_on(self, **kwargs):
|
||||
def turn_on(self, **kwargs: Any) -> None:
|
||||
"""Turn the device on."""
|
||||
_LOGGING.info("Turning on Motion Detection ")
|
||||
self._hikvision_cam.enable_motion_detection()
|
||||
|
||||
def turn_off(self, **kwargs):
|
||||
def turn_off(self, **kwargs: Any) -> None:
|
||||
"""Turn the device off."""
|
||||
_LOGGING.info("Turning off Motion Detection ")
|
||||
self._hikvision_cam.disable_motion_detection()
|
||||
|
||||
def update(self):
|
||||
def update(self) -> None:
|
||||
"""Update Motion Detection state."""
|
||||
enabled = self._hikvision_cam.is_motion_detection_enabled()
|
||||
_LOGGING.info("enabled: %s", enabled)
|
||||
|
@ -2,6 +2,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
from pyaehw4a1.aehw4a1 import AehW4a1
|
||||
import pyaehw4a1.exceptions
|
||||
@ -168,7 +169,7 @@ class ClimateAehW4a1(ClimateEntity):
|
||||
self._preset_mode = None
|
||||
self._previous_state = None
|
||||
|
||||
async def async_update(self):
|
||||
async def async_update(self) -> None:
|
||||
"""Pull state from AEH-W4A1."""
|
||||
try:
|
||||
status = await self._device.command("status_102_0")
|
||||
@ -300,7 +301,7 @@ class ClimateAehW4a1(ClimateEntity):
|
||||
"""Return the supported step of target temperature."""
|
||||
return 1
|
||||
|
||||
async def async_set_temperature(self, **kwargs):
|
||||
async def async_set_temperature(self, **kwargs: Any) -> None:
|
||||
"""Set new target temperatures."""
|
||||
if self._on != "1":
|
||||
_LOGGER.warning(
|
||||
@ -316,7 +317,7 @@ class ClimateAehW4a1(ClimateEntity):
|
||||
else:
|
||||
await self._device.command(f"temp_{int(temp)}_F")
|
||||
|
||||
async def async_set_fan_mode(self, fan_mode):
|
||||
async def async_set_fan_mode(self, fan_mode: str) -> None:
|
||||
"""Set new fan mode."""
|
||||
if self._on != "1":
|
||||
_LOGGER.warning("AC at %s is off, could not set fan mode", self._unique_id)
|
||||
@ -327,7 +328,7 @@ class ClimateAehW4a1(ClimateEntity):
|
||||
_LOGGER.debug("Setting fan mode of %s to %s", self._unique_id, fan_mode)
|
||||
await self._device.command(HA_FAN_MODES_TO_AC[fan_mode])
|
||||
|
||||
async def async_set_swing_mode(self, swing_mode):
|
||||
async def async_set_swing_mode(self, swing_mode: str) -> None:
|
||||
"""Set new target swing operation."""
|
||||
if self._on != "1":
|
||||
_LOGGER.warning(
|
||||
@ -362,7 +363,7 @@ class ClimateAehW4a1(ClimateEntity):
|
||||
if swing_act in (SWING_OFF, SWING_VERTICAL):
|
||||
await self._device.command("hor_swing")
|
||||
|
||||
async def async_set_preset_mode(self, preset_mode):
|
||||
async def async_set_preset_mode(self, preset_mode: str) -> None:
|
||||
"""Set new preset mode."""
|
||||
if self._on != "1":
|
||||
if preset_mode == PRESET_NONE:
|
||||
@ -408,12 +409,12 @@ class ClimateAehW4a1(ClimateEntity):
|
||||
if self._on != "1":
|
||||
await self.async_turn_on()
|
||||
|
||||
async def async_turn_on(self):
|
||||
async def async_turn_on(self) -> None:
|
||||
"""Turn on."""
|
||||
_LOGGER.debug("Turning %s on", self._unique_id)
|
||||
await self._device.command("on")
|
||||
|
||||
async def async_turn_off(self):
|
||||
async def async_turn_off(self) -> None:
|
||||
"""Turn off."""
|
||||
_LOGGER.debug("Turning %s off", self._unique_id)
|
||||
await self._device.command("off")
|
||||
|
@ -65,7 +65,7 @@ class HiveAlarmControlPanelEntity(HiveEntity, AlarmControlPanelEntity):
|
||||
"""Send arm away command."""
|
||||
await self.hive.alarm.setMode(self.device, "away")
|
||||
|
||||
async def async_alarm_trigger(self, code=None) -> None:
|
||||
async def async_alarm_trigger(self, code: str | None = None) -> None:
|
||||
"""Send alarm trigger command."""
|
||||
await self.hive.alarm.setMode(self.device, "sos")
|
||||
|
||||
|
@ -68,7 +68,7 @@ class HiveBinarySensorEntity(HiveEntity, BinarySensorEntity):
|
||||
super().__init__(hive, hive_device)
|
||||
self.entity_description = entity_description
|
||||
|
||||
async def async_update(self):
|
||||
async def async_update(self) -> None:
|
||||
"""Update all Node data from Hive."""
|
||||
await self.hive.session.updateData(self.device)
|
||||
self.device = await self.hive.sensor.getSensor(self.device)
|
||||
|
@ -1,6 +1,7 @@
|
||||
"""Support for the Hive climate devices."""
|
||||
from datetime import timedelta
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
@ -120,7 +121,7 @@ class HiveClimateEntity(HiveEntity, ClimateEntity):
|
||||
await self.hive.heating.setMode(self.device, new_mode)
|
||||
|
||||
@refresh_system
|
||||
async def async_set_temperature(self, **kwargs):
|
||||
async def async_set_temperature(self, **kwargs: Any) -> None:
|
||||
"""Set new target temperature."""
|
||||
new_temperature = kwargs.get(ATTR_TEMPERATURE)
|
||||
if new_temperature is not None:
|
||||
@ -153,7 +154,7 @@ class HiveClimateEntity(HiveEntity, ClimateEntity):
|
||||
"""Handle boost heating service call."""
|
||||
await self.hive.heating.setBoostOff(self.device)
|
||||
|
||||
async def async_update(self):
|
||||
async def async_update(self) -> None:
|
||||
"""Update all Node data from Hive."""
|
||||
await self.hive.session.updateData(self.device)
|
||||
self.device = await self.hive.heating.getClimate(self.device)
|
||||
|
@ -59,7 +59,7 @@ class HiveSensorEntity(HiveEntity, SensorEntity):
|
||||
super().__init__(hive, hive_device)
|
||||
self.entity_description = entity_description
|
||||
|
||||
async def async_update(self):
|
||||
async def async_update(self) -> None:
|
||||
"""Update all Node data from Hive."""
|
||||
await self.hive.session.updateData(self.device)
|
||||
self.device = await self.hive.sensor.getSensor(self.device)
|
||||
|
@ -2,6 +2,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import timedelta
|
||||
from typing import Any
|
||||
|
||||
from homeassistant.components.switch import SwitchEntity, SwitchEntityDescription
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
@ -52,16 +53,16 @@ class HiveSwitch(HiveEntity, SwitchEntity):
|
||||
self.entity_description = entity_description
|
||||
|
||||
@refresh_system
|
||||
async def async_turn_on(self, **kwargs):
|
||||
async def async_turn_on(self, **kwargs: Any) -> None:
|
||||
"""Turn the switch on."""
|
||||
await self.hive.switch.turnOn(self.device)
|
||||
|
||||
@refresh_system
|
||||
async def async_turn_off(self, **kwargs):
|
||||
async def async_turn_off(self, **kwargs: Any) -> None:
|
||||
"""Turn the device off."""
|
||||
await self.hive.switch.turnOff(self.device)
|
||||
|
||||
async def async_update(self):
|
||||
async def async_update(self) -> None:
|
||||
"""Update all Node data from Hive."""
|
||||
await self.hive.session.updateData(self.device)
|
||||
self.device = await self.hive.switch.getSwitch(self.device)
|
||||
|
@ -88,7 +88,7 @@ class HiveWaterHeater(HiveEntity, WaterHeaterEntity):
|
||||
await self.hive.hotwater.setMode(self.device, "OFF")
|
||||
|
||||
@refresh_system
|
||||
async def async_set_operation_mode(self, operation_mode):
|
||||
async def async_set_operation_mode(self, operation_mode: str) -> None:
|
||||
"""Set operation mode."""
|
||||
new_mode = HASS_TO_HIVE_STATE[operation_mode]
|
||||
await self.hive.hotwater.setMode(self.device, new_mode)
|
||||
@ -101,7 +101,7 @@ class HiveWaterHeater(HiveEntity, WaterHeaterEntity):
|
||||
elif on_off == "off":
|
||||
await self.hive.hotwater.setBoostOff(self.device)
|
||||
|
||||
async def async_update(self):
|
||||
async def async_update(self) -> None:
|
||||
"""Update all Node data from Hive."""
|
||||
await self.hive.session.updateData(self.device)
|
||||
self.device = await self.hive.hotwater.getWaterHeater(self.device)
|
||||
|
@ -1,4 +1,6 @@
|
||||
"""Support for HLK-SW16 switches."""
|
||||
from typing import Any
|
||||
|
||||
from homeassistant.components.switch import SwitchEntity
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
@ -36,10 +38,10 @@ class SW16Switch(SW16Device, SwitchEntity):
|
||||
"""Return true if device is on."""
|
||||
return self._is_on
|
||||
|
||||
async def async_turn_on(self, **kwargs):
|
||||
async def async_turn_on(self, **kwargs: Any) -> None:
|
||||
"""Turn the device on."""
|
||||
await self._client.turn_on(self._device_port)
|
||||
|
||||
async def async_turn_off(self, **kwargs):
|
||||
async def async_turn_off(self, **kwargs: Any) -> None:
|
||||
"""Turn the device off."""
|
||||
await self._client.turn_off(self._device_port)
|
||||
|
@ -72,7 +72,7 @@ class HomeConnectBinarySensor(HomeConnectEntity, BinarySensorEntity):
|
||||
"""Return true if the binary sensor is available."""
|
||||
return self._state is not None
|
||||
|
||||
async def async_update(self):
|
||||
async def async_update(self) -> None:
|
||||
"""Update the binary sensor's status."""
|
||||
state = self.device.appliance.status.get(self._update_key, {})
|
||||
if not state:
|
||||
|
@ -1,6 +1,7 @@
|
||||
"""Provides a light for Home Connect."""
|
||||
import logging
|
||||
from math import ceil
|
||||
from typing import Any
|
||||
|
||||
from homeconnect.api import HomeConnectError
|
||||
|
||||
@ -153,7 +154,7 @@ class HomeConnectLight(HomeConnectEntity, LightEntity):
|
||||
|
||||
self.async_entity_update()
|
||||
|
||||
async def async_turn_off(self, **kwargs):
|
||||
async def async_turn_off(self, **kwargs: Any) -> None:
|
||||
"""Switch the light off."""
|
||||
_LOGGER.debug("Switching light off for: %s", self.name)
|
||||
try:
|
||||
|
@ -57,7 +57,7 @@ class HomeConnectSensor(HomeConnectEntity, SensorEntity):
|
||||
"""Return true if the sensor is available."""
|
||||
return self._state is not None
|
||||
|
||||
async def async_update(self):
|
||||
async def async_update(self) -> None:
|
||||
"""Update the sensor's status."""
|
||||
status = self.device.appliance.status
|
||||
if self._key not in status:
|
||||
|
@ -1,5 +1,6 @@
|
||||
"""Provides a switch for Home Connect."""
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
from homeconnect.api import HomeConnectError
|
||||
|
||||
@ -64,7 +65,7 @@ class HomeConnectProgramSwitch(HomeConnectEntity, SwitchEntity):
|
||||
"""Return true if the entity is available."""
|
||||
return True
|
||||
|
||||
async def async_turn_on(self, **kwargs):
|
||||
async def async_turn_on(self, **kwargs: Any) -> None:
|
||||
"""Start the program."""
|
||||
_LOGGER.debug("Tried to turn on program %s", self.program_name)
|
||||
try:
|
||||
@ -75,7 +76,7 @@ class HomeConnectProgramSwitch(HomeConnectEntity, SwitchEntity):
|
||||
_LOGGER.error("Error while trying to start program: %s", err)
|
||||
self.async_entity_update()
|
||||
|
||||
async def async_turn_off(self, **kwargs):
|
||||
async def async_turn_off(self, **kwargs: Any) -> None:
|
||||
"""Stop the program."""
|
||||
_LOGGER.debug("Tried to stop program %s", self.program_name)
|
||||
try:
|
||||
@ -84,7 +85,7 @@ class HomeConnectProgramSwitch(HomeConnectEntity, SwitchEntity):
|
||||
_LOGGER.error("Error while trying to stop program: %s", err)
|
||||
self.async_entity_update()
|
||||
|
||||
async def async_update(self):
|
||||
async def async_update(self) -> None:
|
||||
"""Update the switch's status."""
|
||||
state = self.device.appliance.status.get(BSH_ACTIVE_PROGRAM, {})
|
||||
if state.get(ATTR_VALUE) == self.program_name:
|
||||
@ -107,7 +108,7 @@ class HomeConnectPowerSwitch(HomeConnectEntity, SwitchEntity):
|
||||
"""Return true if the switch is on."""
|
||||
return bool(self._state)
|
||||
|
||||
async def async_turn_on(self, **kwargs):
|
||||
async def async_turn_on(self, **kwargs: Any) -> None:
|
||||
"""Switch the device on."""
|
||||
_LOGGER.debug("Tried to switch on %s", self.name)
|
||||
try:
|
||||
@ -119,7 +120,7 @@ class HomeConnectPowerSwitch(HomeConnectEntity, SwitchEntity):
|
||||
self._state = False
|
||||
self.async_entity_update()
|
||||
|
||||
async def async_turn_off(self, **kwargs):
|
||||
async def async_turn_off(self, **kwargs: Any) -> None:
|
||||
"""Switch the device off."""
|
||||
_LOGGER.debug("tried to switch off %s", self.name)
|
||||
try:
|
||||
@ -133,7 +134,7 @@ class HomeConnectPowerSwitch(HomeConnectEntity, SwitchEntity):
|
||||
self._state = True
|
||||
self.async_entity_update()
|
||||
|
||||
async def async_update(self):
|
||||
async def async_update(self) -> None:
|
||||
"""Update the switch's status."""
|
||||
if (
|
||||
self.device.appliance.status.get(BSH_POWER_STATE, {}).get(ATTR_VALUE)
|
||||
|
@ -1,5 +1,6 @@
|
||||
"""Legrand Home+ Control Switch Entity Module that uses the HomeAssistant DataUpdateCoordinator."""
|
||||
from functools import partial
|
||||
from typing import Any
|
||||
|
||||
from homeassistant.components.switch import SwitchDeviceClass, SwitchEntity
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
@ -118,14 +119,14 @@ class HomeControlSwitchEntity(CoordinatorEntity, SwitchEntity):
|
||||
"""Return entity state."""
|
||||
return self.module.status == "on"
|
||||
|
||||
async def async_turn_on(self, **kwargs):
|
||||
async def async_turn_on(self, **kwargs: Any) -> None:
|
||||
"""Turn the light on."""
|
||||
# Do the turning on.
|
||||
await self.module.turn_on()
|
||||
# Update the data
|
||||
await self.coordinator.async_request_refresh()
|
||||
|
||||
async def async_turn_off(self, **kwargs):
|
||||
async def async_turn_off(self, **kwargs: Any) -> None:
|
||||
"""Turn the entity off."""
|
||||
await self.module.turn_off()
|
||||
# Update the data
|
||||
|
@ -1,6 +1,8 @@
|
||||
"""Support for Homematic thermostats."""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from homeassistant.components.climate import ClimateEntity
|
||||
from homeassistant.components.climate.const import (
|
||||
PRESET_BOOST,
|
||||
@ -131,7 +133,7 @@ class HMThermostat(HMDevice, ClimateEntity):
|
||||
"""Return the target temperature."""
|
||||
return self._data.get(self._state)
|
||||
|
||||
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 None
|
||||
|
@ -1,6 +1,8 @@
|
||||
"""Support for HomeMatic 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
|
||||
@ -50,11 +52,11 @@ class HMSwitch(HMDevice, SwitchEntity):
|
||||
|
||||
return None
|
||||
|
||||
def turn_on(self, **kwargs):
|
||||
def turn_on(self, **kwargs: Any) -> None:
|
||||
"""Turn the switch on."""
|
||||
self._hmdevice.on(self._channel)
|
||||
|
||||
def turn_off(self, **kwargs):
|
||||
def turn_off(self, **kwargs: Any) -> None:
|
||||
"""Turn the switch off."""
|
||||
self._hmdevice.off(self._channel)
|
||||
|
||||
|
@ -194,7 +194,7 @@ class HomematicipHeatingGroup(HomematicipGenericEntity, ClimateEntity):
|
||||
"""Return the maximum temperature."""
|
||||
return self._device.maxTemperature
|
||||
|
||||
async def async_set_temperature(self, **kwargs) -> None:
|
||||
async def async_set_temperature(self, **kwargs: Any) -> None:
|
||||
"""Set new target temperature."""
|
||||
if (temperature := kwargs.get(ATTR_TEMPERATURE)) is None:
|
||||
return
|
||||
|
@ -106,11 +106,11 @@ class HomematicipMultiSwitch(HomematicipGenericEntity, SwitchEntity):
|
||||
"""Return true if switch is on."""
|
||||
return self._device.functionalChannels[self._channel].on
|
||||
|
||||
async def async_turn_on(self, **kwargs) -> None:
|
||||
async def async_turn_on(self, **kwargs: Any) -> None:
|
||||
"""Turn the switch on."""
|
||||
await self._device.turn_on(self._channel)
|
||||
|
||||
async def async_turn_off(self, **kwargs) -> None:
|
||||
async def async_turn_off(self, **kwargs: Any) -> None:
|
||||
"""Turn the switch off."""
|
||||
await self._device.turn_off(self._channel)
|
||||
|
||||
@ -155,11 +155,11 @@ class HomematicipGroupSwitch(HomematicipGenericEntity, SwitchEntity):
|
||||
|
||||
return state_attr
|
||||
|
||||
async def async_turn_on(self, **kwargs) -> None:
|
||||
async def async_turn_on(self, **kwargs: Any) -> None:
|
||||
"""Turn the group on."""
|
||||
await self._device.turn_on()
|
||||
|
||||
async def async_turn_off(self, **kwargs) -> None:
|
||||
async def async_turn_off(self, **kwargs: Any) -> None:
|
||||
"""Turn the group off."""
|
||||
await self._device.turn_off()
|
||||
|
||||
|
@ -252,7 +252,7 @@ class HoneywellUSThermostat(ClimateEntity):
|
||||
except somecomfort.SomeComfortError:
|
||||
_LOGGER.error("Temperature %.1f out of range", temperature)
|
||||
|
||||
def set_temperature(self, **kwargs) -> None:
|
||||
def set_temperature(self, **kwargs: Any) -> None:
|
||||
"""Set new target temperature."""
|
||||
if {HVACMode.COOL, HVACMode.HEAT} & set(self._hvac_mode_map):
|
||||
self._set_temperature(**kwargs)
|
||||
@ -352,6 +352,6 @@ class HoneywellUSThermostat(ClimateEntity):
|
||||
else:
|
||||
self.set_hvac_mode(HVACMode.OFF)
|
||||
|
||||
async def async_update(self):
|
||||
async def async_update(self) -> None:
|
||||
"""Get the latest state from the service."""
|
||||
await self._data.async_update()
|
||||
|
@ -3,6 +3,7 @@ from __future__ import annotations
|
||||
|
||||
from datetime import timedelta
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
from horimote import Client, keys
|
||||
from horimote.exceptions import AuthenticationError
|
||||
@ -105,7 +106,7 @@ class HorizonDevice(MediaPlayerEntity):
|
||||
return self._state
|
||||
|
||||
@util.Throttle(MIN_TIME_BETWEEN_SCANS, MIN_TIME_BETWEEN_FORCED_SCANS)
|
||||
def update(self):
|
||||
def update(self) -> None:
|
||||
"""Update State using the media server running on the Horizon."""
|
||||
try:
|
||||
if self._client.is_powered_on():
|
||||
@ -115,37 +116,37 @@ class HorizonDevice(MediaPlayerEntity):
|
||||
except OSError:
|
||||
self._state = STATE_OFF
|
||||
|
||||
def turn_on(self):
|
||||
def turn_on(self) -> None:
|
||||
"""Turn the device on."""
|
||||
if self._state == STATE_OFF:
|
||||
self._send_key(self._keys.POWER)
|
||||
|
||||
def turn_off(self):
|
||||
def turn_off(self) -> None:
|
||||
"""Turn the device off."""
|
||||
if self._state != STATE_OFF:
|
||||
self._send_key(self._keys.POWER)
|
||||
|
||||
def media_previous_track(self):
|
||||
def media_previous_track(self) -> None:
|
||||
"""Channel down."""
|
||||
self._send_key(self._keys.CHAN_DOWN)
|
||||
self._state = STATE_PLAYING
|
||||
|
||||
def media_next_track(self):
|
||||
def media_next_track(self) -> None:
|
||||
"""Channel up."""
|
||||
self._send_key(self._keys.CHAN_UP)
|
||||
self._state = STATE_PLAYING
|
||||
|
||||
def media_play(self):
|
||||
def media_play(self) -> None:
|
||||
"""Send play command."""
|
||||
self._send_key(self._keys.PAUSE)
|
||||
self._state = STATE_PLAYING
|
||||
|
||||
def media_pause(self):
|
||||
def media_pause(self) -> None:
|
||||
"""Send pause command."""
|
||||
self._send_key(self._keys.PAUSE)
|
||||
self._state = STATE_PAUSED
|
||||
|
||||
def media_play_pause(self):
|
||||
def media_play_pause(self) -> None:
|
||||
"""Send play/pause command."""
|
||||
self._send_key(self._keys.PAUSE)
|
||||
if self._state == STATE_PAUSED:
|
||||
@ -153,7 +154,7 @@ class HorizonDevice(MediaPlayerEntity):
|
||||
else:
|
||||
self._state = STATE_PAUSED
|
||||
|
||||
def play_media(self, media_type, media_id, **kwargs):
|
||||
def play_media(self, media_type: str, media_id: str, **kwargs: Any) -> None:
|
||||
"""Play media / switch to channel."""
|
||||
if MEDIA_TYPE_CHANNEL == media_type:
|
||||
try:
|
||||
|
@ -157,7 +157,7 @@ class HpIloSensor(SensorEntity):
|
||||
"""Return the device state attributes."""
|
||||
return self._state_attributes
|
||||
|
||||
def update(self):
|
||||
def update(self) -> None:
|
||||
"""Get the latest data from HP iLO and updates the states."""
|
||||
# Call the API for new data. Each sensor will re-trigger this
|
||||
# same exact call, but that's fine. Results should be cached for
|
||||
|
@ -69,20 +69,20 @@ class PowerViewShadeBatterySensor(ShadeEntity, SensorEntity):
|
||||
return f"{self._shade_name} Battery"
|
||||
|
||||
@property
|
||||
def native_value(self):
|
||||
def native_value(self) -> int:
|
||||
"""Get the current value in percentage."""
|
||||
return round(
|
||||
self._shade.raw_data[SHADE_BATTERY_LEVEL] / SHADE_BATTERY_LEVEL_MAX * 100
|
||||
)
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
async def async_added_to_hass(self) -> None:
|
||||
"""When entity is added to hass."""
|
||||
self.async_on_remove(
|
||||
self.coordinator.async_add_listener(self._async_update_shade_from_group)
|
||||
)
|
||||
|
||||
@callback
|
||||
def _async_update_shade_from_group(self):
|
||||
def _async_update_shade_from_group(self) -> None:
|
||||
"""Update with new data from the coordinator."""
|
||||
self._shade.raw_data = self.data.get_raw_data(self._shade.id)
|
||||
self.async_write_ha_state()
|
||||
|
@ -1,6 +1,9 @@
|
||||
"""Binary sensor platform for hvv_departures."""
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import timedelta
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
from aiohttp import ClientConnectorError
|
||||
import async_timeout
|
||||
@ -136,7 +139,7 @@ class HvvDepartureBinarySensor(CoordinatorEntity, BinarySensorEntity):
|
||||
return self.coordinator.data[self.idx]["state"]
|
||||
|
||||
@property
|
||||
def available(self):
|
||||
def available(self) -> bool:
|
||||
"""Return if entity is available."""
|
||||
return (
|
||||
self.coordinator.last_update_success
|
||||
@ -175,7 +178,7 @@ class HvvDepartureBinarySensor(CoordinatorEntity, BinarySensorEntity):
|
||||
return BinarySensorDeviceClass.PROBLEM
|
||||
|
||||
@property
|
||||
def extra_state_attributes(self):
|
||||
def extra_state_attributes(self) -> dict[str, Any] | None:
|
||||
"""Return the state attributes."""
|
||||
if not (
|
||||
self.coordinator.last_update_success
|
||||
@ -188,13 +191,13 @@ class HvvDepartureBinarySensor(CoordinatorEntity, BinarySensorEntity):
|
||||
if v is not None
|
||||
}
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
async def async_added_to_hass(self) -> None:
|
||||
"""When entity is added to hass."""
|
||||
self.async_on_remove(
|
||||
self.coordinator.async_add_listener(self.async_write_ha_state)
|
||||
)
|
||||
|
||||
async def async_update(self):
|
||||
async def async_update(self) -> None:
|
||||
"""Update the entity.
|
||||
|
||||
Only used by the generic entity update service.
|
||||
|
@ -1,6 +1,7 @@
|
||||
"""Sensor platform for hvv."""
|
||||
from datetime import timedelta
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
from aiohttp import ClientConnectorError
|
||||
from pygti.exceptions import InvalidAuth
|
||||
@ -66,7 +67,7 @@ class HVVDepartureSensor(SensorEntity):
|
||||
self.gti = hub.gti
|
||||
|
||||
@Throttle(MIN_TIME_BETWEEN_UPDATES)
|
||||
async def async_update(self, **kwargs):
|
||||
async def async_update(self, **kwargs: Any) -> None:
|
||||
"""Update the sensor."""
|
||||
departure_time = utcnow() + timedelta(
|
||||
minutes=self.config_entry.options.get("offset", 0)
|
||||
|
@ -80,7 +80,7 @@ def setup_platform(
|
||||
class HydrawiseBinarySensor(HydrawiseEntity, BinarySensorEntity):
|
||||
"""A sensor implementation for Hydrawise device."""
|
||||
|
||||
def update(self):
|
||||
def update(self) -> None:
|
||||
"""Get the latest data and updates the state."""
|
||||
_LOGGER.debug("Updating Hydrawise binary sensor: %s", self.name)
|
||||
mydata = self.hass.data[DATA_HYDRAWISE].data
|
||||
|
@ -73,7 +73,7 @@ def setup_platform(
|
||||
class HydrawiseSensor(HydrawiseEntity, SensorEntity):
|
||||
"""A sensor implementation for Hydrawise device."""
|
||||
|
||||
def update(self):
|
||||
def update(self) -> None:
|
||||
"""Get the latest data and updates the states."""
|
||||
mydata = self.hass.data[DATA_HYDRAWISE].data
|
||||
_LOGGER.debug("Updating Hydrawise sensor: %s", self.name)
|
||||
|
@ -2,6 +2,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
@ -85,7 +86,7 @@ class HydrawiseSwitch(HydrawiseEntity, SwitchEntity):
|
||||
super().__init__(data, description)
|
||||
self._default_watering_timer = default_watering_timer
|
||||
|
||||
def turn_on(self, **kwargs):
|
||||
def turn_on(self, **kwargs: Any) -> None:
|
||||
"""Turn the device on."""
|
||||
relay_data = self.data["relay"] - 1
|
||||
if self.entity_description.key == "manual_watering":
|
||||
@ -95,7 +96,7 @@ class HydrawiseSwitch(HydrawiseEntity, SwitchEntity):
|
||||
elif self.entity_description.key == "auto_watering":
|
||||
self.hass.data[DATA_HYDRAWISE].data.suspend_zone(0, relay_data)
|
||||
|
||||
def turn_off(self, **kwargs):
|
||||
def turn_off(self, **kwargs: Any) -> None:
|
||||
"""Turn the device off."""
|
||||
relay_data = self.data["relay"] - 1
|
||||
if self.entity_description.key == "manual_watering":
|
||||
@ -103,7 +104,7 @@ class HydrawiseSwitch(HydrawiseEntity, SwitchEntity):
|
||||
elif self.entity_description.key == "auto_watering":
|
||||
self.hass.data[DATA_HYDRAWISE].data.suspend_zone(365, relay_data)
|
||||
|
||||
def update(self):
|
||||
def update(self) -> None:
|
||||
"""Update device state."""
|
||||
relay_data = self.data["relay"] - 1
|
||||
mydata = self.hass.data[DATA_HYDRAWISE].data
|
||||
|
Loading…
x
Reference in New Issue
Block a user