1
0
mirror of https://github.com/home-assistant/core.git synced 2026-04-18 16:06:42 +01:00

Redact utility account id in Opower diagnostics (#165145)

This commit is contained in:
tronikos
2026-03-15 11:56:36 -07:00
committed by GitHub
parent a433a163a3
commit cc45201f2d
2 changed files with 47 additions and 43 deletions

View File

@@ -18,6 +18,7 @@ TO_REDACT = {
CONF_TOTP_SECRET,
# Title contains the username/email
"title",
"utility_account_id",
}
@@ -27,10 +28,11 @@ async def async_get_config_entry_diagnostics(
"""Return diagnostics for a config entry."""
coordinator = entry.runtime_data
return {
"entry": async_redact_data(entry.as_dict(), TO_REDACT),
"data": {
account_id: {
return async_redact_data(
{
"entry": entry.as_dict(),
"data": [
{
"account": {
"utility_account_id": account.utility_account_id,
"meter_type": account.meter_type.name,
@@ -63,7 +65,9 @@ async def async_get_config_entry_diagnostics(
data.last_updated.isoformat() if data.last_updated else None
),
}
for account_id, data in coordinator.data.items()
for data in coordinator.data.values()
for account in (data.account,)
],
},
}
TO_REDACT,
)

View File

@@ -1,12 +1,12 @@
# serializer version: 1
# name: test_diagnostics
dict({
'data': dict({
'111111': dict({
'data': list([
dict({
'account': dict({
'meter_type': 'ELEC',
'read_resolution': 'HOUR',
'utility_account_id': '111111',
'utility_account_id': '**REDACTED**',
}),
'forecast': dict({
'cost_to_date': 20.0,
@@ -23,11 +23,11 @@
'last_changed': None,
'last_updated': '2026-03-07T23:00:00+00:00',
}),
'222222': dict({
dict({
'account': dict({
'meter_type': 'GAS',
'read_resolution': 'DAY',
'utility_account_id': '222222',
'utility_account_id': '**REDACTED**',
}),
'forecast': dict({
'cost_to_date': 15.0,
@@ -44,7 +44,7 @@
'last_changed': None,
'last_updated': '2026-03-07T23:00:00+00:00',
}),
}),
]),
'entry': dict({
'created_at': '2026-03-07T23:00:00+00:00',
'data': dict({