1
mirror of https://github.com/home-assistant/core synced 2024-09-15 17:29:45 +02:00

Add missing type declaration to AsusWrt Scanner Entity (#69773)

This commit is contained in:
ollo69 2022-04-10 23:28:12 +02:00 committed by GitHub
parent 801b0b55a8
commit bc2ba8e1c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -9,7 +9,7 @@ from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from .const import DATA_ASUSWRT, DOMAIN
from .router import AsusWrtRouter
from .router import AsusWrtDevInfo, AsusWrtRouter
DEFAULT_DEVICE_NAME = "Unknown device"
@ -34,7 +34,9 @@ async def async_setup_entry(
@callback
def add_entities(router, async_add_entities, tracked):
def add_entities(
router: AsusWrtRouter, async_add_entities: AddEntitiesCallback, tracked: set[str]
) -> None:
"""Add new tracker entities from the router."""
new_tracked = []
@ -54,7 +56,7 @@ class AsusWrtDevice(ScannerEntity):
_attr_should_poll = False
def __init__(self, router: AsusWrtRouter, device) -> None:
def __init__(self, router: AsusWrtRouter, device: AsusWrtDevInfo) -> None:
"""Initialize a AsusWrt device."""
self._router = router
self._device = device
@ -62,7 +64,7 @@ class AsusWrtDevice(ScannerEntity):
self._attr_name = device.name or DEFAULT_DEVICE_NAME
@property
def is_connected(self):
def is_connected(self) -> bool:
"""Return true if the device is connected to the network."""
return self._device.is_connected
@ -92,7 +94,7 @@ class AsusWrtDevice(ScannerEntity):
return self._device.mac
@callback
def async_on_demand_update(self):
def async_on_demand_update(self) -> None:
"""Update state."""
self._device = self._router.devices[self._device.mac]
self._attr_extra_state_attributes = {}
@ -102,7 +104,7 @@ class AsusWrtDevice(ScannerEntity):
] = self._device.last_activity.isoformat(timespec="seconds")
self.async_write_ha_state()
async def async_added_to_hass(self):
async def async_added_to_hass(self) -> None:
"""Register state update callback."""
self.async_on_remove(
async_dispatcher_connect(