diff --git a/.coveragerc b/.coveragerc index 2ea0f11a6bd..f0953f49cd5 100644 --- a/.coveragerc +++ b/.coveragerc @@ -24,6 +24,9 @@ omit = homeassistant/components/device_tracker/tomato.py homeassistant/components/device_tracker/netgear.py homeassistant/components/device_tracker/nmap_tracker.py + homeassistant/components/light/vera.py + homeassistant/components/sensor/vera.py + homeassistant/components/switch/vera.py [report] diff --git a/homeassistant/components/sensor/vera.py b/homeassistant/components/sensor/vera.py index 8f9ede0182d..6fd978ccd20 100644 --- a/homeassistant/components/sensor/vera.py +++ b/homeassistant/components/sensor/vera.py @@ -57,7 +57,8 @@ import logging import time from homeassistant.helpers import Device -from homeassistant.const import ATTR_BATTERY_LEVEL +from homeassistant.const import ( + ATTR_BATTERY_LEVEL, ATTR_TRIPPED, ATTR_ARMED, ATTR_LAST_TRIP_TIME) # pylint: disable=no-name-in-module, import-error import homeassistant.external.vera.vera as veraApi @@ -149,7 +150,7 @@ class VeraSensor(Device): if self.vera_device.is_armable: armed = self.vera_device.refresh_value('Armed') - attr['Armed'] = 'True' if armed == '1' else 'False' + attr[ATTR_ARMED] = 'True' if armed == '1' else 'False' if self.vera_device.is_trippable: last_tripped = self.vera_device.refresh_value('LastTrip') @@ -157,9 +158,9 @@ class VeraSensor(Device): "%Y-%m-%d %H:%M", time.localtime(int(last_tripped)) ) - attr['Last Tripped'] = trip_time_str + attr[ATTR_LAST_TRIP_TIME] = trip_time_str tripped = self.vera_device.refresh_value('Tripped') - attr['Tripped'] = 'True' if tripped == '1' else 'False' + attr[ATTR_TRIPPED] = 'True' if tripped == '1' else 'False' attr['Vera Device Id'] = self.vera_device.vera_device_id return attr diff --git a/homeassistant/components/switch/vera.py b/homeassistant/components/switch/vera.py index 16613648580..0811ac3b0b9 100644 --- a/homeassistant/components/switch/vera.py +++ b/homeassistant/components/switch/vera.py @@ -57,7 +57,8 @@ import logging import time from homeassistant.helpers import ToggleDevice -from homeassistant.const import ATTR_BATTERY_LEVEL +from homeassistant.const import ( + ATTR_BATTERY_LEVEL, ATTR_TRIPPED, ATTR_ARMED, ATTR_LAST_TRIP_TIME) # pylint: disable=no-name-in-module, import-error import homeassistant.external.vera.vera as veraApi @@ -144,7 +145,7 @@ class VeraSwitch(ToggleDevice): if self.vera_device.is_armable: armed = self.vera_device.refresh_value('Armed') - attr['Armed'] = 'True' if armed == '1' else 'False' + attr[ATTR_ARMED] = 'True' if armed == '1' else 'False' if self.vera_device.is_trippable: last_tripped = self.vera_device.refresh_value('LastTrip') @@ -152,11 +153,9 @@ class VeraSwitch(ToggleDevice): "%Y-%m-%d %H:%M", time.localtime(int(last_tripped)) ) - - attr['Last Tripped'] = trip_time_str - + attr[ATTR_LAST_TRIP_TIME] = trip_time_str tripped = self.vera_device.refresh_value('Tripped') - attr['Tripped'] = 'True' if tripped == '1' else 'False' + attr[ATTR_TRIPPED] = 'True' if tripped == '1' else 'False' attr['Vera Device Id'] = self.vera_device.vera_device_id diff --git a/homeassistant/const.py b/homeassistant/const.py index e90f1338b83..ed74f1edf4f 100644 --- a/homeassistant/const.py +++ b/homeassistant/const.py @@ -73,6 +73,16 @@ ATTR_LOCATION = "location" ATTR_BATTERY_LEVEL = "battery_level" +# For devices which support an armed state +ATTR_ARMED = "device_armed" + +# For sensors that support 'tripping', eg. motion and door sensors +ATTR_TRIPPED = "device_tripped" + +# For sensors that support 'tripping' this holds the most recent +# time the device was tripped +ATTR_LAST_TRIP_TIME = "last_tripped_time" + # #### SERVICES #### SERVICE_HOMEASSISTANT_STOP = "stop"