forked from home-assistant/core
Merge remote-tracking branch 'upstream/dev' into http-sessions
Merged in the latest upstream changes
This commit is contained in:
@@ -77,7 +77,7 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
|
|||||||
controller = veraApi.VeraController(base_url)
|
controller = veraApi.VeraController(base_url)
|
||||||
devices = []
|
devices = []
|
||||||
try:
|
try:
|
||||||
devices = controller.get_devices('Switch')
|
devices = controller.get_devices(['Switch', 'On/Off Switch'])
|
||||||
except RequestException:
|
except RequestException:
|
||||||
# There was a network related error connecting to the vera controller
|
# There was a network related error connecting to the vera controller
|
||||||
_LOGGER.exception("Error communicating with Vera API")
|
_LOGGER.exception("Error communicating with Vera API")
|
||||||
|
@@ -51,8 +51,8 @@ it should be set to "true" if you want this device excluded
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
import time
|
|
||||||
from requests.exceptions import RequestException
|
from requests.exceptions import RequestException
|
||||||
|
import homeassistant.util.dt as dt_util
|
||||||
|
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
@@ -146,11 +146,12 @@ class VeraSensor(Entity):
|
|||||||
|
|
||||||
if self.vera_device.is_trippable:
|
if self.vera_device.is_trippable:
|
||||||
last_tripped = self.vera_device.refresh_value('LastTrip')
|
last_tripped = self.vera_device.refresh_value('LastTrip')
|
||||||
trip_time_str = time.strftime(
|
if last_tripped is not None:
|
||||||
"%Y-%m-%d %H:%M",
|
utc_time = dt_util.utc_from_timestamp(int(last_tripped))
|
||||||
time.localtime(int(last_tripped))
|
attr[ATTR_LAST_TRIP_TIME] = dt_util.datetime_to_str(
|
||||||
)
|
utc_time)
|
||||||
attr[ATTR_LAST_TRIP_TIME] = trip_time_str
|
else:
|
||||||
|
attr[ATTR_LAST_TRIP_TIME] = None
|
||||||
tripped = self.vera_device.refresh_value('Tripped')
|
tripped = self.vera_device.refresh_value('Tripped')
|
||||||
attr[ATTR_TRIPPED] = 'True' if tripped == '1' else 'False'
|
attr[ATTR_TRIPPED] = 'True' if tripped == '1' else 'False'
|
||||||
|
|
||||||
|
@@ -51,6 +51,7 @@ it should be set to "true" if you want this device excluded
|
|||||||
import logging
|
import logging
|
||||||
import time
|
import time
|
||||||
from requests.exceptions import RequestException
|
from requests.exceptions import RequestException
|
||||||
|
import homeassistant.util.dt as dt_util
|
||||||
|
|
||||||
from homeassistant.helpers.entity import ToggleEntity
|
from homeassistant.helpers.entity import ToggleEntity
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
@@ -78,7 +79,8 @@ def get_devices(hass, config):
|
|||||||
vera_controller = veraApi.VeraController(base_url)
|
vera_controller = veraApi.VeraController(base_url)
|
||||||
devices = []
|
devices = []
|
||||||
try:
|
try:
|
||||||
devices = vera_controller.get_devices(['Switch', 'Armable Sensor'])
|
devices = vera_controller.get_devices([
|
||||||
|
'Switch', 'Armable Sensor', 'On/Off Switch'])
|
||||||
except RequestException:
|
except RequestException:
|
||||||
# There was a network related error connecting to the vera controller
|
# There was a network related error connecting to the vera controller
|
||||||
_LOGGER.exception("Error communicating with Vera API")
|
_LOGGER.exception("Error communicating with Vera API")
|
||||||
@@ -132,11 +134,12 @@ class VeraSwitch(ToggleEntity):
|
|||||||
|
|
||||||
if self.vera_device.is_trippable:
|
if self.vera_device.is_trippable:
|
||||||
last_tripped = self.vera_device.refresh_value('LastTrip')
|
last_tripped = self.vera_device.refresh_value('LastTrip')
|
||||||
trip_time_str = time.strftime(
|
if last_tripped is not None:
|
||||||
"%Y-%m-%d %H:%M",
|
utc_time = dt_util.utc_from_timestamp(int(last_tripped))
|
||||||
time.localtime(int(last_tripped))
|
attr[ATTR_LAST_TRIP_TIME] = dt_util.datetime_to_str(
|
||||||
)
|
utc_time)
|
||||||
attr[ATTR_LAST_TRIP_TIME] = trip_time_str
|
else:
|
||||||
|
attr[ATTR_LAST_TRIP_TIME] = None
|
||||||
tripped = self.vera_device.refresh_value('Tripped')
|
tripped = self.vera_device.refresh_value('Tripped')
|
||||||
attr[ATTR_TRIPPED] = 'True' if tripped == '1' else 'False'
|
attr[ATTR_TRIPPED] = 'True' if tripped == '1' else 'False'
|
||||||
|
|
||||||
|
2
homeassistant/external/vera
vendored
2
homeassistant/external/vera
vendored
Submodule homeassistant/external/vera updated: fedbb5c3af...30c59781d6
Reference in New Issue
Block a user