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()
This commit is contained in:
MartinHjelmare committed 2016-01-27 02:33:21 +01:00
1 parent b13e48bd71
commit 1dae22a465
2 files changed
+8 -4

No files matched your search

+4 -2
View File
@@ -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
+4 -2
View File
@@ -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