mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 17:27:10 +00:00
Improve type hints in vacuum entities (#76561)
This commit is contained in:
parent
52fbd50d3c
commit
fea0ec4d4d
@ -94,17 +94,17 @@ class EcovacsVacuum(VacuumEntity):
|
||||
return self.device.vacuum.get("did")
|
||||
|
||||
@property
|
||||
def is_on(self):
|
||||
def is_on(self) -> bool:
|
||||
"""Return true if vacuum is currently cleaning."""
|
||||
return self.device.is_cleaning
|
||||
|
||||
@property
|
||||
def is_charging(self):
|
||||
def is_charging(self) -> bool:
|
||||
"""Return true if vacuum is currently charging."""
|
||||
return self.device.is_charging
|
||||
|
||||
@property
|
||||
def status(self):
|
||||
def status(self) -> str | None:
|
||||
"""Return the status of the vacuum cleaner."""
|
||||
return self.device.vacuum_status
|
||||
|
||||
@ -173,9 +173,9 @@ class EcovacsVacuum(VacuumEntity):
|
||||
self.device.run(sucks.VacBotCommand(command, params))
|
||||
|
||||
@property
|
||||
def extra_state_attributes(self):
|
||||
def extra_state_attributes(self) -> dict[str, Any]:
|
||||
"""Return the device-specific state attributes of this vacuum."""
|
||||
data = {}
|
||||
data: dict[str, Any] = {}
|
||||
data[ATTR_ERROR] = self._error
|
||||
|
||||
for key, val in self.device.components.items():
|
||||
|
@ -2,6 +2,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Iterable
|
||||
from typing import Any
|
||||
|
||||
from sharkiq import OperatingModes, PowerModes, Properties, SharkIqVacuum
|
||||
|
||||
@ -89,11 +90,16 @@ class SharkVacuumEntity(CoordinatorEntity[SharkIqUpdateCoordinator], StateVacuum
|
||||
self._attr_unique_id = sharkiq.serial_number
|
||||
self._serial_number = sharkiq.serial_number
|
||||
|
||||
def clean_spot(self, **kwargs):
|
||||
def clean_spot(self, **kwargs: Any) -> None:
|
||||
"""Clean a spot. Not yet implemented."""
|
||||
raise NotImplementedError()
|
||||
|
||||
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 the vacuum. Not yet implemented."""
|
||||
raise NotImplementedError()
|
||||
|
||||
@ -146,7 +152,7 @@ class SharkVacuumEntity(CoordinatorEntity[SharkIqUpdateCoordinator], StateVacuum
|
||||
return self.sharkiq.get_property_value(Properties.RECHARGING_TO_RESUME)
|
||||
|
||||
@property
|
||||
def state(self):
|
||||
def state(self) -> str | None:
|
||||
"""
|
||||
Get the current vacuum state.
|
||||
|
||||
@ -169,27 +175,27 @@ class SharkVacuumEntity(CoordinatorEntity[SharkIqUpdateCoordinator], StateVacuum
|
||||
"""Get the current battery level."""
|
||||
return self.sharkiq.get_property_value(Properties.BATTERY_CAPACITY)
|
||||
|
||||
async def async_return_to_base(self, **kwargs):
|
||||
async def async_return_to_base(self, **kwargs: Any) -> None:
|
||||
"""Have the device return to base."""
|
||||
await self.sharkiq.async_set_operating_mode(OperatingModes.RETURN)
|
||||
await self.coordinator.async_refresh()
|
||||
|
||||
async def async_pause(self):
|
||||
async def async_pause(self) -> None:
|
||||
"""Pause the cleaning task."""
|
||||
await self.sharkiq.async_set_operating_mode(OperatingModes.PAUSE)
|
||||
await self.coordinator.async_refresh()
|
||||
|
||||
async def async_start(self):
|
||||
async def async_start(self) -> None:
|
||||
"""Start the device."""
|
||||
await self.sharkiq.async_set_operating_mode(OperatingModes.START)
|
||||
await self.coordinator.async_refresh()
|
||||
|
||||
async def async_stop(self, **kwargs):
|
||||
async def async_stop(self, **kwargs: Any) -> None:
|
||||
"""Stop the device."""
|
||||
await self.sharkiq.async_set_operating_mode(OperatingModes.STOP)
|
||||
await self.coordinator.async_refresh()
|
||||
|
||||
async def async_locate(self, **kwargs):
|
||||
async def async_locate(self, **kwargs: Any) -> None:
|
||||
"""Cause the device to generate a loud chirp."""
|
||||
await self.sharkiq.async_find_device()
|
||||
|
||||
@ -203,7 +209,7 @@ class SharkVacuumEntity(CoordinatorEntity[SharkIqUpdateCoordinator], StateVacuum
|
||||
fan_speed = k
|
||||
return fan_speed
|
||||
|
||||
async def async_set_fan_speed(self, fan_speed: str, **kwargs):
|
||||
async def async_set_fan_speed(self, fan_speed: str, **kwargs: Any) -> None:
|
||||
"""Set the fan speed."""
|
||||
await self.sharkiq.async_set_property_value(
|
||||
Properties.POWER_MODE, FAN_SPEEDS_MAP.get(fan_speed.capitalize())
|
||||
@ -227,7 +233,7 @@ class SharkVacuumEntity(CoordinatorEntity[SharkIqUpdateCoordinator], StateVacuum
|
||||
return self.sharkiq.get_property_value(Properties.LOW_LIGHT_MISSION)
|
||||
|
||||
@property
|
||||
def extra_state_attributes(self) -> dict:
|
||||
def extra_state_attributes(self) -> dict[str, Any]:
|
||||
"""Return a dictionary of device state attributes specific to sharkiq."""
|
||||
data = {
|
||||
ATTR_ERROR_CODE: self.error_code,
|
||||
|
@ -2,6 +2,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
@ -204,46 +205,46 @@ class TemplateVacuum(TemplateEntity, StateVacuumEntity):
|
||||
"""Return the status of the vacuum cleaner."""
|
||||
return self._state
|
||||
|
||||
async def async_start(self):
|
||||
async def async_start(self) -> None:
|
||||
"""Start or resume the cleaning task."""
|
||||
await self.async_run_script(self._start_script, context=self._context)
|
||||
|
||||
async def async_pause(self):
|
||||
async def async_pause(self) -> None:
|
||||
"""Pause the cleaning task."""
|
||||
if self._pause_script is None:
|
||||
return
|
||||
|
||||
await self.async_run_script(self._pause_script, context=self._context)
|
||||
|
||||
async def async_stop(self, **kwargs):
|
||||
async def async_stop(self, **kwargs: Any) -> None:
|
||||
"""Stop the cleaning task."""
|
||||
if self._stop_script is None:
|
||||
return
|
||||
|
||||
await self.async_run_script(self._stop_script, context=self._context)
|
||||
|
||||
async def async_return_to_base(self, **kwargs):
|
||||
async def async_return_to_base(self, **kwargs: Any) -> None:
|
||||
"""Set the vacuum cleaner to return to the dock."""
|
||||
if self._return_to_base_script is None:
|
||||
return
|
||||
|
||||
await self.async_run_script(self._return_to_base_script, context=self._context)
|
||||
|
||||
async def async_clean_spot(self, **kwargs):
|
||||
async def async_clean_spot(self, **kwargs: Any) -> None:
|
||||
"""Perform a spot clean-up."""
|
||||
if self._clean_spot_script is None:
|
||||
return
|
||||
|
||||
await self.async_run_script(self._clean_spot_script, context=self._context)
|
||||
|
||||
async def async_locate(self, **kwargs):
|
||||
async def async_locate(self, **kwargs: Any) -> None:
|
||||
"""Locate the vacuum cleaner."""
|
||||
if self._locate_script is None:
|
||||
return
|
||||
|
||||
await self.async_run_script(self._locate_script, context=self._context)
|
||||
|
||||
async def async_set_fan_speed(self, fan_speed, **kwargs):
|
||||
async def async_set_fan_speed(self, fan_speed: str, **kwargs: Any) -> None:
|
||||
"""Set fan speed."""
|
||||
if self._set_fan_speed_script is None:
|
||||
return
|
||||
|
Loading…
x
Reference in New Issue
Block a user