Address last comments

This commit is contained in:
Paulus Schoutsen committed 2016-08-04 22:44:37 -07:00
1 parent 26526ca57a
commit 231656916c
7 files changed
+33 -57

No files matched your search

+2 -9
View File
@@ -51,7 +51,8 @@ class VeraSensor(VeraDevice, Entity):
def update(self):
"""Update the state."""
if self.vera_device.category == "Temperature Sensor":
current_temp = self.vera_device.temperature
self.current_value = self.vera_device.temperature
vera_temp_units = (
self.vera_device.vera_controller.temperature_units)
@@ -60,14 +61,6 @@ class VeraSensor(VeraDevice, Entity):
else:
self._temperature_units = TEMP_CELSIUS
if self.hass:
temp = self.hass.config.units.temperature(
current_temp,
self._temperature_units)
current_temp = temp
self.current_value = current_temp
elif self.vera_device.category == "Light Sensor":
self.current_value = self.vera_device.light
elif self.vera_device.category == "Humidity Sensor":
@@ -147,14 +147,11 @@ def setup(hass, config):
temperature = service.data[ATTR_TEMPERATURE]
for thermostat in target_thermostats:
if thermostat.unit_of_measurement is not None:
converted_temperature = convert(
temperature, hass.config.units.temperature_unit,
thermostat.unit_of_measurement)
else:
converted_temperature = temperature
thermostat.set_temperature(converted_temperature)
converted_temperature = convert(
temperature, hass.config.units.temperature_unit,
thermostat.unit_of_measurement)
thermostat.set_temperature(converted_temperature)
thermostat.update_ha_state(True)
hass.services.register(
@@ -306,20 +303,12 @@ class ThermostatDevice(Entity):
@property
def min_temp(self):
"""Return the minimum temperature."""
try:
unit = self.unit_of_measurement
return convert(7, TEMP_CELSIUS, unit)
except ValueError:
return STATE_UNKNOWN
return convert(7, TEMP_CELSIUS, self.unit_of_measurement)
@property
def max_temp(self):
"""Return the maximum temperature."""
try:
unit = self.unit_of_measurement
return convert(35, TEMP_CELSIUS, unit)
except ValueError:
return STATE_UNKNOWN
return convert(35, TEMP_CELSIUS, self.unit_of_measurement)
def _convert_for_display(self, temp):
"""Convert temperature into preferred units for display purposes."""
@@ -8,12 +8,10 @@ import logging
import voluptuous as vol
import homeassistant.helpers.config_validation as cv
import homeassistant.util as util
from homeassistant.components import switch
from homeassistant.components.thermostat import (
STATE_HEAT, STATE_COOL, STATE_IDLE, ThermostatDevice)
from homeassistant.const import (
ATTR_UNIT_OF_MEASUREMENT, TEMP_CELSIUS, TEMP_FAHRENHEIT)
from homeassistant.const import ATTR_UNIT_OF_MEASUREMENT
from homeassistant.helpers.event import track_state_change
DEPENDENCIES = ['switch', 'sensor']
@@ -157,24 +155,11 @@ class HeatControl(ThermostatDevice):
"""Update thermostat with latest state from sensor."""
unit = state.attributes.get(ATTR_UNIT_OF_MEASUREMENT)
if unit not in (TEMP_CELSIUS, TEMP_FAHRENHEIT):
self._cur_temp = None
self._unit = None
_LOGGER.error('Sensor has unsupported unit: %s (allowed: %s, %s)',
unit, TEMP_CELSIUS, TEMP_FAHRENHEIT)
return
temp = util.convert(state.state, float)
if temp is None:
self._cur_temp = None
self._unit = None
_LOGGER.error('Unable to parse sensor temperature: %s',
state.state)
return
self._cur_temp = temp
self._unit = unit
try:
self._cur_temp = self.hass.config.units.temperature(
float(state.state), unit)
except ValueError as ex:
_LOGGER.error('Unable to update from sensor: %s', ex)
def _control_heating(self):
"""Check if we need to turn heating on or off."""