mirror of
https://github.com/home-assistant/core.git
synced 2026-07-10 00:05:13 +01:00
Remove state attributes from OPNsense (#172930)
This commit is contained in:
committed by
Franck Nijhof
parent
e812cd3c3f
commit
89a033bc2c
@@ -1,7 +1,5 @@
|
||||
"""Device tracker support for OPNsense routers."""
|
||||
|
||||
from typing import Any
|
||||
|
||||
from homeassistant.components.device_tracker import ScannerEntity
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||
@@ -98,20 +96,3 @@ class OPNsenseDeviceTrackerEntity(
|
||||
hostname = device_data.get("hostname")
|
||||
return hostname or None
|
||||
return None
|
||||
|
||||
@property
|
||||
def extra_state_attributes(self) -> dict[str, Any]:
|
||||
"""Return the state attributes."""
|
||||
device_data = self.device_data
|
||||
if not device_data:
|
||||
return {}
|
||||
|
||||
attrs = {}
|
||||
if manufacturer := device_data.get("manufacturer"):
|
||||
attrs["manufacturer"] = manufacturer
|
||||
if interface := device_data.get("intf_description"):
|
||||
attrs["interface"] = interface
|
||||
if expires := device_data.get("expires"):
|
||||
attrs["expires"] = expires
|
||||
|
||||
return attrs
|
||||
|
||||
@@ -90,7 +90,6 @@ async def test_device_tracker_states(
|
||||
assert state_1.state == "home" # Should be connected since it's in ARP table
|
||||
assert state_1.attributes.get("ip") == "192.168.0.123"
|
||||
assert state_1.attributes.get("mac") == "ff:ff:ff:ff:ff:ff"
|
||||
assert state_1.attributes.get("interface") == "LAN"
|
||||
|
||||
# Test second device (with hostname and manufacturer)
|
||||
entity_id_2 = entity_ids_by_unique_id["ff:ff:ff:ff:ff:fe"]
|
||||
@@ -99,8 +98,6 @@ async def test_device_tracker_states(
|
||||
assert state_2.state == "home" # Should be connected since it's in ARP table
|
||||
assert state_2.attributes.get("ip") == "192.168.0.167"
|
||||
assert state_2.attributes.get("mac") == "ff:ff:ff:ff:ff:fe"
|
||||
assert state_2.attributes.get("interface") == "LAN"
|
||||
assert state_2.attributes.get("manufacturer") == "OEM"
|
||||
|
||||
|
||||
async def test_device_tracker_with_interfaces_filter(
|
||||
|
||||
Reference in New Issue
Block a user