Merge branch 'dev' of github.com:andylockran/home-assistant into dev

This commit is contained in:
andylockran 2015-12-11 12:49:34 +00:00
commit 84226b573e
8 changed files with 39 additions and 38 deletions

View File

@ -1,11 +1,9 @@
sudo: false
language: python
cache:
directories:
- $HOME/virtualenv/python$TRAVIS_PYTHON_VERSION/
cache: pip
python:
- 3.4.2
- 3.5.0
- 3.4
- 3.5
install:
- script/bootstrap_server
script:

View File

@ -275,7 +275,7 @@ def enable_logging(hass, verbose=False, daemon=False, log_rotate_days=None):
datefmt='%y-%m-%d %H:%M:%S'))
logger = logging.getLogger('')
logger.addHandler(err_handler)
logger.setLevel(logging.INFO) # this sets the minimum log level
logger.setLevel(logging.NOTSET) # this sets the minimum log level
else:
_LOGGER.error(

View File

@ -79,6 +79,7 @@ def _handle_get_root(handler, path_match, data):
def _handle_get_service_worker(handler, path_match, data):
""" Returns service worker for the frontend. """
if handler.server.development:
sw_path = "home-assistant-polymer/build/service_worker.js"
else:

View File

@ -1,7 +1,7 @@
"""
homeassistant.components.rollershutter.demo
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Demo platform for rollorshutter component.
Demo platform for the rollorshutter component.
"""
from homeassistant.const import EVENT_TIME_CHANGED
from homeassistant.helpers.event import track_utc_time_change
@ -9,7 +9,7 @@ from homeassistant.components.rollershutter import RollershutterDevice
def setup_platform(hass, config, add_devices, discovery_info=None):
""" Sets up the Demo binary sensors. """
""" Sets up the Demo rollershutters. """
add_devices([
DemoRollershutter(hass, 'Kitchen Window', 0),
DemoRollershutter(hass, 'Living Room Window', 100),
@ -17,7 +17,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
class DemoRollershutter(RollershutterDevice):
""" Represents a rollershutter within Home Assistant. """
""" Represents a rollershutter.. """
# pylint: disable=no-self-use
def __init__(self, hass, name, position):
@ -29,14 +29,17 @@ class DemoRollershutter(RollershutterDevice):
@property
def name(self):
""" Returns the name of the rollershutter. """
return self._name
@property
def should_poll(self):
""" No polling needed for a demo rollershutter. """
return False
@property
def current_position(self):
""" Returns the current position of the rollershutter. """
return self._position
def move_up(self, **kwargs):
@ -62,11 +65,13 @@ class DemoRollershutter(RollershutterDevice):
self._listener = None
def _listen(self):
""" Listens for changes. """
if self._listener is None:
self._listener = track_utc_time_change(self.hass,
self._time_changed)
def _time_changed(self, now):
""" Track time changes. """
if self._moving_up:
self._position -= 10
else:

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')

View File

@ -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

View File

@ -76,7 +76,8 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
return False
persistence = config.get(CONF_PERSISTENCE, True)
persistence_file = config.get(CONF_PERSISTENCE_FILE, 'mysensors.pickle')
persistence_file = config.get(CONF_PERSISTENCE_FILE,
hass.config.path('mysensors.pickle'))
version = config.get(CONF_VERSION, '1.4')
gateway = mysensors.SerialGateway(port, sensor_update,

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)