1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 21:06:19 +00:00
This commit is contained in:
Paulus Schoutsen
2019-07-31 12:25:30 -07:00
parent da05dfe708
commit 4de97abc3a
2676 changed files with 163166 additions and 140084 deletions

View File

@@ -17,8 +17,12 @@ SCAN_INTERVAL = timedelta(seconds=5)
def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Vera controller devices."""
add_entities(
[VeraSensor(device, hass.data[VERA_CONTROLLER])
for device in hass.data[VERA_DEVICES]['sensor']], True)
[
VeraSensor(device, hass.data[VERA_CONTROLLER])
for device in hass.data[VERA_DEVICES]["sensor"]
],
True,
)
class VeraSensor(VeraDevice, Entity):
@@ -41,27 +45,28 @@ class VeraSensor(VeraDevice, Entity):
def unit_of_measurement(self):
"""Return the unit of measurement of this entity, if any."""
import pyvera as veraApi
if self.vera_device.category == veraApi.CATEGORY_TEMPERATURE_SENSOR:
return self._temperature_units
if self.vera_device.category == veraApi.CATEGORY_LIGHT_SENSOR:
return 'lx'
return "lx"
if self.vera_device.category == veraApi.CATEGORY_UV_SENSOR:
return 'level'
return "level"
if self.vera_device.category == veraApi.CATEGORY_HUMIDITY_SENSOR:
return '%'
return "%"
if self.vera_device.category == veraApi.CATEGORY_POWER_METER:
return 'watts'
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)
vera_temp_units = self.vera_device.vera_controller.temperature_units
if vera_temp_units == 'F':
if vera_temp_units == "F":
self._temperature_units = TEMP_FAHRENHEIT
else:
self._temperature_units = TEMP_CELSIUS
@@ -85,6 +90,6 @@ class VeraSensor(VeraDevice, Entity):
self.current_value = int(round(power, 0))
elif self.vera_device.is_trippable:
tripped = self.vera_device.is_tripped
self.current_value = 'Tripped' if tripped else 'Not Tripped'
self.current_value = "Tripped" if tripped else "Not Tripped"
else:
self.current_value = 'Unknown'
self.current_value = "Unknown"