8000 Switched VeraSensor to use category ids by alanfischer · Pull Request #9624 · home-assistant/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Switched VeraSensor to use category ids # 8000 9624

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 29, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions homeassistant/components/sensor/vera.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,20 @@ def state(self):
@property
def unit_of_measurement(self):
"""Return the unit of measurement of this entity, if any."""
if self.vera_device.category == "Temperature Sensor":
import pyvera as veraApi
if self.vera_device.category == veraApi.CATEGORY_TEMPERATURE_SENSOR:
return self._temperature_units
elif self.vera_device.category == "Light Sensor":
elif self.vera_device.category == veraApi.CATEGORY_LIGHT_SENSOR:
return 'lux'
elif self.vera_device.category == "Humidity Sensor":
elif self.vera_device.category == veraApi.CATEGORY_HUMIDITY_SENSOR:
return '%'
elif self.vera_device.category == "Power meter":
elif self.vera_device.category == veraApi.CATEGORY_POWER_METER:
return 'watts'

def update(self):
"""Update the state."""
if self.vera_device.category == "Temperature Sensor":
import pyvera as veraApi
if self.vera_device.category == veraApi.CATEGORY_TEMPERATURE_SENSOR:
self.current_value = self.vera_device.temperature

vera_temp_units = (
Expand All @@ -70,22 +72,22 @@ def update(self):
else:
self._temperature_units = TEMP_CELSIUS

elif self.vera_device.category == "Light Sensor":
elif self.vera_device.category == veraApi.CATEGORY_LIGHT_SENSOR:
self.current_value = self.vera_device.light
elif self.vera_device.category == "Humidity Sensor":
elif self.vera_device.category == veraApi.CATEGORY_HUMIDITY_SENSOR:
self.current_value = self.vera_device.humidity
elif self.vera_device.category == "Scene Controller":
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 == "Power meter":
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.category == "Sensor":
elif self.vera_device.is_trippable:
tripped = self.vera_device.is_tripped
self.current_value = 'Tripped' if tripped else 'Not Tripped'
else:
Expand Down
0