Catch RuntimeError (#5134)

pull/4972/merge
John Arild Berentsen 2017-01-02 18:45:10 +01:00 committed by GitHub
parent 8a463ef7a4
commit 23f16bb68f
1 changed files with 6 additions and 1 deletions

View File

@ -621,7 +621,12 @@ class ZWaveDeviceEntity:
const.ATTR_NODE_ID: self._value.node.node_id,
}
battery_level = self._value.node.get_battery_level()
try:
battery_level = self._value.node.get_battery_level()
except RuntimeError:
# If we get an runtime error the dict has changed while
# we was looking for a value, just do it again
battery_level = self._value.node.get_battery_level()
if battery_level is not None:
attrs[ATTR_BATTERY_LEVEL] = battery_level