-
-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #55 from BottlecapDave/develop
diagnostic information
- Loading branch information
Showing
2 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
"""Diagnostics support.""" | ||
import logging | ||
|
||
from homeassistant.components.diagnostics import async_redact_data | ||
|
||
from .const import ( | ||
DOMAIN, | ||
|
||
DATA_ACCOUNT_ID, | ||
DATA_CLIENT | ||
) | ||
|
||
_LOGGER = logging.getLogger(__name__) | ||
|
||
async def async_get_device_diagnostics(hass, config_entry, device): | ||
"""Return diagnostics for a device.""" | ||
|
||
client = hass.data[DOMAIN][DATA_CLIENT] | ||
|
||
_LOGGER.info('Retrieving account details for diagnostics...') | ||
|
||
account_info = await client.async_get_account(hass.data[DOMAIN][DATA_ACCOUNT_ID]) | ||
|
||
points_length = len(account_info["electricity_meter_points"]) | ||
if points_length > 0: | ||
for point_index in range(points_length): | ||
account_info["electricity_meter_points"][point_index] = async_redact_data(account_info["electricity_meter_points"][point_index], { "mpan" }) | ||
meters_length = len(account_info["electricity_meter_points"][point_index]["meters"]) | ||
for meter_index in range(meters_length): | ||
account_info["electricity_meter_points"][point_index]["meters"][meter_index] = async_redact_data(account_info["electricity_meter_points"][point_index]["meters"][meter_index], { "serial_number" }) | ||
|
||
points_length = len(account_info["gas_meter_points"]) | ||
if points_length > 0: | ||
for point_index in range(points_length): | ||
account_info["gas_meter_points"][point_index] = async_redact_data(account_info["gas_meter_points"][point_index], { "mprn" }) | ||
meters_length = len(account_info["gas_meter_points"][point_index]["meters"]) | ||
for meter_index in range(meters_length): | ||
account_info["gas_meter_points"][point_index]["meters"][meter_index] = async_redact_data(account_info["gas_meter_points"][point_index]["meters"][meter_index], { "serial_number" }) | ||
|
||
_LOGGER.info(f'Returning diagnostic details; {len(account_info["electricity_meter_points"])} electricity meter point(s), {len(account_info["gas_meter_points"])} gas meter point(s)') | ||
|
||
return account_info |