Added constants for armed, tripped and tripped time

This commit is contained in:
jamespcole 2015-03-09 08:10:31 +11:00
parent 38fbc3595a
commit 7dc3198320
4 changed files with 23 additions and 10 deletions

View file

@ -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]

View file

@ -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

View file

@ -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

View file

@ -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"