From 1c47ade641ae5346fe51c545eae9c47007332432 Mon Sep 17 00:00:00 2001 From: jamespcole Date: Mon, 18 May 2015 18:54:25 +1000 Subject: [PATCH 1/3] Updated with new switch category for UI7 firmware update and fixed excpetion when trippable sensor has never been tripped --- homeassistant/components/light/vera.py | 2 +- homeassistant/components/sensor/vera.py | 13 +++++++------ homeassistant/components/switch/vera.py | 15 +++++++++------ 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/homeassistant/components/light/vera.py b/homeassistant/components/light/vera.py index 46fd3b54bb4..fe363923c76 100644 --- a/homeassistant/components/light/vera.py +++ b/homeassistant/components/light/vera.py @@ -77,7 +77,7 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None): controller = veraApi.VeraController(base_url) devices = [] try: - devices = controller.get_devices('Switch') + devices = controller.get_devices(['Switch', 'On/Off Switch']) except RequestException: # There was a network related error connecting to the vera controller _LOGGER.exception("Error communicating with Vera API") diff --git a/homeassistant/components/sensor/vera.py b/homeassistant/components/sensor/vera.py index 1cbef3a899a..b678188f8ea 100644 --- a/homeassistant/components/sensor/vera.py +++ b/homeassistant/components/sensor/vera.py @@ -51,8 +51,8 @@ it should be set to "true" if you want this device excluded """ import logging -import time from requests.exceptions import RequestException +import homeassistant.util.dt as dt_util from homeassistant.helpers.entity import Entity from homeassistant.const import ( @@ -146,11 +146,12 @@ class VeraSensor(Entity): if self.vera_device.is_trippable: last_tripped = self.vera_device.refresh_value('LastTrip') - trip_time_str = time.strftime( - "%Y-%m-%d %H:%M", - time.localtime(int(last_tripped)) - ) - attr[ATTR_LAST_TRIP_TIME] = trip_time_str + if last_tripped is not None: + utc_time = dt_util.utc_from_timestamp(int(last_tripped)) + attr[ATTR_LAST_TRIP_TIME] = dt_util.datetime_to_local_str( + utc_time) + else: + attr[ATTR_LAST_TRIP_TIME] = None tripped = self.vera_device.refresh_value('Tripped') attr[ATTR_TRIPPED] = 'True' if tripped == '1' else 'False' diff --git a/homeassistant/components/switch/vera.py b/homeassistant/components/switch/vera.py index 7a9f8f96b79..9497938ce13 100644 --- a/homeassistant/components/switch/vera.py +++ b/homeassistant/components/switch/vera.py @@ -51,6 +51,7 @@ it should be set to "true" if you want this device excluded import logging import time from requests.exceptions import RequestException +import homeassistant.util.dt as dt_util from homeassistant.helpers.entity import ToggleEntity from homeassistant.const import ( @@ -78,7 +79,8 @@ def get_devices(hass, config): vera_controller = veraApi.VeraController(base_url) devices = [] try: - devices = vera_controller.get_devices(['Switch', 'Armable Sensor']) + devices = vera_controller.get_devices([ + 'Switch', 'Armable Sensor', 'On/Off Switch']) except RequestException: # There was a network related error connecting to the vera controller _LOGGER.exception("Error communicating with Vera API") @@ -132,11 +134,12 @@ class VeraSwitch(ToggleEntity): if self.vera_device.is_trippable: last_tripped = self.vera_device.refresh_value('LastTrip') - trip_time_str = time.strftime( - "%Y-%m-%d %H:%M", - time.localtime(int(last_tripped)) - ) - attr[ATTR_LAST_TRIP_TIME] = trip_time_str + if last_tripped is not None: + utc_time = dt_util.utc_from_timestamp(int(last_tripped)) + attr[ATTR_LAST_TRIP_TIME] = dt_util.datetime_to_local_str( + utc_time) + else: + attr[ATTR_LAST_TRIP_TIME] = None tripped = self.vera_device.refresh_value('Tripped') attr[ATTR_TRIPPED] = 'True' if tripped == '1' else 'False' From 1d7d0ea2d4e1c86350ca93b56334e55ff46040bf Mon Sep 17 00:00:00 2001 From: jamespcole Date: Mon, 18 May 2015 19:18:53 +1000 Subject: [PATCH 2/3] updated vera submodule to the latest version for the UI7 formware update --- homeassistant/external/vera | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/external/vera b/homeassistant/external/vera index fedbb5c3af1..30c59781d63 160000 --- a/homeassistant/external/vera +++ b/homeassistant/external/vera @@ -1 +1 @@ -Subproject commit fedbb5c3af1e5f36b7008d894e9fc1ecf3cc2ea8 +Subproject commit 30c59781d63322db2160ff00a4b99f16ead40b85 From dba9f8854fb3124d8df811a64621de988fb487b3 Mon Sep 17 00:00:00 2001 From: jamespcole Date: Tue, 19 May 2015 00:31:59 +1000 Subject: [PATCH 3/3] Removed conversion to local time from UTC for last_tripped_time for vera sensors and switches --- homeassistant/components/sensor/vera.py | 2 +- homeassistant/components/switch/vera.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/sensor/vera.py b/homeassistant/components/sensor/vera.py index b678188f8ea..89b2a1a2964 100644 --- a/homeassistant/components/sensor/vera.py +++ b/homeassistant/components/sensor/vera.py @@ -148,7 +148,7 @@ class VeraSensor(Entity): last_tripped = self.vera_device.refresh_value('LastTrip') if last_tripped is not None: utc_time = dt_util.utc_from_timestamp(int(last_tripped)) - attr[ATTR_LAST_TRIP_TIME] = dt_util.datetime_to_local_str( + attr[ATTR_LAST_TRIP_TIME] = dt_util.datetime_to_str( utc_time) else: attr[ATTR_LAST_TRIP_TIME] = None diff --git a/homeassistant/components/switch/vera.py b/homeassistant/components/switch/vera.py index 9497938ce13..2e472b4358f 100644 --- a/homeassistant/components/switch/vera.py +++ b/homeassistant/components/switch/vera.py @@ -136,7 +136,7 @@ class VeraSwitch(ToggleEntity): last_tripped = self.vera_device.refresh_value('LastTrip') if last_tripped is not None: utc_time = dt_util.utc_from_timestamp(int(last_tripped)) - attr[ATTR_LAST_TRIP_TIME] = dt_util.datetime_to_local_str( + attr[ATTR_LAST_TRIP_TIME] = dt_util.datetime_to_str( utc_time) else: attr[ATTR_LAST_TRIP_TIME] = None