Update A. O. Smith integration to reflect upstream API changes (#127678)

This commit is contained in:
Brandon Rothweiler 2024-10-06 11:16:29 -04:00 committed by GitHub
parent 3cda93d001
commit b4dfd08bc4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 16 additions and 42 deletions

View File

@ -5,5 +5,5 @@
"config_flow": true, "config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/aosmith", "documentation": "https://www.home-assistant.io/integrations/aosmith",
"iot_class": "cloud_polling", "iot_class": "cloud_polling",
"requirements": ["py-aosmith==1.0.8"] "requirements": ["py-aosmith==1.0.10"]
} }

View File

@ -3,7 +3,7 @@
from collections.abc import Callable from collections.abc import Callable
from dataclasses import dataclass from dataclasses import dataclass
from py_aosmith.models import Device as AOSmithDevice, HotWaterStatus from py_aosmith.models import Device as AOSmithDevice
from homeassistant.components.sensor import ( from homeassistant.components.sensor import (
SensorDeviceClass, SensorDeviceClass,
@ -11,7 +11,7 @@ from homeassistant.components.sensor import (
SensorEntityDescription, SensorEntityDescription,
SensorStateClass, SensorStateClass,
) )
from homeassistant.const import UnitOfEnergy from homeassistant.const import PERCENTAGE, UnitOfEnergy
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
@ -31,20 +31,11 @@ STATUS_ENTITY_DESCRIPTIONS: tuple[AOSmithStatusSensorEntityDescription, ...] = (
AOSmithStatusSensorEntityDescription( AOSmithStatusSensorEntityDescription(
key="hot_water_availability", key="hot_water_availability",
translation_key="hot_water_availability", translation_key="hot_water_availability",
device_class=SensorDeviceClass.ENUM, native_unit_of_measurement=PERCENTAGE,
options=["low", "medium", "high"], value_fn=lambda device: device.status.hot_water_status,
value_fn=lambda device: HOT_WATER_STATUS_MAP.get(
device.status.hot_water_status
),
), ),
) )
HOT_WATER_STATUS_MAP: dict[HotWaterStatus, str] = {
HotWaterStatus.LOW: "low",
HotWaterStatus.MEDIUM: "medium",
HotWaterStatus.HIGH: "high",
}
async def async_setup_entry( async def async_setup_entry(
hass: HomeAssistant, hass: HomeAssistant,

View File

@ -28,12 +28,7 @@
"entity": { "entity": {
"sensor": { "sensor": {
"hot_water_availability": { "hot_water_availability": {
"name": "Hot water availability", "name": "Hot water availability"
"state": {
"low": "Low",
"medium": "Medium",
"high": "High"
}
}, },
"energy_usage": { "energy_usage": {
"name": "Energy usage" "name": "Energy usage"

View File

@ -1662,7 +1662,7 @@ pushover_complete==1.1.1
pvo==2.1.1 pvo==2.1.1
# homeassistant.components.aosmith # homeassistant.components.aosmith
py-aosmith==1.0.8 py-aosmith==1.0.10
# homeassistant.components.canary # homeassistant.components.canary
py-canary==0.5.4 py-canary==0.5.4

View File

@ -1357,7 +1357,7 @@ pushover_complete==1.1.1
pvo==2.1.1 pvo==2.1.1
# homeassistant.components.aosmith # homeassistant.components.aosmith
py-aosmith==1.0.8 py-aosmith==1.0.10
# homeassistant.components.canary # homeassistant.components.canary
py-canary==0.5.4 py-canary==0.5.4

View File

@ -10,7 +10,6 @@ from py_aosmith.models import (
DeviceType, DeviceType,
EnergyUseData, EnergyUseData,
EnergyUseHistoryEntry, EnergyUseHistoryEntry,
HotWaterStatus,
OperationMode, OperationMode,
SupportedOperationModeInfo, SupportedOperationModeInfo,
) )
@ -93,7 +92,7 @@ def build_device_fixture(
temperature_setpoint_pending=setpoint_pending, temperature_setpoint_pending=setpoint_pending,
temperature_setpoint_previous=130, temperature_setpoint_previous=130,
temperature_setpoint_maximum=130, temperature_setpoint_maximum=130,
hot_water_status=HotWaterStatus.LOW, hot_water_status=90,
), ),
) )

View File

@ -103,7 +103,7 @@
} }
], ],
"firmwareVersion": "2.14", "firmwareVersion": "2.14",
"hotWaterStatus": "HIGH", "hotWaterStatus": 10,
"isAdvancedLoadUpMore": false, "isAdvancedLoadUpMore": false,
"isCtaUcmPresent": false, "isCtaUcmPresent": false,
"isDemandResponsePaused": false, "isDemandResponsePaused": false,

View File

@ -43,7 +43,7 @@
'error': '', 'error': '',
'firmwareVersion': '2.14', 'firmwareVersion': '2.14',
'heaterSsid': '**REDACTED**', 'heaterSsid': '**REDACTED**',
'hotWaterStatus': 'HIGH', 'hotWaterStatus': 10,
'isAdvancedLoadUpMore': False, 'isAdvancedLoadUpMore': False,
'isCtaUcmPresent': False, 'isCtaUcmPresent': False,
'isDemandResponsePaused': False, 'isDemandResponsePaused': False,

View File

@ -58,13 +58,7 @@
'aliases': set({ 'aliases': set({
}), }),
'area_id': None, 'area_id': None,
'capabilities': dict({ 'capabilities': None,
'options': list([
'low',
'medium',
'high',
]),
}),
'config_entry_id': <ANY>, 'config_entry_id': <ANY>,
'device_class': None, 'device_class': None,
'device_id': <ANY>, 'device_id': <ANY>,
@ -81,7 +75,7 @@
'name': None, 'name': None,
'options': dict({ 'options': dict({
}), }),
'original_device_class': <SensorDeviceClass.ENUM: 'enum'>, 'original_device_class': None,
'original_icon': None, 'original_icon': None,
'original_name': 'Hot water availability', 'original_name': 'Hot water availability',
'platform': 'aosmith', 'platform': 'aosmith',
@ -89,25 +83,20 @@
'supported_features': 0, 'supported_features': 0,
'translation_key': 'hot_water_availability', 'translation_key': 'hot_water_availability',
'unique_id': 'hot_water_availability_junctionId', 'unique_id': 'hot_water_availability_junctionId',
'unit_of_measurement': None, 'unit_of_measurement': '%',
}) })
# --- # ---
# name: test_state[sensor.my_water_heater_hot_water_availability-state] # name: test_state[sensor.my_water_heater_hot_water_availability-state]
StateSnapshot({ StateSnapshot({
'attributes': ReadOnlyDict({ 'attributes': ReadOnlyDict({
'device_class': 'enum',
'friendly_name': 'My water heater Hot water availability', 'friendly_name': 'My water heater Hot water availability',
'options': list([ 'unit_of_measurement': '%',
'low',
'medium',
'high',
]),
}), }),
'context': <ANY>, 'context': <ANY>,
'entity_id': 'sensor.my_water_heater_hot_water_availability', 'entity_id': 'sensor.my_water_heater_hot_water_availability',
'last_changed': <ANY>, 'last_changed': <ANY>,
'last_reported': <ANY>, 'last_reported': <ANY>,
'last_updated': <ANY>, 'last_updated': <ANY>,
'state': 'low', 'state': '90',
}) })
# --- # ---