mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
parent
02f7165ca5
commit
0d22822ed0
36
homeassistant/components/ecovacs/diagnostics.py
Normal file
36
homeassistant/components/ecovacs/diagnostics.py
Normal file
@ -0,0 +1,36 @@
|
||||
"""Ecovacs diagnostics."""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from homeassistant.components.diagnostics import async_redact_data
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_NAME, CONF_PASSWORD, CONF_USERNAME
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from .const import DOMAIN
|
||||
from .controller import EcovacsController
|
||||
|
||||
REDACT_CONFIG = {CONF_USERNAME, CONF_PASSWORD, "title"}
|
||||
REDACT_DEVICE = {"did", CONF_NAME, "homeId"}
|
||||
|
||||
|
||||
async def async_get_config_entry_diagnostics(
|
||||
hass: HomeAssistant, config_entry: ConfigEntry
|
||||
) -> dict[str, Any]:
|
||||
"""Return diagnostics for a config entry."""
|
||||
controller: EcovacsController = hass.data[DOMAIN][config_entry.entry_id]
|
||||
diag: dict[str, Any] = {
|
||||
"config": async_redact_data(config_entry.as_dict(), REDACT_CONFIG)
|
||||
}
|
||||
|
||||
diag["devices"] = [
|
||||
async_redact_data(device.device_info.api_device_info, REDACT_DEVICE)
|
||||
for device in controller.devices
|
||||
]
|
||||
diag["legacy_devices"] = [
|
||||
async_redact_data(device.vacuum, REDACT_DEVICE)
|
||||
for device in controller.legacy_devices
|
||||
]
|
||||
|
||||
return diag
|
50
tests/components/ecovacs/snapshots/test_diagnostics.ambr
Normal file
50
tests/components/ecovacs/snapshots/test_diagnostics.ambr
Normal file
@ -0,0 +1,50 @@
|
||||
# serializer version: 1
|
||||
# name: test_diagnostics
|
||||
dict({
|
||||
'config': dict({
|
||||
'data': dict({
|
||||
'country': 'IT',
|
||||
'password': '**REDACTED**',
|
||||
'username': '**REDACTED**',
|
||||
}),
|
||||
'disabled_by': None,
|
||||
'domain': 'ecovacs',
|
||||
'minor_version': 1,
|
||||
'options': dict({
|
||||
}),
|
||||
'pref_disable_new_entities': False,
|
||||
'pref_disable_polling': False,
|
||||
'source': 'user',
|
||||
'title': '**REDACTED**',
|
||||
'unique_id': None,
|
||||
'version': 1,
|
||||
}),
|
||||
'devices': list([
|
||||
dict({
|
||||
'UILogicId': 'DX_9G',
|
||||
'class': 'yna5xi',
|
||||
'company': 'eco-ng',
|
||||
'deviceName': 'DEEBOT OZMO 950 Series',
|
||||
'did': '**REDACTED**',
|
||||
'homeSort': 9999,
|
||||
'icon': 'https://portal-ww.ecouser.net/api/pim/file/get/606278df4a84d700082b39f1',
|
||||
'materialNo': '110-1820-0101',
|
||||
'model': 'DX9G',
|
||||
'name': '**REDACTED**',
|
||||
'nick': 'Ozmo 950',
|
||||
'otaUpgrade': dict({
|
||||
}),
|
||||
'pid': '5c19a91ca1e6ee000178224a',
|
||||
'product_category': 'DEEBOT',
|
||||
'resource': 'upQ6',
|
||||
'service': dict({
|
||||
'jmq': 'jmq-ngiot-eu.dc.ww.ecouser.net',
|
||||
'mqs': 'api-ngiot.dc-as.ww.ecouser.net',
|
||||
}),
|
||||
'status': 1,
|
||||
}),
|
||||
]),
|
||||
'legacy_devices': list([
|
||||
]),
|
||||
})
|
||||
# ---
|
22
tests/components/ecovacs/test_diagnostics.py
Normal file
22
tests/components/ecovacs/test_diagnostics.py
Normal file
@ -0,0 +1,22 @@
|
||||
"""Tests for diagnostics data."""
|
||||
|
||||
from syrupy.assertion import SnapshotAssertion
|
||||
from syrupy.filters import props
|
||||
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
from tests.components.diagnostics import get_diagnostics_for_config_entry
|
||||
from tests.typing import ClientSessionGenerator
|
||||
|
||||
|
||||
async def test_diagnostics(
|
||||
hass: HomeAssistant,
|
||||
hass_client: ClientSessionGenerator,
|
||||
init_integration: MockConfigEntry,
|
||||
snapshot: SnapshotAssertion,
|
||||
) -> None:
|
||||
"""Test diagnostics."""
|
||||
assert await get_diagnostics_for_config_entry(
|
||||
hass, hass_client, init_integration
|
||||
) == snapshot(exclude=props("entry_id"))
|
Loading…
x
Reference in New Issue
Block a user