mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Add voltage attribute to Xiaomi Aqara devices (#26876)
This commit is contained in:
parent
aaf013da6e
commit
f5018e91b5
@ -8,6 +8,7 @@ import voluptuous as vol
|
|||||||
from homeassistant.components.discovery import SERVICE_XIAOMI_GW
|
from homeassistant.components.discovery import SERVICE_XIAOMI_GW
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_BATTERY_LEVEL,
|
ATTR_BATTERY_LEVEL,
|
||||||
|
ATTR_VOLTAGE,
|
||||||
CONF_HOST,
|
CONF_HOST,
|
||||||
CONF_MAC,
|
CONF_MAC,
|
||||||
CONF_PORT,
|
CONF_PORT,
|
||||||
@ -323,6 +324,7 @@ class XiaomiDevice(Entity):
|
|||||||
max_volt = 3300
|
max_volt = 3300
|
||||||
min_volt = 2800
|
min_volt = 2800
|
||||||
voltage = data[voltage_key]
|
voltage = data[voltage_key]
|
||||||
|
self._device_state_attributes[ATTR_VOLTAGE] = round(voltage/1000.0, 2)
|
||||||
voltage = min(voltage, max_volt)
|
voltage = min(voltage, max_volt)
|
||||||
voltage = max(voltage, min_volt)
|
voltage = max(voltage, min_volt)
|
||||||
percent = ((voltage - min_volt) / (max_volt - min_volt)) * 100
|
percent = ((voltage - min_volt) / (max_volt - min_volt)) * 100
|
||||||
|
Loading…
x
Reference in New Issue
Block a user