mirror of
https://github.com/home-assistant/core.git
synced 2025-11-12 04:20:17 +00:00
Fix mysensors version errors
* The application of the version check in unit_of_measurement was messed up after the last refactor. Fix that again. * An error could occur in device_state_attributes if there was a mismatch between used value_type in the device and mysensors version in config. Add try... except to handle that.
This commit is contained in:
@@ -100,10 +100,16 @@ class MySensorsSwitch(SwitchDevice):
|
||||
@property
|
||||
def device_state_attributes(self):
|
||||
"""Return device specific state attributes."""
|
||||
set_req = self.gateway.const.SetReq
|
||||
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
|
||||
try:
|
||||
device_attr[set_req(value_type).name] = value
|
||||
except ValueError:
|
||||
_LOGGER.error('value_type %s is not valid for mysensors '
|
||||
'version %s', value_type,
|
||||
self.gateway.version)
|
||||
return device_attr
|
||||
|
||||
@property
|
||||
|
||||
Reference in New Issue
Block a user