Skip to content

Commit

Permalink
Add diagnostics to A. O. Smith integration (home-assistant#106343)
Browse files Browse the repository at this point in the history
* Add diagnostics to A. O. Smith integration

* Bump py-aosmith to 1.0.4

* remove redactions from test fixture
  • Loading branch information
bdr99 authored and jmuf committed Jan 7, 2024
1 parent 091d531 commit 3adc8c5
Show file tree
Hide file tree
Showing 8 changed files with 570 additions and 3 deletions.
39 changes: 39 additions & 0 deletions homeassistant/components/aosmith/diagnostics.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
"""Diagnostics support for A. O. Smith."""
from __future__ import annotations

from typing import Any

from homeassistant.components.diagnostics import async_redact_data
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant

from . import AOSmithData
from .const import DOMAIN

TO_REDACT = {
"address",
"city",
"contactId",
"dsn",
"email",
"firstName",
"heaterSsid",
"id",
"lastName",
"phone",
"postalCode",
"registeredOwner",
"serial",
"ssid",
"state",
}


async def async_get_config_entry_diagnostics(
hass: HomeAssistant, config_entry: ConfigEntry
) -> dict[str, Any]:
"""Return diagnostics for a config entry."""
data: AOSmithData = hass.data[DOMAIN][config_entry.entry_id]

all_device_info = await data.client.get_all_device_info()
return async_redact_data(all_device_info, TO_REDACT)
2 changes: 1 addition & 1 deletion homeassistant/components/aosmith/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
"config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/aosmith",
"iot_class": "cloud_polling",
"requirements": ["py-aosmith==1.0.1"]
"requirements": ["py-aosmith==1.0.4"]
}
2 changes: 1 addition & 1 deletion requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1554,7 +1554,7 @@ pushover_complete==1.1.1
pvo==2.1.1

# homeassistant.components.aosmith
py-aosmith==1.0.1
py-aosmith==1.0.4

# homeassistant.components.canary
py-canary==0.5.3
Expand Down
2 changes: 1 addition & 1 deletion requirements_test_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1201,7 +1201,7 @@ pushover_complete==1.1.1
pvo==2.1.1

# homeassistant.components.aosmith
py-aosmith==1.0.1
py-aosmith==1.0.4

