Add current_humidity to Ecobee humidifier (#114753)

* Ecobee: add current_humidity to humidifier

* Ecobee: Add test for current_humidity property

* Update current_humidity handling in climate and
humidifier entity to support the ecobee API
not returning actualHumidity, which is an optional
value.
Also updated tests to add a thermostat which
covers a non-populated humidity. In passing,
set up the new test thermostat to cover a missing
condition where the code doens't recognize the
ecobee model number. This gets ecobee humidifier
test coverage to 100%
pull/113710/head^2
Brent Petit 2024-04-05 14:54:40 -05:00 committed by GitHub
parent 0214511b38
commit c9ce848b4b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 90 additions and 1 deletions

View File

@ -509,7 +509,10 @@ class Thermostat(ClimateEntity):
@property
def current_humidity(self) -> int | None:
"""Return the current humidity."""
return self.thermostat["runtime"]["actualHumidity"]
try:
return int(self.thermostat["runtime"]["actualHumidity"])
except KeyError:
return None
@property
def hvac_action(self):

View File

@ -110,6 +110,14 @@ class EcobeeHumidifier(HumidifierEntity):
"""Return the desired humidity set point."""
return int(self.thermostat["runtime"]["desiredHumidity"])
@property
def current_humidity(self) -> int | None:
"""Return the current humidity."""
try:
return int(self.thermostat["runtime"]["actualHumidity"])
except KeyError:
return None
def set_mode(self, mode):
"""Set humidifier mode (auto, off, manual)."""
if mode.lower() not in (self.available_modes):

View File

@ -139,6 +139,81 @@
]
}
]
},
{
"identifier": 8675307,
"name": "unknownEcobeeName",
"modelNumber": "unknownEcobeeModel",
"program": {
"climates": [
{
"name": "Climate1",
"climateRef": "c1"
},
{
"name": "Climate2",
"climateRef": "c2"
}
],
"currentClimateRef": "c1"
},
"runtime": {
"connected": true,
"actualTemperature": 300,
"desiredHeat": 400,
"desiredCool": 200,
"desiredFanMode": "on",
"desiredHumidity": 40
},
"settings": {
"hvacMode": "auto",
"heatStages": 1,
"coolStages": 1,
"fanMinOnTime": 10,
"heatCoolMinDelta": 50,
"holdAction": "nextTransition",
"ventilatorType": "none",
"ventilatorMinOnTimeHome": 20,
"ventilatorMinOnTimeAway": 10,
"isVentilatorTimerOn": false,
"hasHumidifier": true,
"humidifierMode": "manual",
"humidity": "30"
},
"equipmentStatus": "fan",
"events": [
{
"name": "Event1",
"running": true,
"type": "hold",
"holdClimateRef": "away",
"startDate": "2022-02-02",
"startTime": "11:00:00",
"endDate": "2022-01-01",
"endTime": "10:00:00"
}
],
"remoteSensors": [
{
"id": "rs:100",
"name": "Remote Sensor 1",
"type": "ecobee3_remote_sensor",
"code": "WKRP",
"inUse": false,
"capability": [
{
"id": "1",
"type": "temperature",
"value": "782"
},
{
"id": "2",
"type": "occupancy",
"value": "false"
}
]
}
]
}
]
}

View File

@ -7,6 +7,7 @@ import pytest
from homeassistant.components.ecobee.humidifier import MODE_MANUAL, MODE_OFF
from homeassistant.components.humidifier import (
ATTR_AVAILABLE_MODES,
ATTR_CURRENT_HUMIDITY,
ATTR_HUMIDITY,
ATTR_MAX_HUMIDITY,
ATTR_MIN_HUMIDITY,
@ -43,6 +44,8 @@ async def test_attributes(hass: HomeAssistant) -> None:
state = hass.states.get(DEVICE_ID)
assert state.state == STATE_ON
if state.attributes.get(ATTR_CURRENT_HUMIDITY):
assert state.attributes.get(ATTR_CURRENT_HUMIDITY) == 15
assert state.attributes.get(ATTR_MIN_HUMIDITY) == DEFAULT_MIN_HUMIDITY
assert state.attributes.get(ATTR_MAX_HUMIDITY) == DEFAULT_MAX_HUMIDITY
assert state.attributes.get(ATTR_HUMIDITY) == 40