diff --git a/homeassistant/components/climate/zwave.py b/homeassistant/components/climate/zwave.py index c8425ab4e8ce8d..b29c6a92b63843 100755 --- a/homeassistant/components/climate/zwave.py +++ b/homeassistant/components/climate/zwave.py @@ -12,7 +12,6 @@ from homeassistant.components.zwave import ( ATTR_NODE_ID, ATTR_VALUE_ID, ZWaveDeviceEntity) from homeassistant.components import zwave -from homeassistant.const import (TEMP_FAHRENHEIT, TEMP_CELSIUS) _LOGGER = logging.getLogger(__name__) @@ -59,11 +58,11 @@ def setup_platform(hass, config, add_devices, discovery_info=None): _LOGGER.debug("No discovery_info=%s or no NETWORK=%s", discovery_info, zwave.NETWORK) return - + temp_unit = hass.config.units.temperature_unit node = zwave.NETWORK.nodes[discovery_info[ATTR_NODE_ID]] value = node.values[discovery_info[ATTR_VALUE_ID]] value.set_change_verified(False) - add_devices([ZWaveClimate(value)]) + add_devices([ZWaveClimate(value, temp_unit)]) _LOGGER.debug("discovery_info=%s and zwave.NETWORK=%s", discovery_info, zwave.NETWORK) @@ -73,7 +72,7 @@ class ZWaveClimate(ZWaveDeviceEntity, ClimateDevice): """Represents a ZWave Climate device.""" # pylint: disable=too-many-public-methods, too-many-instance-attributes - def __init__(self, value): + def __init__(self, value, temp_unit): """Initialize the zwave climate device.""" from openzwave.network import ZWaveNetwork from pydispatch import dispatcher @@ -87,7 +86,8 @@ def __init__(self, value): self._fan_list = None self._current_swing_mode = None self._swing_list = None - self._unit = None + self._unit = temp_unit + _LOGGER.debug("temp_unit is %s", self._unit) self._zxt_120 = None self.update_properties() # register listener @@ -115,18 +115,6 @@ def value_changed(self, value): def update_properties(self): """Callback on data change for the registered node/value pair.""" - # Set point - for value in self._node.get_values( - class_id=COMMAND_CLASS_THERMOSTAT_SETPOINT).values(): - self._unit = value.units - if self.current_operation is not None: - if SET_TEMP_TO_INDEX.get(self._current_operation) \ - != value.index: - continue - if self._zxt_120: - continue - self._target_temperature = int(value.data) - # Operation Mode for value in self._node.get_values( class_id=COMMAND_CLASS_THERMOSTAT_MODE).values(): @@ -158,6 +146,17 @@ def update_properties(self): _LOGGER.debug("self._swing_list=%s", self._swing_list) _LOGGER.debug("self._current_swing_mode=%s", self._current_swing_mode) + # Set point + for value in self._node.get_values( + class_id=COMMAND_CLASS_THERMOSTAT_SETPOINT).values(): + if self.current_operation is not None: + if SET_TEMP_TO_INDEX.get(self._current_operation) \ + != value.index: + continue + self._unit = value.units + if self._zxt_120: + continue + self._target_temperature = int(value.data) @property def should_poll(self): @@ -187,14 +186,7 @@ def swing_list(self): @property def unit_of_measurement(self): """Return the unit of measurement.""" - unit = self._unit - if unit == 'C': - return TEMP_CELSIUS - elif unit == 'F': - return TEMP_FAHRENHEIT - else: - _LOGGER.exception("unit_of_measurement=%s is not valid", - unit) + return self._unit @property def current_temperature(self):