Disable some upnp entities by default (#77330)
This commit is contained in:
parent
a09e9040f3
commit
525afb729c
3 changed files with 20 additions and 4 deletions
|
@ -7,6 +7,7 @@ from homeassistant.components.binary_sensor import (
|
|||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity import EntityCategory
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from . import UpnpBinarySensorEntityDescription, UpnpDataUpdateCoordinator, UpnpEntity
|
||||
|
@ -16,6 +17,8 @@ BINARYSENSOR_ENTITY_DESCRIPTIONS: tuple[UpnpBinarySensorEntityDescription, ...]
|
|||
UpnpBinarySensorEntityDescription(
|
||||
key=WAN_STATUS,
|
||||
name="wan status",
|
||||
device_class=BinarySensorDeviceClass.CONNECTIVITY,
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
),
|
||||
)
|
||||
|
||||
|
@ -44,7 +47,6 @@ class UpnpStatusBinarySensor(UpnpEntity, BinarySensorEntity):
|
|||
"""Class for UPnP/IGD binary sensors."""
|
||||
|
||||
entity_description: UpnpBinarySensorEntityDescription
|
||||
_attr_device_class = BinarySensorDeviceClass.CONNECTIVITY
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
|
|
|
@ -5,6 +5,7 @@ from homeassistant.components.sensor import SensorEntity
|
|||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import DATA_BYTES, DATA_RATE_KIBIBYTES_PER_SECOND, TIME_SECONDS
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity import EntityCategory
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from . import UpnpDataUpdateCoordinator, UpnpEntity, UpnpSensorEntityDescription
|
||||
|
@ -31,6 +32,7 @@ RAW_SENSORS: tuple[UpnpSensorEntityDescription, ...] = (
|
|||
icon="mdi:server-network",
|
||||
native_unit_of_measurement=DATA_BYTES,
|
||||
format="d",
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
UpnpSensorEntityDescription(
|
||||
key=BYTES_SENT,
|
||||
|
@ -38,6 +40,7 @@ RAW_SENSORS: tuple[UpnpSensorEntityDescription, ...] = (
|
|||
icon="mdi:server-network",
|
||||
native_unit_of_measurement=DATA_BYTES,
|
||||
format="d",
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
UpnpSensorEntityDescription(
|
||||
key=PACKETS_RECEIVED,
|
||||
|
@ -45,6 +48,7 @@ RAW_SENSORS: tuple[UpnpSensorEntityDescription, ...] = (
|
|||
icon="mdi:server-network",
|
||||
native_unit_of_measurement=DATA_PACKETS,
|
||||
format="d",
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
UpnpSensorEntityDescription(
|
||||
key=PACKETS_SENT,
|
||||
|
@ -52,6 +56,7 @@ RAW_SENSORS: tuple[UpnpSensorEntityDescription, ...] = (
|
|||
icon="mdi:server-network",
|
||||
native_unit_of_measurement=DATA_PACKETS,
|
||||
format="d",
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
UpnpSensorEntityDescription(
|
||||
key=ROUTER_IP,
|
||||
|
@ -65,11 +70,14 @@ RAW_SENSORS: tuple[UpnpSensorEntityDescription, ...] = (
|
|||
native_unit_of_measurement=TIME_SECONDS,
|
||||
entity_registry_enabled_default=False,
|
||||
format="d",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
),
|
||||
UpnpSensorEntityDescription(
|
||||
key=WAN_STATUS,
|
||||
name="wan status",
|
||||
icon="mdi:server-network",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
)
|
||||
|
||||
|
@ -97,6 +105,7 @@ DERIVED_SENSORS: tuple[UpnpSensorEntityDescription, ...] = (
|
|||
icon="mdi:server-network",
|
||||
native_unit_of_measurement=DATA_RATE_PACKETS_PER_SECOND,
|
||||
format=".1f",
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
UpnpSensorEntityDescription(
|
||||
key=PACKETS_SENT,
|
||||
|
@ -105,6 +114,7 @@ DERIVED_SENSORS: tuple[UpnpSensorEntityDescription, ...] = (
|
|||
icon="mdi:server-network",
|
||||
native_unit_of_measurement=DATA_RATE_PACKETS_PER_SECOND,
|
||||
format=".1f",
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
)
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
"""Configuration for SSDP tests."""
|
||||
from __future__ import annotations
|
||||
|
||||
from unittest.mock import AsyncMock, MagicMock, create_autospec, patch
|
||||
from unittest.mock import AsyncMock, MagicMock, PropertyMock, create_autospec, patch
|
||||
from urllib.parse import urlparse
|
||||
|
||||
from async_upnp_client.client import UpnpDevice
|
||||
|
@ -184,7 +184,11 @@ async def mock_config_entry(
|
|||
|
||||
# Load config_entry.
|
||||
entry.add_to_hass(hass)
|
||||
await hass.config_entries.async_setup(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
with patch(
|
||||
"homeassistant.helpers.entity.Entity.entity_registry_enabled_default",
|
||||
PropertyMock(return_value=True),
|
||||
):
|
||||
await hass.config_entries.async_setup(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
yield entry
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue