Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"parent": 1,
"armed": "0",
"armedtripped": "0",
"configured": "1",
"batterylevel": "100",
"commFailure": "0",
"lasttrip": "1571975359",
"tripped": "0",
"state": -1,
"comment": "",
},
{
"name": "Temp sensor 1",
"altid": "m1",
"id": DEVICE_TEMP_SENSOR_ID,
"category": CATEGORY_TEMPERATURE_SENSOR,
"subcategory": 0,
"room": 0,
"parent": 51,
"configured": "0",
"temperature": "57.00",
},
{
"name": "Dimmer 1",
"altid": "16",
"id": DEVICE_DIMMER_ID,
"category": CATEGORY_DIMMER,
"subcategory": 2,
"room": 0,
"parent": 1,
"kwh": "0.0000",
"watts": "0",
def unit_of_measurement(self):
"""Return the unit of measurement of this entity, if any."""
if self.vera_device.category == veraApi.CATEGORY_TEMPERATURE_SENSOR:
return self._temperature_units
if self.vera_device.category == veraApi.CATEGORY_LIGHT_SENSOR:
return "lx"
if self.vera_device.category == veraApi.CATEGORY_UV_SENSOR:
return "level"
if self.vera_device.category == veraApi.CATEGORY_HUMIDITY_SENSOR:
return "%"
if self.vera_device.category == veraApi.CATEGORY_POWER_METER:
return "watts"
def update(self):
"""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