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()
pull/1010/head
MartinHjelmare 2016-01-27 02:06:43 +01:00
parent b13e48bd71
commit 1dae22a465
2 changed files with 8 additions and 4 deletions

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

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