Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add vera power meter. #7134

Merged
merged 2 commits into from
Apr 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions homeassistant/components/sensor/vera.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
TEMP_CELSIUS, TEMP_FAHRENHEIT)
from homeassistant.helpers.entity import Entity
from homeassistant.components.sensor import ENTITY_ID_FORMAT
from homeassistant.util import convert
from homeassistant.components.vera import (
VERA_CONTROLLER, VERA_DEVICES, VeraDevice)

Expand Down Expand Up @@ -49,6 +50,8 @@ def unit_of_measurement(self):
return 'lux'
elif self.vera_device.category == "Humidity Sensor":
return '%'
elif self.vera_device.category == "Power meter":
return 'watts'

def update(self):
"""Update the state."""
Expand All @@ -67,6 +70,9 @@ def update(self):
self.current_value = self.vera_device.light
elif self.vera_device.category == "Humidity Sensor":
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":
tripped = self.vera_device.is_tripped
self.current_value = 'Tripped' if tripped else 'Not Tripped'
Expand Down
7 changes: 6 additions & 1 deletion homeassistant/components/vera.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
EVENT_HOMEASSISTANT_STOP)
from homeassistant.helpers.entity import Entity

REQUIREMENTS = ['pyvera==0.2.25']
REQUIREMENTS = ['pyvera==0.2.26']

_LOGGER = logging.getLogger(__name__)

Expand All @@ -35,6 +35,7 @@
VERA_ID_FORMAT = '{}_{}'

ATTR_CURRENT_POWER_W = "current_power_w"
ATTR_CURRENT_ENERGY_KWH = "current_energy_kwh"

VERA_DEVICES = defaultdict(list)

Expand Down Expand Up @@ -181,6 +182,10 @@ def device_state_attributes(self):
if power:
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

return attr
2 changes: 1 addition & 1 deletion requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@ pyunifi==2.0
# pyuserinput==0.1.11

# homeassistant.components.vera
pyvera==0.2.25
pyvera==0.2.26

# homeassistant.components.notify.html5
pywebpush==0.6.1
Expand Down