mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
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:
parent
d79f89e168
commit
28aab33cd1
@ -5,6 +5,7 @@ For more details about this platform, please refer to the documentation at
|
|||||||
https://home-assistant.io/components/sensor.vera/
|
https://home-assistant.io/components/sensor.vera/
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
|
from datetime import timedelta
|
||||||
|
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
TEMP_CELSIUS, TEMP_FAHRENHEIT)
|
TEMP_CELSIUS, TEMP_FAHRENHEIT)
|
||||||
@ -18,6 +19,8 @@ DEPENDENCIES = ['vera']
|
|||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
SCAN_INTERVAL = timedelta(seconds=5)
|
||||||
|
|
||||||
|
|
||||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
"""Perform the setup for Vera controller devices."""
|
"""Perform the setup for Vera controller devices."""
|
||||||
@ -33,6 +36,7 @@ class VeraSensor(VeraDevice, Entity):
|
|||||||
"""Initialize the sensor."""
|
"""Initialize the sensor."""
|
||||||
self.current_value = None
|
self.current_value = None
|
||||||
self._temperature_units = None
|
self._temperature_units = None
|
||||||
|
self.last_changed_time = None
|
||||||
VeraDevice.__init__(self, vera_device, controller)
|
VeraDevice.__init__(self, vera_device, controller)
|
||||||
self.entity_id = ENTITY_ID_FORMAT.format(self.vera_id)
|
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
|
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 == "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":
|
elif self.vera_device.category == "Power meter":
|
||||||
power = convert(self.vera_device.power, float, 0)
|
power = convert(self.vera_device.power, float, 0)
|
||||||
self.current_value = int(round(power, 0))
|
self.current_value = int(round(power, 0))
|
||||||
|
@ -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.26']
|
REQUIREMENTS = ['pyvera==0.2.27']
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -118,6 +118,8 @@ def map_vera_device(vera_device, remap):
|
|||||||
return 'climate'
|
return 'climate'
|
||||||
if isinstance(vera_device, veraApi.VeraCurtain):
|
if isinstance(vera_device, veraApi.VeraCurtain):
|
||||||
return 'cover'
|
return 'cover'
|
||||||
|
if isinstance(vera_device, veraApi.VeraSceneController):
|
||||||
|
return 'sensor'
|
||||||
if isinstance(vera_device, veraApi.VeraSwitch):
|
if isinstance(vera_device, veraApi.VeraSwitch):
|
||||||
if vera_device.device_id in remap:
|
if vera_device.device_id in remap:
|
||||||
return 'light'
|
return 'light'
|
||||||
@ -153,8 +155,8 @@ class VeraDevice(Entity):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def should_poll(self):
|
def should_poll(self):
|
||||||
"""No polling needed."""
|
"""Get polling requirement from vera device."""
|
||||||
return False
|
return self.vera_device.should_poll
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_state_attributes(self):
|
def device_state_attributes(self):
|
||||||
|
@ -676,7 +676,7 @@ pyunifi==2.0
|
|||||||
# pyuserinput==0.1.11
|
# pyuserinput==0.1.11
|
||||||
|
|
||||||
# homeassistant.components.vera
|
# homeassistant.components.vera
|
||||||
pyvera==0.2.26
|
pyvera==0.2.27
|
||||||
|
|
||||||
# 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