Compare commits

...

2 Commits

Author SHA1 Message Date
Franck Nijhof
c4d8c5f6ac Potential fix for pull request finding
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-04-16 05:50:16 +02:00
Franck Nijhof
099731a1b6 Improve Twente Milieu diagnostics with redacted config entry data 2026-04-16 03:34:51 +00:00
3 changed files with 64 additions and 23 deletions

View File

@@ -4,18 +4,33 @@ from __future__ import annotations
from typing import Any
from homeassistant.components.diagnostics import async_redact_data
from homeassistant.const import CONF_ID, CONF_UNIQUE_ID
from homeassistant.core import HomeAssistant
from .const import CONF_HOUSE_LETTER, CONF_HOUSE_NUMBER, CONF_POST_CODE
from .coordinator import TwenteMilieuConfigEntry
TO_REDACT = {
CONF_ID,
CONF_UNIQUE_ID,
CONF_POST_CODE,
CONF_HOUSE_NUMBER,
CONF_HOUSE_LETTER,
"title",
}
async def async_get_config_entry_diagnostics(
hass: HomeAssistant, entry: TwenteMilieuConfigEntry
) -> dict[str, Any]:
"""Return diagnostics for a config entry."""
return {
f"WasteType.{waste_type.name}": [
waste_date.isoformat() for waste_date in waste_dates
]
for waste_type, waste_dates in entry.runtime_data.data.items()
"entry": async_redact_data(entry.as_dict(), TO_REDACT),
"data": {
f"WasteType.{waste_type.name}": [
waste_date.isoformat() for waste_date in waste_dates
]
for waste_type, waste_dates in entry.runtime_data.data.items()
},
}

View File

@@ -1,20 +1,46 @@
# serializer version: 1
# name: test_diagnostics
dict({
'WasteType.NON_RECYCLABLE': list([
'2021-11-01',
'2021-12-01',
]),
'WasteType.ORGANIC': list([
'2021-11-02',
]),
'WasteType.PACKAGES': list([
'2021-11-03',
]),
'WasteType.PAPER': list([
]),
'WasteType.TREE': list([
'2022-01-06',
]),
'data': dict({
'WasteType.NON_RECYCLABLE': list([
'2021-11-01',
'2021-12-01',
]),
'WasteType.ORGANIC': list([
'2021-11-02',
]),
'WasteType.PACKAGES': list([
'2021-11-03',
]),
'WasteType.PAPER': list([
]),
'WasteType.TREE': list([
'2022-01-06',
]),
}),
'entry': dict({
'data': dict({
'house_letter': '**REDACTED**',
'house_number': '**REDACTED**',
'id': '**REDACTED**',
'post_code': '**REDACTED**',
}),
'disabled_by': None,
'discovery_keys': dict({
}),
'domain': 'twentemilieu',
'entry_id': '01JWHZD0JS7ACCE0JA3ABCDEF1',
'minor_version': 1,
'options': dict({
}),
'pref_disable_new_entities': False,
'pref_disable_polling': False,
'source': 'user',
'subentries': list([
]),
'title': '1234AB 1',
'unique_id': '12345',
'version': 2,
}),
})
# ---

View File

@@ -1,6 +1,7 @@
"""Tests for the diagnostics data provided by the TwenteMilieu integration."""
from syrupy.assertion import SnapshotAssertion
from syrupy.filters import props
from homeassistant.core import HomeAssistant
@@ -16,7 +17,6 @@ async def test_diagnostics(
snapshot: SnapshotAssertion,
) -> None:
"""Test diagnostics."""
assert (
await get_diagnostics_for_config_entry(hass, hass_client, init_integration)
== snapshot
)
assert await get_diagnostics_for_config_entry(
hass, hass_client, init_integration
) == snapshot(exclude=props("created_at", "modified_at"))