Improve type hints in vesync lights (#75998)
* Improve type hints in vesync lights * Adjust import
This commit is contained in:
parent
98f0b24c42
commit
1ba18f8df6
3 changed files with 22 additions and 27 deletions
|
@ -1,7 +1,10 @@
|
|||
"""Common utilities for VeSync Component."""
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
from homeassistant.helpers.entity import Entity, ToggleEntity
|
||||
from pyvesync.vesyncbasedevice import VeSyncBaseDevice
|
||||
|
||||
from homeassistant.helpers.entity import DeviceInfo, Entity, ToggleEntity
|
||||
|
||||
from .const import DOMAIN, VS_FANS, VS_LIGHTS, VS_SENSORS, VS_SWITCHES
|
||||
|
||||
|
@ -48,7 +51,7 @@ async def async_process_devices(hass, manager):
|
|||
class VeSyncBaseEntity(Entity):
|
||||
"""Base class for VeSync Entity Representations."""
|
||||
|
||||
def __init__(self, device):
|
||||
def __init__(self, device: VeSyncBaseDevice) -> None:
|
||||
"""Initialize the VeSync device."""
|
||||
self.device = device
|
||||
self._attr_unique_id = self.base_unique_id
|
||||
|
@ -65,7 +68,7 @@ class VeSyncBaseEntity(Entity):
|
|||
return self.device.cid
|
||||
|
||||
@property
|
||||
def base_name(self):
|
||||
def base_name(self) -> str:
|
||||
"""Return the name of the device."""
|
||||
# Same story here as `base_unique_id` above
|
||||
return self.device.device_name
|
||||
|
@ -76,17 +79,17 @@ class VeSyncBaseEntity(Entity):
|
|||
return self.device.connection_status == "online"
|
||||
|
||||
@property
|
||||
def device_info(self):
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return device information."""
|
||||
return {
|
||||
"identifiers": {(DOMAIN, self.base_unique_id)},
|
||||
"name": self.base_name,
|
||||
"model": self.device.device_type,
|
||||
"default_manufacturer": "VeSync",
|
||||
"sw_version": self.device.current_firm_version,
|
||||
}
|
||||
return DeviceInfo(
|
||||
identifiers={(DOMAIN, self.base_unique_id)},
|
||||
name=self.base_name,
|
||||
model=self.device.device_type,
|
||||
default_manufacturer="VeSync",
|
||||
sw_version=self.device.current_firm_version,
|
||||
)
|
||||
|
||||
def update(self):
|
||||
def update(self) -> None:
|
||||
"""Update vesync device."""
|
||||
self.device.update()
|
||||
|
||||
|
@ -100,10 +103,10 @@ class VeSyncDevice(VeSyncBaseEntity, ToggleEntity):
|
|||
return self.device.details
|
||||
|
||||
@property
|
||||
def is_on(self):
|
||||
def is_on(self) -> bool:
|
||||
"""Return True if device is on."""
|
||||
return self.device.device_status == "on"
|
||||
|
||||
def turn_off(self, **kwargs):
|
||||
def turn_off(self, **kwargs: Any) -> None:
|
||||
"""Turn the device off."""
|
||||
self.device.turn_off()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue