mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Disable some upnp entities by default (#77330)
This commit is contained in:
parent
a09e9040f3
commit
525afb729c
@ -7,6 +7,7 @@ from homeassistant.components.binary_sensor import (
|
|||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.helpers.entity import EntityCategory
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from . import UpnpBinarySensorEntityDescription, UpnpDataUpdateCoordinator, UpnpEntity
|
from . import UpnpBinarySensorEntityDescription, UpnpDataUpdateCoordinator, UpnpEntity
|
||||||
@ -16,6 +17,8 @@ BINARYSENSOR_ENTITY_DESCRIPTIONS: tuple[UpnpBinarySensorEntityDescription, ...]
|
|||||||
UpnpBinarySensorEntityDescription(
|
UpnpBinarySensorEntityDescription(
|
||||||
key=WAN_STATUS,
|
key=WAN_STATUS,
|
||||||
name="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."""
|
"""Class for UPnP/IGD binary sensors."""
|
||||||
|
|
||||||
entity_description: UpnpBinarySensorEntityDescription
|
entity_description: UpnpBinarySensorEntityDescription
|
||||||
_attr_device_class = BinarySensorDeviceClass.CONNECTIVITY
|
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
|
@ -5,6 +5,7 @@ from homeassistant.components.sensor import SensorEntity
|
|||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import DATA_BYTES, DATA_RATE_KIBIBYTES_PER_SECOND, TIME_SECONDS
|
from homeassistant.const import DATA_BYTES, DATA_RATE_KIBIBYTES_PER_SECOND, TIME_SECONDS
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.helpers.entity import EntityCategory
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from . import UpnpDataUpdateCoordinator, UpnpEntity, UpnpSensorEntityDescription
|
from . import UpnpDataUpdateCoordinator, UpnpEntity, UpnpSensorEntityDescription
|
||||||
@ -31,6 +32,7 @@ RAW_SENSORS: tuple[UpnpSensorEntityDescription, ...] = (
|
|||||||
icon="mdi:server-network",
|
icon="mdi:server-network",
|
||||||
native_unit_of_measurement=DATA_BYTES,
|
native_unit_of_measurement=DATA_BYTES,
|
||||||
format="d",
|
format="d",
|
||||||
|
entity_registry_enabled_default=False,
|
||||||
),
|
),
|
||||||
UpnpSensorEntityDescription(
|
UpnpSensorEntityDescription(
|
||||||
key=BYTES_SENT,
|
key=BYTES_SENT,
|
||||||
@ -38,6 +40,7 @@ RAW_SENSORS: tuple[UpnpSensorEntityDescription, ...] = (
|
|||||||
icon="mdi:server-network",
|
icon="mdi:server-network",
|
||||||
native_unit_of_measurement=DATA_BYTES,
|
native_unit_of_measurement=DATA_BYTES,
|
||||||
format="d",
|
format="d",
|
||||||
|
entity_registry_enabled_default=False,
|
||||||
),
|
),
|
||||||
UpnpSensorEntityDescription(
|
UpnpSensorEntityDescription(
|
||||||
key=PACKETS_RECEIVED,
|
key=PACKETS_RECEIVED,
|
||||||
@ -45,6 +48,7 @@ RAW_SENSORS: tuple[UpnpSensorEntityDescription, ...] = (
|
|||||||
icon="mdi:server-network",
|
icon="mdi:server-network",
|
||||||
native_unit_of_measurement=DATA_PACKETS,
|
native_unit_of_measurement=DATA_PACKETS,
|
||||||
format="d",
|
format="d",
|
||||||
|
entity_registry_enabled_default=False,
|
||||||
),
|
),
|
||||||
UpnpSensorEntityDescription(
|
UpnpSensorEntityDescription(
|
||||||
key=PACKETS_SENT,
|
key=PACKETS_SENT,
|
||||||
@ -52,6 +56,7 @@ RAW_SENSORS: tuple[UpnpSensorEntityDescription, ...] = (
|
|||||||
icon="mdi:server-network",
|
icon="mdi:server-network",
|
||||||
native_unit_of_measurement=DATA_PACKETS,
|
native_unit_of_measurement=DATA_PACKETS,
|
||||||
format="d",
|
format="d",
|
||||||
|
entity_registry_enabled_default=False,
|
||||||
),
|
),
|
||||||
UpnpSensorEntityDescription(
|
UpnpSensorEntityDescription(
|
||||||
key=ROUTER_IP,
|
key=ROUTER_IP,
|
||||||
@ -65,11 +70,14 @@ RAW_SENSORS: tuple[UpnpSensorEntityDescription, ...] = (
|
|||||||
native_unit_of_measurement=TIME_SECONDS,
|
native_unit_of_measurement=TIME_SECONDS,
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
format="d",
|
format="d",
|
||||||
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
),
|
),
|
||||||
UpnpSensorEntityDescription(
|
UpnpSensorEntityDescription(
|
||||||
key=WAN_STATUS,
|
key=WAN_STATUS,
|
||||||
name="wan status",
|
name="wan status",
|
||||||
icon="mdi:server-network",
|
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",
|
icon="mdi:server-network",
|
||||||
native_unit_of_measurement=DATA_RATE_PACKETS_PER_SECOND,
|
native_unit_of_measurement=DATA_RATE_PACKETS_PER_SECOND,
|
||||||
format=".1f",
|
format=".1f",
|
||||||
|
entity_registry_enabled_default=False,
|
||||||
),
|
),
|
||||||
UpnpSensorEntityDescription(
|
UpnpSensorEntityDescription(
|
||||||
key=PACKETS_SENT,
|
key=PACKETS_SENT,
|
||||||
@ -105,6 +114,7 @@ DERIVED_SENSORS: tuple[UpnpSensorEntityDescription, ...] = (
|
|||||||
icon="mdi:server-network",
|
icon="mdi:server-network",
|
||||||
native_unit_of_measurement=DATA_RATE_PACKETS_PER_SECOND,
|
native_unit_of_measurement=DATA_RATE_PACKETS_PER_SECOND,
|
||||||
format=".1f",
|
format=".1f",
|
||||||
|
entity_registry_enabled_default=False,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
"""Configuration for SSDP tests."""
|
"""Configuration for SSDP tests."""
|
||||||
from __future__ import annotations
|
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 urllib.parse import urlparse
|
||||||
|
|
||||||
from async_upnp_client.client import UpnpDevice
|
from async_upnp_client.client import UpnpDevice
|
||||||
@ -184,6 +184,10 @@ async def mock_config_entry(
|
|||||||
|
|
||||||
# Load config_entry.
|
# Load config_entry.
|
||||||
entry.add_to_hass(hass)
|
entry.add_to_hass(hass)
|
||||||
|
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.config_entries.async_setup(entry.entry_id)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user