Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
CATEGORY_UNKNOWN = 1234
RESPONSE_SDATA = {
"scenes": [{"id": SCENE1_ID, "name": "scene1", "active": 0, "root": 0}],
"temperature": 23,
"categories": [
{"name": "Dimmable Switch", "id": CATEGORY_DIMMER},
{"name": "On/Off Switch", "id": CATEGORY_SWITCH},
{"name": "Sensor", "id": CATEGORY_ARMABLE},
{"name": "Generic IO", "id": CATEGORY_GENERIC},
{"name": "Temperature Sensor", "id": CATEGORY_TEMPERATURE_SENSOR},
{"name": "Lock", "id": CATEGORY_LOCK},
{"name": "Thermostat", "id": CATEGORY_THERMOSTAT},
{"name": "Light sensor", "id": CATEGORY_LIGHT_SENSOR},
{"name": "UV sensor", "id": CATEGORY_UV_SENSOR},
{"name": "Humidity sensor", "id": CATEGORY_HUMIDITY_SENSOR},
{"name": "Power meter", "id": CATEGORY_POWER_METER},
],
"devices": [
{
"name": "Ignore 1",
"altid": "6",
"id": DEVICE_IGNORE,
"category": CATEGORY_SWITCH,
"subcategory": 1,
"room": 0,
"parent": 1,
"armed": "0",
"armedtripped": "0",
"configured": "1",
"batterylevel": "100",
def update(self):
"""Update the state."""
if self.vera_device.category == veraApi.CATEGORY_TEMPERATURE_SENSOR:
self.current_value = self.vera_device.temperature
vera_temp_units = self.vera_device.vera_controller.temperature_units
if vera_temp_units == "F":
self._temperature_units = TEMP_FAHRENHEIT
else:
self._temperature_units = TEMP_CELSIUS
elif self.vera_device.category == veraApi.CATEGORY_LIGHT_SENSOR:
self.current_value = self.vera_device.light
elif self.vera_device.category == veraApi.CATEGORY_UV_SENSOR:
self.current_value = self.vera_device.light
elif self.vera_device.category == veraApi.CATEGORY_HUMIDITY_SENSOR:
self.current_value = self.vera_device.humidity
elif self.vera_device.category == veraApi.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 == veraApi.CATEGORY_POWER_METER:
power = convert(self.vera_device.power, float, 0)
self.current_value = int(round(power, 0))
elif self.vera_device.is_trippable:
tripped = self.vera_device.is_tripped
"""Update the state."""
import pyvera as veraApi
if self.vera_device.category == veraApi.CATEGORY_TEMPERATURE_SENSOR:
self.current_value = self.vera_device.temperature
vera_temp_units = (
self.vera_device.vera_controller.temperature_units)
if vera_temp_units == 'F':
self._temperature_units = TEMP_FAHRENHEIT
else:
self._temperature_units = TEMP_CELSIUS
elif self.vera_device.category == veraApi.CATEGORY_LIGHT_SENSOR:
self.current_value = self.vera_device.light
elif self.vera_device.category == veraApi.CATEGORY_UV_SENSOR:
self.current_value = self.vera_device.light
elif self.vera_device.category == veraApi.CATEGORY_HUMIDITY_SENSOR:
self.current_value = self.vera_device.humidity
elif self.vera_device.category == veraApi.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 == veraApi.CATEGORY_POWER_METER:
power = convert(self.vera_device.power, float, 0)
self.current_value = int(round(power, 0))
elif self.vera_device.is_trippable:
tripped = self.vera_device.is_tripped