Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion custom_components/eero/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,10 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b
device_entry.name,
device_entry.model,
)
device_registry.async_remove_device(device_entry.id)
try:
device_registry.async_remove_device(device_entry.id)
except (KeyError, ValueError):
pass
else:
for entity_entry in er.async_entries_for_device(
entity_registry, device_entry.id
Expand Down
32 changes: 4 additions & 28 deletions custom_components/eero/device_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,17 @@
from collections.abc import Mapping
from dataclasses import dataclass
from datetime import datetime, timedelta
from typing import Any, final
from typing import Any

from homeassistant.components.device_tracker import (
ATTR_HOST_NAME,
ATTR_IP,
ATTR_MAC,
ATTR_SOURCE_TYPE,
BaseScannerEntity,
SourceType,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ATTR_MANUFACTURER, STATE_HOME, STATE_NOT_HOME
from homeassistant.const import ATTR_MANUFACTURER
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import EntityCategory
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import StateType
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
from homeassistant.util import dt as dt_util

Expand Down Expand Up @@ -100,7 +96,7 @@ async def async_setup_entry(
async_add_entities(entities)


class EeroDeviceTrackerEntity(EeroEntity):
class EeroDeviceTrackerEntity(EeroEntity, BaseScannerEntity):
"""Representation of an Eero device tracker entity."""

_attr_entity_category = EntityCategory.DIAGNOSTIC
Expand Down Expand Up @@ -176,26 +172,6 @@ def hostname(self) -> str | None:
return self.resource.hostname
return None

@property
def state(self) -> str:
"""Return the state of the device."""
if self.is_connected:
return STATE_HOME
return STATE_NOT_HOME

@final
@property
def state_attributes(self) -> dict[str, StateType]:
"""Return the device state attributes."""
attr: dict[str, StateType] = {ATTR_SOURCE_TYPE: self.source_type}
if ip_address := self.ip_address:
attr[ATTR_IP] = ip_address
if mac_address := self.mac_address:
attr[ATTR_MAC] = mac_address
if hostname := self.hostname:
attr[ATTR_HOST_NAME] = hostname
return attr

@property
def extra_state_attributes(self) -> Mapping[str, Any] | None:
"""Return entity specific state attributes.
Expand Down