Merge pull request #898 from balloob/vera_fixes

Vera fixes
This commit is contained in:
Paulus Schoutsen 2016-01-15 07:43:03 -08:00
commit bb80e3a9fc
4 changed files with 18 additions and 7 deletions

View File

@ -15,7 +15,7 @@ from homeassistant.components.light import ATTR_BRIGHTNESS
from homeassistant.const import EVENT_HOMEASSISTANT_STOP, STATE_ON from homeassistant.const import EVENT_HOMEASSISTANT_STOP, STATE_ON
REQUIREMENTS = ['pyvera==0.2.3'] REQUIREMENTS = ['pyvera==0.2.5']
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)

View File

@ -15,7 +15,7 @@ from homeassistant.const import (
ATTR_BATTERY_LEVEL, ATTR_TRIPPED, ATTR_ARMED, ATTR_LAST_TRIP_TIME, ATTR_BATTERY_LEVEL, ATTR_TRIPPED, ATTR_ARMED, ATTR_LAST_TRIP_TIME,
TEMP_CELCIUS, TEMP_FAHRENHEIT, EVENT_HOMEASSISTANT_STOP) TEMP_CELCIUS, TEMP_FAHRENHEIT, EVENT_HOMEASSISTANT_STOP)
REQUIREMENTS = ['pyvera==0.2.3'] REQUIREMENTS = ['pyvera==0.2.5']
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -45,7 +45,10 @@ def get_devices(hass, config):
hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP, stop_subscription) hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP, stop_subscription)
categories = ['Temperature Sensor', 'Light Sensor', 'Sensor'] categories = ['Temperature Sensor',
'Light Sensor',
'Humidity Sensor',
'Sensor']
devices = [] devices = []
try: try:
devices = vera_controller.get_devices(categories) devices = vera_controller.get_devices(categories)
@ -106,7 +109,12 @@ class VeraSensor(Entity):
@property @property
def unit_of_measurement(self): def unit_of_measurement(self):
""" Unit of measurement of this entity, if any. """ """ Unit of measurement of this entity, if any. """
if self.vera_device.category == "Temperature Sensor":
return self._temperature_units return self._temperature_units
elif self.vera_device.category == "Light Sensor":
return 'lux'
elif self.vera_device.category == "Humidity Sensor":
return '%'
@property @property
def state_attributes(self): def state_attributes(self):
@ -140,7 +148,8 @@ class VeraSensor(Entity):
def update(self): def update(self):
if self.vera_device.category == "Temperature Sensor": if self.vera_device.category == "Temperature Sensor":
current_temp = self.vera_device.get_value('CurrentTemperature') current_temp = self.vera_device.get_value('CurrentTemperature')
vera_temp_units = self.vera_device.veraController.temperature_units vera_temp_units = (
self.vera_device.vera_controller.temperature_units)
if vera_temp_units == 'F': if vera_temp_units == 'F':
self._temperature_units = TEMP_FAHRENHEIT self._temperature_units = TEMP_FAHRENHEIT
@ -157,6 +166,8 @@ class VeraSensor(Entity):
self.current_value = current_temp self.current_value = current_temp
elif self.vera_device.category == "Light Sensor": elif self.vera_device.category == "Light Sensor":
self.current_value = self.vera_device.get_value('CurrentLevel') self.current_value = self.vera_device.get_value('CurrentLevel')
elif self.vera_device.category == "Humidity Sensor":
self.current_value = self.vera_device.get_value('CurrentLevel')
elif self.vera_device.category == "Sensor": elif self.vera_device.category == "Sensor":
tripped = self.vera_device.get_value('Tripped') tripped = self.vera_device.get_value('Tripped')
self.current_value = 'Tripped' if tripped == '1' else 'Not Tripped' self.current_value = 'Tripped' if tripped == '1' else 'Not Tripped'

View File

@ -21,7 +21,7 @@ from homeassistant.const import (
STATE_ON, STATE_ON,
STATE_OFF) STATE_OFF)
REQUIREMENTS = ['pyvera==0.2.3'] REQUIREMENTS = ['pyvera==0.2.5']
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)

View File

@ -62,7 +62,7 @@ tellcore-py==1.1.2
# homeassistant.components.light.vera # homeassistant.components.light.vera
# homeassistant.components.sensor.vera # homeassistant.components.sensor.vera
# homeassistant.components.switch.vera # homeassistant.components.switch.vera
pyvera==0.2.3 pyvera==0.2.5
# homeassistant.components.wink # homeassistant.components.wink
# homeassistant.components.light.wink # homeassistant.components.light.wink