From 0907eea44206543b64b3f6982d1643c430fb876c Mon Sep 17 00:00:00 2001 From: turbokongen Date: Fri, 2 Sep 2016 07:17:41 +0200 Subject: [PATCH] move units to temperature for climate zwave. wrong state was sent to mqtt cove --- homeassistant/components/climate/zwave.py | 9 ++++++++- homeassistant/components/cover/mqtt.py | 16 ++++++++-------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/homeassistant/components/climate/zwave.py b/homeassistant/components/climate/zwave.py index 11704b06fdf..530e3ea028f 100755 --- a/homeassistant/components/climate/zwave.py +++ b/homeassistant/components/climate/zwave.py @@ -12,6 +12,7 @@ from homeassistant.components.climate import ClimateDevice from homeassistant.components.zwave import ( ATTR_NODE_ID, ATTR_VALUE_ID, ZWaveDeviceEntity) from homeassistant.components import zwave +from homeassistant.const import TEMP_CELSIUS, TEMP_FAHRENHEIT _LOGGER = logging.getLogger(__name__) @@ -128,6 +129,7 @@ class ZWaveClimate(ZWaveDeviceEntity, ClimateDevice): class_id=COMMAND_CLASS_SENSOR_MULTILEVEL).values(): if value.label == 'Temperature': self._current_temperature = int(value.data) + self._unit = value.units # Fan Mode for value in self._node.get_values( class_id=COMMAND_CLASS_THERMOSTAT_FAN_MODE).values(): @@ -186,7 +188,12 @@ class ZWaveClimate(ZWaveDeviceEntity, ClimateDevice): @property def unit_of_measurement(self): """Return the unit of measurement.""" - return self._unit + if self._unit == 'C': + return TEMP_CELSIUS + elif self._unit == 'F': + return TEMP_FAHRENHEIT + else: + return self._unit @property def current_temperature(self): diff --git a/homeassistant/components/cover/mqtt.py b/homeassistant/components/cover/mqtt.py index a632fb46ba3..b47bcf124e1 100644 --- a/homeassistant/components/cover/mqtt.py +++ b/homeassistant/components/cover/mqtt.py @@ -96,13 +96,17 @@ class MqttCover(CoverDevice): payload = template.render_with_possible_json_value( hass, value_template, payload) if payload == self._state_open: - self._state = True + self._state = False + _LOGGER.warning("state=%s", int(self._state)) self.update_ha_state() elif payload == self._state_closed: - self._state = False + self._state = True self.update_ha_state() elif payload.isnumeric() and 0 <= int(payload) <= 100: - self._state = int(payload) + if int(payload) > 0: + self._state = False + else: + self._state = True self._position = int(payload) self.update_ha_state() else: @@ -129,11 +133,7 @@ class MqttCover(CoverDevice): @property def is_closed(self): """Return if the cover is closed.""" - if self.current_cover_position is not None: - if self.current_cover_position > 0: - return False - else: - return True + return self._state @property def current_cover_position(self):