From 1dae22a465f0f67229da9c984a0c721cb357fed4 Mon Sep 17 00:00:00 2001 From: MartinHjelmare Date: Wed, 27 Jan 2016 02:06:43 +0100 Subject: [PATCH] Fix device_state_attributes * Return a dict with keys as the names of the enum members instead of the member values. * This fixes a TypeError: unorderable types: int() < str() --- homeassistant/components/sensor/mysensors.py | 6 ++++-- homeassistant/components/switch/mysensors.py | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/sensor/mysensors.py b/homeassistant/components/sensor/mysensors.py index fba0e8edcb7..42db8508964 100644 --- a/homeassistant/components/sensor/mysensors.py +++ b/homeassistant/components/sensor/mysensors.py @@ -153,8 +153,10 @@ class MySensorsSensor(Entity): @property def device_state_attributes(self): """Return device specific state attributes.""" - device_attr = dict(self._values) - device_attr.pop(self.value_type, None) + device_attr = {} + for value_type, value in self._values.items(): + if value_type != self.value_type: + device_attr[self.gateway.const.SetReq(value_type).name] = value return device_attr @property diff --git a/homeassistant/components/switch/mysensors.py b/homeassistant/components/switch/mysensors.py index ec9845c0bf1..294ff760ad5 100644 --- a/homeassistant/components/switch/mysensors.py +++ b/homeassistant/components/switch/mysensors.py @@ -103,8 +103,10 @@ class MySensorsSwitch(SwitchDevice): @property def device_state_attributes(self): """Return device specific state attributes.""" - device_attr = dict(self._values) - device_attr.pop(self.value_type, None) + device_attr = {} + for value_type, value in self._values.items(): + if value_type != self.value_type: + device_attr[self.gateway.const.SetReq(value_type).name] = value return device_attr @property