mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Add vera power meter. (#7134)
* Add vera power meter. * Use W for power.
This commit is contained in:
parent
226066eafd
commit
1925748f61
@ -10,6 +10,7 @@ from homeassistant.const import (
|
|||||||
TEMP_CELSIUS, TEMP_FAHRENHEIT)
|
TEMP_CELSIUS, TEMP_FAHRENHEIT)
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
from homeassistant.components.sensor import ENTITY_ID_FORMAT
|
from homeassistant.components.sensor import ENTITY_ID_FORMAT
|
||||||
|
from homeassistant.util import convert
|
||||||
from homeassistant.components.vera import (
|
from homeassistant.components.vera import (
|
||||||
VERA_CONTROLLER, VERA_DEVICES, VeraDevice)
|
VERA_CONTROLLER, VERA_DEVICES, VeraDevice)
|
||||||
|
|
||||||
@ -49,6 +50,8 @@ class VeraSensor(VeraDevice, Entity):
|
|||||||
return 'lux'
|
return 'lux'
|
||||||
elif self.vera_device.category == "Humidity Sensor":
|
elif self.vera_device.category == "Humidity Sensor":
|
||||||
return '%'
|
return '%'
|
||||||
|
elif self.vera_device.category == "Power meter":
|
||||||
|
return 'watts'
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
"""Update the state."""
|
"""Update the state."""
|
||||||
@ -67,6 +70,9 @@ class VeraSensor(VeraDevice, Entity):
|
|||||||
self.current_value = self.vera_device.light
|
self.current_value = self.vera_device.light
|
||||||
elif self.vera_device.category == "Humidity Sensor":
|
elif self.vera_device.category == "Humidity Sensor":
|
||||||
self.current_value = self.vera_device.humidity
|
self.current_value = self.vera_device.humidity
|
||||||
|
elif self.vera_device.category == "Power meter":
|
||||||
|
power = convert(self.vera_device.power, float, 0)
|
||||||
|
self.current_value = int(round(power, 0))
|
||||||
elif self.vera_device.category == "Sensor":
|
elif self.vera_device.category == "Sensor":
|
||||||
tripped = self.vera_device.is_tripped
|
tripped = self.vera_device.is_tripped
|
||||||
self.current_value = 'Tripped' if tripped else 'Not Tripped'
|
self.current_value = 'Tripped' if tripped else 'Not Tripped'
|
||||||
|
@ -20,7 +20,7 @@ from homeassistant.const import (
|
|||||||
EVENT_HOMEASSISTANT_STOP)
|
EVENT_HOMEASSISTANT_STOP)
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
|
|
||||||
REQUIREMENTS = ['pyvera==0.2.25']
|
REQUIREMENTS = ['pyvera==0.2.26']
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -35,6 +35,7 @@ CONF_LIGHTS = 'lights'
|
|||||||
VERA_ID_FORMAT = '{}_{}'
|
VERA_ID_FORMAT = '{}_{}'
|
||||||
|
|
||||||
ATTR_CURRENT_POWER_W = "current_power_w"
|
ATTR_CURRENT_POWER_W = "current_power_w"
|
||||||
|
ATTR_CURRENT_ENERGY_KWH = "current_energy_kwh"
|
||||||
|
|
||||||
VERA_DEVICES = defaultdict(list)
|
VERA_DEVICES = defaultdict(list)
|
||||||
|
|
||||||
@ -181,6 +182,10 @@ class VeraDevice(Entity):
|
|||||||
if power:
|
if power:
|
||||||
attr[ATTR_CURRENT_POWER_W] = convert(power, float, 0.0)
|
attr[ATTR_CURRENT_POWER_W] = convert(power, float, 0.0)
|
||||||
|
|
||||||
|
energy = self.vera_device.energy
|
||||||
|
if energy:
|
||||||
|
attr[ATTR_CURRENT_ENERGY_KWH] = convert(energy, float, 0.0)
|
||||||
|
|
||||||
attr['Vera Device Id'] = self.vera_device.vera_device_id
|
attr['Vera Device Id'] = self.vera_device.vera_device_id
|
||||||
|
|
||||||
return attr
|
return attr
|
||||||
|
@ -665,7 +665,7 @@ pyunifi==2.0
|
|||||||
# pyuserinput==0.1.11
|
# pyuserinput==0.1.11
|
||||||
|
|
||||||
# homeassistant.components.vera
|
# homeassistant.components.vera
|
||||||
pyvera==0.2.25
|
pyvera==0.2.26
|
||||||
|
|
||||||
# homeassistant.components.notify.html5
|
# homeassistant.components.notify.html5
|
||||||
pywebpush==0.6.1
|
pywebpush==0.6.1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user