mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Add humidity sensor, add units for humidity and light sensors.
This commit is contained in:
parent
86b0e49995
commit
c4e1035638
@ -45,7 +45,10 @@ def get_devices(hass, config):
|
|||||||
|
|
||||||
hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP, stop_subscription)
|
hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP, stop_subscription)
|
||||||
|
|
||||||
categories = ['Temperature Sensor', 'Light Sensor', 'Sensor']
|
categories = ['Temperature Sensor',
|
||||||
|
'Light Sensor',
|
||||||
|
'Humidity Sensor',
|
||||||
|
'Sensor']
|
||||||
devices = []
|
devices = []
|
||||||
try:
|
try:
|
||||||
devices = vera_controller.get_devices(categories)
|
devices = vera_controller.get_devices(categories)
|
||||||
@ -106,7 +109,12 @@ class VeraSensor(Entity):
|
|||||||
@property
|
@property
|
||||||
def unit_of_measurement(self):
|
def unit_of_measurement(self):
|
||||||
""" Unit of measurement of this entity, if any. """
|
""" Unit of measurement of this entity, if any. """
|
||||||
return self._temperature_units
|
if self.vera_device.category == "Temperature Sensor":
|
||||||
|
return self._temperature_units
|
||||||
|
elif self.vera_device.category == "Light Sensor":
|
||||||
|
return 'lux'
|
||||||
|
elif self.vera_device.category == "Humidity Sensor":
|
||||||
|
return '%'
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def state_attributes(self):
|
def state_attributes(self):
|
||||||
@ -140,7 +148,7 @@ class VeraSensor(Entity):
|
|||||||
def update(self):
|
def update(self):
|
||||||
if self.vera_device.category == "Temperature Sensor":
|
if self.vera_device.category == "Temperature Sensor":
|
||||||
current_temp = self.vera_device.get_value('CurrentTemperature')
|
current_temp = self.vera_device.get_value('CurrentTemperature')
|
||||||
vera_temp_units = self.vera_device.veraController.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
|
self._temperature_units = TEMP_FAHRENHEIT
|
||||||
@ -157,6 +165,8 @@ class VeraSensor(Entity):
|
|||||||
self.current_value = current_temp
|
self.current_value = current_temp
|
||||||
elif self.vera_device.category == "Light Sensor":
|
elif self.vera_device.category == "Light Sensor":
|
||||||
self.current_value = self.vera_device.get_value('CurrentLevel')
|
self.current_value = self.vera_device.get_value('CurrentLevel')
|
||||||
|
elif self.vera_device.category == "Humidity Sensor":
|
||||||
|
self.current_value = self.vera_device.get_value('CurrentLevel')
|
||||||
elif self.vera_device.category == "Sensor":
|
elif self.vera_device.category == "Sensor":
|
||||||
tripped = self.vera_device.get_value('Tripped')
|
tripped = self.vera_device.get_value('Tripped')
|
||||||
self.current_value = 'Tripped' if tripped == '1' else 'Not Tripped'
|
self.current_value = 'Tripped' if tripped == '1' else 'Not Tripped'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user