|
发表于 2019-3-28 13:16:38
|
显示全部楼层
组件里面\xiaomi_aqara\__init__.py
其中这一段改为下面的就可以了,拿走不谢:
def parse_voltage(self, data):
"""Parse battery level data sent by gateway."""
if 'battery_voltage' in data:
voltage = data['battery_voltage']
max_volt = 3300
min_volt = 2800
voltage = min(voltage, max_volt)
voltage = max(voltage, min_volt)
percent = ((voltage - min_volt) / (max_volt - min_volt)) * 100
self._device_state_attributes[ATTR_BATTERY_LEVEL] = round(percent, 1)
return True
elif 'voltage' in data:
voltage = data['voltage']
max_volt = 3300
min_volt = 2800
voltage = min(voltage, max_volt)
voltage = max(voltage, min_volt)
percent = ((voltage - min_volt) / (max_volt - min_volt)) * 100
self._device_state_attributes[ATTR_BATTERY_LEVEL] = round(percent, 1)
return True
else:
return False |
|