Fix access of missing zwave_js climate unit value (#47380)

This commit is contained in:
Martin Hjelmare 2021-03-04 22:11:38 +01:00 committed by GitHub
parent d64fe6ea32
commit 5ced7395f3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 300 additions and 2 deletions

View file

@ -118,7 +118,7 @@ class ZWaveClimate(ZWaveBaseEntity, ClimateEntity):
super().__init__(config_entry, client, info)
self._hvac_modes: Dict[str, Optional[int]] = {}
self._hvac_presets: Dict[str, Optional[int]] = {}
self._unit_value: ZwaveValue = None
self._unit_value: Optional[ZwaveValue] = None
self._current_mode = self.get_zwave_value(
THERMOSTAT_MODE_PROPERTY, command_class=CommandClass.THERMOSTAT_MODE
@ -215,7 +215,11 @@ class ZWaveClimate(ZWaveBaseEntity, ClimateEntity):
@property
def temperature_unit(self) -> str:
"""Return the unit of measurement used by the platform."""
if "f" in self._unit_value.metadata.unit.lower():
if (
self._unit_value
and self._unit_value.metadata.unit
and "f" in self._unit_value.metadata.unit.lower()
):
return TEMP_FAHRENHEIT
return TEMP_CELSIUS