# homeassistant.components.canary
py-canary==0.5.3
Expand Down
6 changes: 6 additions & 0 deletions tests/components/aosmith/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,16 @@ async def mock_client(get_devices_fixture: str) -> Generator[MagicMock, None, No
get_energy_use_fixture = load_json_object_fixture(
"get_energy_use_data.json", DOMAIN
)
get_all_device_info_fixture = load_json_object_fixture(
"get_all_device_info.json", DOMAIN
)

client_mock = MagicMock(AOSmithAPIClient)
client_mock.get_devices = AsyncMock(return_value=get_devices_fixture)
client_mock.get_energy_use_data = AsyncMock(return_value=get_energy_use_fixture)
client_mock.get_all_device_info = AsyncMock(
return_value=get_all_device_info_fixture
)

return client_mock

Expand Down
247 changes: 247 additions & 0 deletions tests/components/aosmith/fixtures/get_all_device_info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,247 @@
{
"devices": [
{
"alertSettings": {
"faultCode": {
"major": {
"email": true,
"sms": false
},
"minor": {
"email": false,
"sms": false
}
},
"operatingSetPoint": {
"email": false,
"sms": false
},
"tankTemperature": {
"highTemperature": {
"email": false,
"sms": false,
"value": 160
},
"lowTemperature": {
"email": false,
"sms": false,
"value": 120
}
}
},
"brand": "aosmith",
"deviceType": "NEXT_GEN_HEAT_PUMP",
"dsn": "dsn",
"hardware": {
"hasBluetooth": true,
"interface": "CONTROL_PANEL"
},
"id": "id",
"install": {
"address": "sample_address",
"city": "sample_city",
"country": "United States",
"date": "2023-09-29",
"email": "sample_email",
"group": "Residential",
"location": "Basement",
"phone": "sample_phone",
"postalCode": "sample_postal_code",
"professional": false,
"registeredOwner": "sample_owner",
"registrationDate": "2023-12-24",
"state": "sample_state"
},
"isRegistered": true,
"junctionId": "junctionId",
"lastUpdate": 1703386473737,
"model": "HPTS-50 200 202172000",
"name": "Water Heater",
"permissions": "USER",
"productId": "100350404",
"serial": "sample_serial",
"users": [
{
"contactId": "sample_contact_id",
"email": "sample_email",
"firstName": "sample_first_name",
"isSelf": true,
"lastName": "sample_last_name",
"permissions": "USER"
}
],
"data": {
"activeAlerts": [],
"alertHistory": [],
"isOnline": true,
"isWifi": true,
"lastUpdate": 1703138389000,
"signalStrength": null,
"heaterSsid": "sample_heater_ssid",
"ssid": "sample_ssid",
"temperatureSetpoint": 145,
"temperatureSetpointPending": false,
"temperatureSetpointPrevious": 145,
"temperatureSetpointMaximum": 145,
"error": "",
"modes": [
{
"mode": "HYBRID",
"controls": null
},
{
"mode": "HEAT_PUMP",
"controls": null
},
{
"mode": "ELECTRIC",
"controls": "SELECT_DAYS"
},
{
"mode": "VACATION",
"controls": "SELECT_DAYS"
}
],
"firmwareVersion": "2.14",
"hotWaterStatus": "HIGH",
"isAdvancedLoadUpMore": false,
"isCtaUcmPresent": false,
"isDemandResponsePaused": false,
"isEnrolled": false,
"mode": "HEAT_PUMP",
"modePending": false,
"vacationModeRemainingDays": 0,
"electricModeRemainingDays": 100,
"isLowes": false,
"canEditTimeOfUse": false,
"timeOfUseData": null,
"consumerScheduleData": null
}
}
],
"energy_use_data": {
"junctionId": {
"average": 2.4744000000000006,
"graphData": [
{
"date": "2023-11-26T04:00:00.000Z",
"kwh": 0.936
},
{
"date": "2023-11-27T04:00:00.000Z",
"kwh": 4.248
},
{
"date": "2023-11-28T04:00:00.000Z",
"kwh": 1.002
},
{
"date": "2023-11-29T04:00:00.000Z",
"kwh": 3.078
},
{
"date": "2023-11-30T04:00:00.000Z",
"kwh": 1.896
},
{
"date": "2023-12-01T04:00:00.000Z",
"kwh": 1.98
},
{
"date": "2023-12-02T04:00:00.000Z",
"kwh": 2.112
},
{
"date": "2023-12-03T04:00:00.000Z",
"kwh": 3.222
},
{
"date": "2023-12-04T04:00:00.000Z",
"kwh": 4.254
},
{
"date": "2023-12-05T04:00:00.000Z",
"kwh": 4.05
},
{
"date": "2023-12-06T04:00:00.000Z",
"kwh": 3.312
},
{
"date": "2023-12-07T04:00:00.000Z",
"kwh": 2.334
},
{
"date": "2023-12-08T04:00:00.000Z",
"kwh": 2.418
},
{
"date": "2023-12-09T04:00:00.000Z",
"kwh": 2.19
},
{
"date": "2023-12-10T04:00:00.000Z",
"kwh": 3.786
},
{
"date": "2023-12-11T04:00:00.000Z",
"kwh": 5.292
},
{
"date": "2023-12-12T04:00:00.000Z",
"kwh": 1.38
},
{
"date": "2023-12-13T04:00:00.000Z",
"kwh": 3.324
},
{
"date": "2023-12-14T04:00:00.000Z",
"kwh": 1.092
},
{
"date": "2023-12-15T04:00:00.000Z",
"kwh": 0.606
},
{
"date": "2023-12-16T04:00:00.000Z",
"kwh": 0
},
{
"date": "2023-12-17T04:00:00.000Z",
"kwh": 2.838
},
{
"date": "2023-12-18T04:00:00.000Z",
"kwh": 2.382
},
{
"date": "2023-12-19T04:00:00.000Z",
"kwh": 2.904
},
{
"date": "2023-12-20T04:00:00.000Z",
"kwh": 1.914
},
{
"date": "2023-12-21T04:00:00.000Z",
"kwh": 3.93
},
{
"date": "2023-12-22T04:00:00.000Z",
"kwh": 3.666
},
{
"date": "2023-12-23T04:00:00.000Z",
"kwh": 2.766
},
{
"date": "2023-12-24T04:00:00.000Z",
"kwh": 1.32
}
],
"lifetimeKwh": 203.259,
"startDate": "Nov 26"
}
}
}
Loading

0 comments on commit 3adc8c5

Please sign in to comment.