From e877ed01afca576a405041af78de23b53a19ee86 Mon Sep 17 00:00:00 2001 From: jamespcole Date: Sun, 22 Mar 2015 14:43:20 +1100 Subject: [PATCH 1/3] Fixed attribute error with new unit_of_measurement changes --- homeassistant/components/sensor/sabnzbd.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/sensor/sabnzbd.py b/homeassistant/components/sensor/sabnzbd.py index 431752f544c..d33c9603c01 100644 --- a/homeassistant/components/sensor/sabnzbd.py +++ b/homeassistant/components/sensor/sabnzbd.py @@ -118,7 +118,7 @@ class SabnzbdSensor(Entity): self.type = sensor_type self.client_name = client_name self._state = None - self.unit_of_measurement = SENSOR_TYPES[sensor_type][1] + self._unit_of_measurement = SENSOR_TYPES[sensor_type][1] @property def name(self): @@ -134,7 +134,7 @@ class SabnzbdSensor(Entity): """ Returns the state attributes. """ return { ATTR_FRIENDLY_NAME: self.name, - ATTR_UNIT_OF_MEASUREMENT: self.unit_of_measurement, + ATTR_UNIT_OF_MEASUREMENT: self._unit_of_measurement, } def refresh_sabnzbd_data(self): From 04d16d76076a3ffff7ca7706ac5347c47f86de6f Mon Sep 17 00:00:00 2001 From: jamespcole Date: Sun, 22 Mar 2015 15:18:58 +1100 Subject: [PATCH 2/3] removed unused state attributes that are no longer required after upstream changes --- homeassistant/components/sensor/sabnzbd.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/homeassistant/components/sensor/sabnzbd.py b/homeassistant/components/sensor/sabnzbd.py index d33c9603c01..974c7d05fbe 100644 --- a/homeassistant/components/sensor/sabnzbd.py +++ b/homeassistant/components/sensor/sabnzbd.py @@ -130,12 +130,9 @@ class SabnzbdSensor(Entity): return self._state @property - def state_attributes(self): - """ Returns the state attributes. """ - return { - ATTR_FRIENDLY_NAME: self.name, - ATTR_UNIT_OF_MEASUREMENT: self._unit_of_measurement, - } + def unit_of_measurement(self): + """ Unit of measurement of this entity, if any. """ + return self._unit_of_measurement def refresh_sabnzbd_data(self): """ Calls the throttled SABnzbd refresh method. """ From 470096047b8a9979655823d964fad15c7518d1dc Mon Sep 17 00:00:00 2001 From: jamespcole Date: Sun, 22 Mar 2015 15:43:59 +1100 Subject: [PATCH 3/3] removed unused imports --- homeassistant/components/sensor/sabnzbd.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/homeassistant/components/sensor/sabnzbd.py b/homeassistant/components/sensor/sabnzbd.py index 974c7d05fbe..a1230def614 100644 --- a/homeassistant/components/sensor/sabnzbd.py +++ b/homeassistant/components/sensor/sabnzbd.py @@ -56,8 +56,7 @@ from homeassistant.helpers.entity import Entity # pylint: disable=no-name-in-module, import-error from homeassistant.external.nzbclients.sabnzbd import SabnzbdApi from homeassistant.external.nzbclients.sabnzbd import SabnzbdApiException -from homeassistant.const import ( - ATTR_UNIT_OF_MEASUREMENT, ATTR_FRIENDLY_NAME) + import logging SENSOR_TYPES = {