From bea7d950cc7dcab9fe98b97db827d890f7e7436d Mon Sep 17 00:00:00 2001 From: magnusknutas Date: Sun, 4 Nov 2018 21:01:59 +0100 Subject: [PATCH 1/4] Melissa attributes --- homeassistant/components/climate/melissa.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/climate/melissa.py b/homeassistant/components/climate/melissa.py index bfb18fa0a4cc2..1b0fc2e3abeb5 100644 --- a/homeassistant/components/climate/melissa.py +++ b/homeassistant/components/climate/melissa.py @@ -113,8 +113,9 @@ def fan_list(self): @property def target_temperature(self): """Return the temperature we try to reach.""" - if self._cur_settings is not None: - return self._cur_settings[self._api.TEMP] + if self._cur_settings is None: + return None + return self._cur_settings[self._api.TEMP] @property def state(self): @@ -123,6 +124,15 @@ def state(self): return self.melissa_state_to_hass( self._cur_settings[self._api.STATE]) + @property + def state_attributes(self): + """Add the attributes that's available.""" + data = super(MelissaClimate, self).state_attributes + add_data = self._data.copy() + add_data.pop('temp') + data.update(add_data) + return data + @property def temperature_unit(self): """Return the unit of measurement which this thermostat uses.""" From a190646a7117ccdad03db222abd00e9fcddc4c75 Mon Sep 17 00:00:00 2001 From: magnusknutas Date: Mon, 5 Nov 2018 06:57:13 +0100 Subject: [PATCH 2/4] overide device_state_attributes rather than state_attributes --- homeassistant/components/climate/melissa.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/homeassistant/components/climate/melissa.py b/homeassistant/components/climate/melissa.py index 1b0fc2e3abeb5..d95d388e6a425 100644 --- a/homeassistant/components/climate/melissa.py +++ b/homeassistant/components/climate/melissa.py @@ -125,12 +125,10 @@ def state(self): self._cur_settings[self._api.STATE]) @property - def state_attributes(self): + def device_state_attributes(self): """Add the attributes that's available.""" - data = super(MelissaClimate, self).state_attributes - add_data = self._data.copy() - add_data.pop('temp') - data.update(add_data) + data = self._data.copy() + data.pop('temp') return data @property From e5bf3115f2093c539040ab58e21d530b15b0e85c Mon Sep 17 00:00:00 2001 From: magnusknutas Date: Mon, 5 Nov 2018 13:03:48 +0100 Subject: [PATCH 3/4] Selected attributes --- homeassistant/components/climate/melissa.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/climate/melissa.py b/homeassistant/components/climate/melissa.py index d95d388e6a425..14b65b1d34692 100644 --- a/homeassistant/components/climate/melissa.py +++ b/homeassistant/components/climate/melissa.py @@ -127,8 +127,9 @@ def state(self): @property def device_state_attributes(self): """Add the attributes that's available.""" - data = self._data.copy() - data.pop('temp') + data = dict() + if self._data: + data['humidity'] = self._data['humidity'] return data @property From bad7ff88f24e3428f5d003579806f79cba604fc5 Mon Sep 17 00:00:00 2001 From: magnusknutas Date: Mon, 5 Nov 2018 14:46:02 +0100 Subject: [PATCH 4/4] Adding current humidity rather than a state_attribute --- homeassistant/components/climate/melissa.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/homeassistant/components/climate/melissa.py b/homeassistant/components/climate/melissa.py index 14b65b1d34692..25beedfe0dd29 100644 --- a/homeassistant/components/climate/melissa.py +++ b/homeassistant/components/climate/melissa.py @@ -88,6 +88,12 @@ def current_temperature(self): if self._data: return self._data[self._api.TEMP] + @property + def current_humidity(self): + """Return the current humidity value.""" + if self._data: + return self._data[self._api.HUMIDITY] + @property def target_temperature_step(self): """Return the supported step of target temperature.""" @@ -124,14 +130,6 @@ def state(self): return self.melissa_state_to_hass( self._cur_settings[self._api.STATE]) - @property - def device_state_attributes(self): - """Add the attributes that's available.""" - data = dict() - if self._data: - data['humidity'] = self._data['humidity'] - return data - @property def temperature_unit(self): """Return the unit of measurement which this thermostat uses."""