mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Add missing type declaration to AsusWrt Scanner Entity (#69773)
This commit is contained in:
parent
801b0b55a8
commit
bc2ba8e1c8
@ -9,7 +9,7 @@ from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
|||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from .const import DATA_ASUSWRT, DOMAIN
|
from .const import DATA_ASUSWRT, DOMAIN
|
||||||
from .router import AsusWrtRouter
|
from .router import AsusWrtDevInfo, AsusWrtRouter
|
||||||
|
|
||||||
DEFAULT_DEVICE_NAME = "Unknown device"
|
DEFAULT_DEVICE_NAME = "Unknown device"
|
||||||
|
|
||||||
@ -34,7 +34,9 @@ async def async_setup_entry(
|
|||||||
|
|
||||||
|
|
||||||
@callback
|
@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."""
|
"""Add new tracker entities from the router."""
|
||||||
new_tracked = []
|
new_tracked = []
|
||||||
|
|
||||||
@ -54,7 +56,7 @@ class AsusWrtDevice(ScannerEntity):
|
|||||||
|
|
||||||
_attr_should_poll = False
|
_attr_should_poll = False
|
||||||
|
|
||||||
def __init__(self, router: AsusWrtRouter, device) -> None:
|
def __init__(self, router: AsusWrtRouter, device: AsusWrtDevInfo) -> None:
|
||||||
"""Initialize a AsusWrt device."""
|
"""Initialize a AsusWrt device."""
|
||||||
self._router = router
|
self._router = router
|
||||||
self._device = device
|
self._device = device
|
||||||
@ -62,7 +64,7 @@ class AsusWrtDevice(ScannerEntity):
|
|||||||
self._attr_name = device.name or DEFAULT_DEVICE_NAME
|
self._attr_name = device.name or DEFAULT_DEVICE_NAME
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_connected(self):
|
def is_connected(self) -> bool:
|
||||||
"""Return true if the device is connected to the network."""
|
"""Return true if the device is connected to the network."""
|
||||||
return self._device.is_connected
|
return self._device.is_connected
|
||||||
|
|
||||||
@ -92,7 +94,7 @@ class AsusWrtDevice(ScannerEntity):
|
|||||||
return self._device.mac
|
return self._device.mac
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def async_on_demand_update(self):
|
def async_on_demand_update(self) -> None:
|
||||||
"""Update state."""
|
"""Update state."""
|
||||||
self._device = self._router.devices[self._device.mac]
|
self._device = self._router.devices[self._device.mac]
|
||||||
self._attr_extra_state_attributes = {}
|
self._attr_extra_state_attributes = {}
|
||||||
@ -102,7 +104,7 @@ class AsusWrtDevice(ScannerEntity):
|
|||||||
] = self._device.last_activity.isoformat(timespec="seconds")
|
] = self._device.last_activity.isoformat(timespec="seconds")
|
||||||
self.async_write_ha_state()
|
self.async_write_ha_state()
|
||||||
|
|
||||||
async def async_added_to_hass(self):
|
async def async_added_to_hass(self) -> None:
|
||||||
"""Register state update callback."""
|
"""Register state update callback."""
|
||||||
self.async_on_remove(
|
self.async_on_remove(
|
||||||
async_dispatcher_connect(
|
async_dispatcher_connect(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user