Handle missing keys in Honeywell (#98392)

This commit is contained in:
mkmer 2023-08-16 12:59:34 -04:00 committed by GitHub
parent 5bf80a0f6d
commit 3e1d2a1000
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 7 deletions

View file

@ -146,13 +146,13 @@ class HoneywellUSThermostat(ClimateEntity):
| ClimateEntityFeature.TARGET_TEMPERATURE_RANGE | ClimateEntityFeature.TARGET_TEMPERATURE_RANGE
) )
if device._data["canControlHumidification"]: if device._data.get("canControlHumidification"):
self._attr_supported_features |= ClimateEntityFeature.TARGET_HUMIDITY self._attr_supported_features |= ClimateEntityFeature.TARGET_HUMIDITY
if device.raw_ui_data["SwitchEmergencyHeatAllowed"]: if device.raw_ui_data.get("SwitchEmergencyHeatAllowed"):
self._attr_supported_features |= ClimateEntityFeature.AUX_HEAT self._attr_supported_features |= ClimateEntityFeature.AUX_HEAT
if not device._data["hasFan"]: if not device._data.get("hasFan"):
return return
# not all honeywell fans support all modes # not all honeywell fans support all modes

View file

@ -20,6 +20,7 @@ from homeassistant.helpers.device_registry import DeviceInfo
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import StateType from homeassistant.helpers.typing import StateType
from . import HoneywellData
from .const import DOMAIN, HUMIDITY_STATUS_KEY, TEMPERATURE_STATUS_KEY from .const import DOMAIN, HUMIDITY_STATUS_KEY, TEMPERATURE_STATUS_KEY
@ -71,7 +72,7 @@ async def async_setup_entry(
async_add_entities: AddEntitiesCallback, async_add_entities: AddEntitiesCallback,
) -> None: ) -> None:
"""Set up the Honeywell thermostat.""" """Set up the Honeywell thermostat."""
data = hass.data[DOMAIN][config_entry.entry_id] data: HoneywellData = hass.data[DOMAIN][config_entry.entry_id]
sensors = [] sensors = []
for device in data.devices.values(): for device in data.devices.values():

View file

@ -48,13 +48,13 @@ FAN_ACTION = "fan_action"
PRESET_HOLD = "Hold" PRESET_HOLD = "Hold"
async def test_no_thermostats( async def test_no_thermostat_options(
hass: HomeAssistant, device: MagicMock, config_entry: MagicMock hass: HomeAssistant, device: MagicMock, config_entry: MagicMock
) -> None: ) -> None:
"""Test the setup of the climate entities when there are no appliances available.""" """Test the setup of the climate entities when there are no additional options available."""
device._data = {} device._data = {}
await init_integration(hass, config_entry) await init_integration(hass, config_entry)
assert len(hass.states.async_all()) == 0 assert len(hass.states.async_all()) == 1
async def test_static_attributes( async def test_static_attributes(