mirror of
https://github.com/home-assistant/core.git
synced 2026-05-08 09:38:58 +01:00
Filter out integration types in extended analytics (#152874)
This commit is contained in:
@@ -546,12 +546,13 @@ async def async_devices_payload(hass: HomeAssistant) -> dict:
|
||||
if isinstance(integration, Integration)
|
||||
}
|
||||
|
||||
# Filter out custom integrations
|
||||
# Filter out custom integrations and integrations that are not device or hub type
|
||||
integration_inputs = {
|
||||
domain: integration_info
|
||||
for domain, integration_info in integration_inputs.items()
|
||||
if (integration := integrations.get(domain)) is not None
|
||||
and integration.is_built_in
|
||||
and integration.integration_type in ("device", "hub")
|
||||
}
|
||||
|
||||
# Call integrations that implement the analytics platform
|
||||
|
||||
@@ -1055,6 +1055,16 @@ async def test_devices_payload_no_entities(
|
||||
model_id="test-model-id7",
|
||||
)
|
||||
|
||||
# Device from an integration with a service type
|
||||
mock_service_config_entry = MockConfigEntry(domain="uptime")
|
||||
mock_service_config_entry.add_to_hass(hass)
|
||||
device_registry.async_get_or_create(
|
||||
config_entry_id=mock_service_config_entry.entry_id,
|
||||
identifiers={("device", "8")},
|
||||
manufacturer="test-manufacturer8",
|
||||
model_id="test-model-id8",
|
||||
)
|
||||
|
||||
client = await hass_client()
|
||||
response = await client.get("/api/analytics/devices")
|
||||
assert response.status == HTTPStatus.OK
|
||||
@@ -1173,21 +1183,29 @@ async def test_devices_payload_with_entities(
|
||||
original_device_class=NumberDeviceClass.TEMPERATURE,
|
||||
)
|
||||
hass.states.async_set("number.hue_1", "2")
|
||||
# Helper entity with assumed state
|
||||
# Entity with assumed state
|
||||
entity_registry.async_get_or_create(
|
||||
domain="light",
|
||||
platform="template",
|
||||
platform="hue",
|
||||
unique_id="2",
|
||||
device_id=device_entry.id,
|
||||
has_entity_name=True,
|
||||
)
|
||||
hass.states.async_set("light.hue_2", "on", {ATTR_ASSUMED_STATE: True})
|
||||
# Entity from a different integration
|
||||
entity_registry.async_get_or_create(
|
||||
domain="light",
|
||||
platform="roomba",
|
||||
unique_id="1",
|
||||
device_id=device_entry.id,
|
||||
has_entity_name=True,
|
||||
)
|
||||
hass.states.async_set("light.template_1", "on", {ATTR_ASSUMED_STATE: True})
|
||||
|
||||
# Second device
|
||||
entity_registry.async_get_or_create(
|
||||
domain="light",
|
||||
platform="hue",
|
||||
unique_id="2",
|
||||
unique_id="3",
|
||||
device_id=device_entry_2.id,
|
||||
)
|
||||
|
||||
@@ -1235,6 +1253,16 @@ async def test_devices_payload_with_entities(
|
||||
"original_device_class": "temperature",
|
||||
"unit_of_measurement": None,
|
||||
},
|
||||
{
|
||||
"assumed_state": True,
|
||||
"capabilities": None,
|
||||
"domain": "light",
|
||||
"entity_category": None,
|
||||
"has_entity_name": True,
|
||||
"modified_by_integration": None,
|
||||
"original_device_class": None,
|
||||
"unit_of_measurement": None,
|
||||
},
|
||||
],
|
||||
"entry_type": None,
|
||||
"has_configuration_url": False,
|
||||
@@ -1281,11 +1309,11 @@ async def test_devices_payload_with_entities(
|
||||
},
|
||||
],
|
||||
},
|
||||
"template": {
|
||||
"roomba": {
|
||||
"devices": [],
|
||||
"entities": [
|
||||
{
|
||||
"assumed_state": True,
|
||||
"assumed_state": None,
|
||||
"capabilities": None,
|
||||
"domain": "light",
|
||||
"entity_category": None,
|
||||
|
||||
Reference in New Issue
Block a user