Merge branch 'dev' into mysensors-component-switch

This commit is contained in:
MartinHjelmare committed 2015-12-18 03:39:41 +01:00
commit eae07c070a
24 files changed
+278 -117

No files matched your search

+8 -9
View File
@@ -127,15 +127,14 @@ class ArestSensor(Entity):
if 'error' in values:
return values['error']
elif 'value' in values:
if self._corr_factor is not None \
and self._decimal_places is not None:
return round((float(values['value']) *
float(self._corr_factor)), self._decimal_places)
elif self._corr_factor is not None \
and self._decimal_places is None:
return round(float(values['value']) * float(self._corr_factor))
else:
return values['value']
value = values['value']
if self._corr_factor is not None:
value = float(value) * float(self._corr_factor)
if self._decimal_places is not None:
value = round(value, self._decimal_places)
if self._decimal_places == 0:
value = int(value)
return value
else:
return values.get(self._variable, 'n/a')
@@ -35,8 +35,8 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
data,
config.get('name', DEFAULT_NAME),
config.get('unit_of_measurement'),
config.get('correction_factor', 1.0),
config.get('decimal_places', 0)
config.get('correction_factor', None),
config.get('decimal_places', None)
)])
@@ -49,7 +49,7 @@ class CommandSensor(Entity):
self._name = name
self._state = False
self._unit_of_measurement = unit_of_measurement
self._corr_factor = float(corr_factor)
self._corr_factor = corr_factor
self._decimal_places = decimal_places
self.update()
@@ -76,10 +76,12 @@ class CommandSensor(Entity):
try:
if value is not None:
if self._corr_factor is not None:
self._state = round((float(value) * self._corr_factor),
self._decimal_places)
else:
self._state = value
value = float(value) * float(self._corr_factor)
if self._decimal_places is not None:
value = round(value, self._decimal_places)
if self._decimal_places == 0:
value = int(value)
self._state = value
except ValueError:
self._state = value
+1 -10
View File
@@ -147,17 +147,8 @@ class ForeCastSensor(Entity):
self._state = data.nearestStormBearing
elif self.type == 'precip_intensity':
self._state = data.precipIntensity
if data.precipIntensity == 0:
self._state = 'None'
self._unit_of_measurement = ''
else:
self._state = data.precipIntensity
elif self.type == 'precip_type':
if data.precipType is None:
self._state = 'None'
self._unit_of_measurement = ''
else:
self._state = data.precipType
self._state = data.precipType
elif self.type == 'precip_probability':
self._state = round(data.precipProbability * 100, 1)
elif self.type == 'dew_point':
+7 -12
View File
@@ -136,18 +136,13 @@ class RestSensor(Entity):
try:
if value is not None:
value = RestSensor.extract_value(value, self._variable)
if self._corr_factor is not None \
and self._decimal_places is not None:
self._state = round(
(float(value) *
float(self._corr_factor)),
self._decimal_places)
elif self._corr_factor is not None \
and self._decimal_places is None:
self._state = round(float(value) *
float(self._corr_factor))
else:
self._state = value
if self._corr_factor is not None:
value = float(value) * float(self._corr_factor)
if self._decimal_places is not None:
value = round(value, self._decimal_places)
if self._decimal_places == 0:
value = int(value)
self._state = value
except ValueError:
self._state = RestSensor.extract_value(value, self._variable)