mirror of
https://github.com/home-assistant/core.git
synced 2025-04-25 17:57:55 +00:00
Improve enphase_envoy diagnostics error handling to retain collected data (#142255)
Improve enphase_envoy Diagnostics error handling to retain collected data
This commit is contained in:
parent
ae0f27c42f
commit
6da37691ff
@ -66,16 +66,19 @@ async def _get_fixture_collection(envoy: Envoy, serial: str) -> dict[str, Any]:
|
|||||||
]
|
]
|
||||||
|
|
||||||
for end_point in end_points:
|
for end_point in end_points:
|
||||||
response = await envoy.request(end_point)
|
try:
|
||||||
fixture_data[end_point] = response.text.replace("\n", "").replace(
|
response = await envoy.request(end_point)
|
||||||
serial, CLEAN_TEXT
|
fixture_data[end_point] = response.text.replace("\n", "").replace(
|
||||||
)
|
serial, CLEAN_TEXT
|
||||||
fixture_data[f"{end_point}_log"] = json_dumps(
|
)
|
||||||
{
|
fixture_data[f"{end_point}_log"] = json_dumps(
|
||||||
"headers": dict(response.headers.items()),
|
{
|
||||||
"code": response.status_code,
|
"headers": dict(response.headers.items()),
|
||||||
}
|
"code": response.status_code,
|
||||||
)
|
}
|
||||||
|
)
|
||||||
|
except EnvoyError as err:
|
||||||
|
fixture_data[f"{end_point}_log"] = {"Error": repr(err)}
|
||||||
return fixture_data
|
return fixture_data
|
||||||
|
|
||||||
|
|
||||||
@ -160,10 +163,7 @@ async def async_get_config_entry_diagnostics(
|
|||||||
|
|
||||||
fixture_data: dict[str, Any] = {}
|
fixture_data: dict[str, Any] = {}
|
||||||
if entry.options.get(OPTION_DIAGNOSTICS_INCLUDE_FIXTURES, False):
|
if entry.options.get(OPTION_DIAGNOSTICS_INCLUDE_FIXTURES, False):
|
||||||
try:
|
fixture_data = await _get_fixture_collection(envoy=envoy, serial=old_serial)
|
||||||
fixture_data = await _get_fixture_collection(envoy=envoy, serial=old_serial)
|
|
||||||
except EnvoyError as err:
|
|
||||||
fixture_data["Error"] = repr(err)
|
|
||||||
|
|
||||||
diagnostic_data: dict[str, Any] = {
|
diagnostic_data: dict[str, Any] = {
|
||||||
"config_entry": async_redact_data(entry.as_dict(), TO_REDACT),
|
"config_entry": async_redact_data(entry.as_dict(), TO_REDACT),
|
||||||
|
@ -1373,7 +1373,66 @@
|
|||||||
]),
|
]),
|
||||||
}),
|
}),
|
||||||
'fixtures': dict({
|
'fixtures': dict({
|
||||||
'Error': "EnvoyError('Test')",
|
'/admin/lib/tariff_log': dict({
|
||||||
|
'Error': "EnvoyError('Test')",
|
||||||
|
}),
|
||||||
|
'/api/v1/production/inverters_log': dict({
|
||||||
|
'Error': "EnvoyError('Test')",
|
||||||
|
}),
|
||||||
|
'/api/v1/production_log': dict({
|
||||||
|
'Error': "EnvoyError('Test')",
|
||||||
|
}),
|
||||||
|
'/info_log': dict({
|
||||||
|
'Error': "EnvoyError('Test')",
|
||||||
|
}),
|
||||||
|
'/ivp/ensemble/dry_contacts_log': dict({
|
||||||
|
'Error': "EnvoyError('Test')",
|
||||||
|
}),
|
||||||
|
'/ivp/ensemble/generator_log': dict({
|
||||||
|
'Error': "EnvoyError('Test')",
|
||||||
|
}),
|
||||||
|
'/ivp/ensemble/inventory_log': dict({
|
||||||
|
'Error': "EnvoyError('Test')",
|
||||||
|
}),
|
||||||
|
'/ivp/ensemble/power_log': dict({
|
||||||
|
'Error': "EnvoyError('Test')",
|
||||||
|
}),
|
||||||
|
'/ivp/ensemble/secctrl_log': dict({
|
||||||
|
'Error': "EnvoyError('Test')",
|
||||||
|
}),
|
||||||
|
'/ivp/ensemble/status_log': dict({
|
||||||
|
'Error': "EnvoyError('Test')",
|
||||||
|
}),
|
||||||
|
'/ivp/meters/readings_log': dict({
|
||||||
|
'Error': "EnvoyError('Test')",
|
||||||
|
}),
|
||||||
|
'/ivp/meters_log': dict({
|
||||||
|
'Error': "EnvoyError('Test')",
|
||||||
|
}),
|
||||||
|
'/ivp/sc/pvlimit_log': dict({
|
||||||
|
'Error': "EnvoyError('Test')",
|
||||||
|
}),
|
||||||
|
'/ivp/ss/dry_contact_settings_log': dict({
|
||||||
|
'Error': "EnvoyError('Test')",
|
||||||
|
}),
|
||||||
|
'/ivp/ss/gen_config_log': dict({
|
||||||
|
'Error': "EnvoyError('Test')",
|
||||||
|
}),
|
||||||
|
'/ivp/ss/gen_schedule_log': dict({
|
||||||
|
'Error': "EnvoyError('Test')",
|
||||||
|
}),
|
||||||
|
'/ivp/ss/pel_settings_log': dict({
|
||||||
|
'Error': "EnvoyError('Test')",
|
||||||
|
}),
|
||||||
|
'/production.json?details=1_log': dict({
|
||||||
|
'Error': "EnvoyError('Test')",
|
||||||
|
}),
|
||||||
|
'/production.json_log': dict({
|
||||||
|
'Error': "EnvoyError('Test')",
|
||||||
|
}),
|
||||||
|
'/production_log': dict({
|
||||||
|
'Error': "EnvoyError('Test')",
|
||||||
|
}),
|
||||||
}),
|
}),
|
||||||
'raw_data': dict({
|
'raw_data': dict({
|
||||||
'varies_by': 'firmware_version',
|
'varies_by': 'firmware_version',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user