Added scene controller support to the vera component, along with proper polling when a vera device needs it (#7234)
Add an optional extended description…
This commit is contained in:
1 parent
d79f89e168
commit
28aab33cd1
3 files changed
+18
-4
No files matched your search
@@ -5,6 +5,7 @@ For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/sensor.vera/
|
||||
"""
|
||||
import logging
|
||||
from datetime import timedelta
|
||||
|
||||
from homeassistant.const import (
|
||||
TEMP_CELSIUS, TEMP_FAHRENHEIT)
|
||||
@@ -18,6 +19,8 @@ DEPENDENCIES = ['vera']
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
SCAN_INTERVAL = timedelta(seconds=5)
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
"""Perform the setup for Vera controller devices."""
|
||||
@@ -33,6 +36,7 @@ class VeraSensor(VeraDevice, Entity):
|
||||
"""Initialize the sensor."""
|
||||
self.current_value = None
|
||||
self._temperature_units = None
|
||||
self.last_changed_time = None
|
||||
VeraDevice.__init__(self, vera_device, controller)
|
||||
self.entity_id = ENTITY_ID_FORMAT.format(self.vera_id)
|
||||
|
||||
@@ -70,6 +74,14 @@ class VeraSensor(VeraDevice, Entity):
|
||||
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 == "Scene Controller":
|
||||
value = self.vera_device.get_last_scene_id(True)
|
||||
time = self.vera_device.get_last_scene_time(True)
|
||||
if time == self.last_changed_time:
|
||||
self.current_value = None
|
||||
else:
|
||||
self.current_value = value
|
||||
self.last_changed_time = time
|
||||
elif self.vera_device.category == "Power meter":
|
||||
power = convert(self.vera_device.power, float, 0)
|
||||
self.current_value = int(round(power, 0))
|
||||
|
||||
Reference in new issue
Block a user