diff --git a/homeassistant/components/alarm_control_panel/alarmdotcom.py b/homeassistant/components/alarm_control_panel/alarmdotcom.py index 22cbdefd403..6e99ba67257 100644 --- a/homeassistant/components/alarm_control_panel/alarmdotcom.py +++ b/homeassistant/components/alarm_control_panel/alarmdotcom.py @@ -17,7 +17,7 @@ from homeassistant.const import ( import homeassistant.helpers.config_validation as cv from homeassistant.helpers.aiohttp_client import async_get_clientsession -REQUIREMENTS = ['pyalarmdotcom==0.2.9'] +REQUIREMENTS = ['pyalarmdotcom==0.3.0'] _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/binary_sensor/workday.py b/homeassistant/components/binary_sensor/workday.py index c2590925df7..c25ea81922b 100644 --- a/homeassistant/components/binary_sensor/workday.py +++ b/homeassistant/components/binary_sensor/workday.py @@ -66,8 +66,9 @@ def setup_platform(hass, config, add_devices, discovery_info=None): obj_holidays = getattr(holidays, country)(years=year) if province: - if province not in obj_holidays.PROVINCES: - _LOGGER.error('There is no province/state %s in country %s', + if province not in obj_holidays.PROVINCES and \ + province not in obj_holidays.STATES: + _LOGGER.error("There is no province/state %s in country %s", province, country) return False else: diff --git a/homeassistant/components/camera/synology.py b/homeassistant/components/camera/synology.py index e986d81887b..378d75ac26d 100644 --- a/homeassistant/components/camera/synology.py +++ b/homeassistant/components/camera/synology.py @@ -81,7 +81,9 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None): params=query_payload ) - query_resp = yield from query_req.json() + # Skip content type check because Synology doesn't return JSON with + # right content type + query_resp = yield from query_req.json(content_type=None) auth_path = query_resp['data'][AUTH_API]['path'] camera_api = query_resp['data'][CAMERA_API]['path'] camera_path = query_resp['data'][CAMERA_API]['path'] @@ -127,7 +129,7 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None): _LOGGER.exception("Error on %s", syno_camera_url) return False - camera_resp = yield from camera_req.json() + camera_resp = yield from camera_req.json(content_type=None) cameras = camera_resp['data']['cameras'] # add cameras @@ -172,7 +174,7 @@ def get_session_id(hass, websession, username, password, login_url, timeout): login_url, params=auth_payload ) - auth_resp = yield from auth_req.json() + auth_resp = yield from auth_req.json(content_type=None) return auth_resp['data']['sid'] except (asyncio.TimeoutError, aiohttp.ClientError): diff --git a/homeassistant/components/input_slider.py b/homeassistant/components/input_slider.py index d10120e673b..c4976bb43e8 100644 --- a/homeassistant/components/input_slider.py +++ b/homeassistant/components/input_slider.py @@ -174,8 +174,8 @@ class InputSlider(Entity): state = yield from async_get_last_state(self.hass, self.entity_id) value = state and float(state.state) - # Check against False because value can be 0 - if value is not False and self._minimum < value < self._maximum: + # Check against None because value can be 0 + if value is not None and self._minimum <= value <= self._maximum: self._current_value = value else: self._current_value = self._minimum diff --git a/homeassistant/components/light/lifx.py b/homeassistant/components/light/lifx.py index 76a2a9e907d..da09601c1bb 100644 --- a/homeassistant/components/light/lifx.py +++ b/homeassistant/components/light/lifx.py @@ -26,7 +26,7 @@ import homeassistant.helpers.config_validation as cv _LOGGER = logging.getLogger(__name__) -REQUIREMENTS = ['aiolifx==0.4.2'] +REQUIREMENTS = ['aiolifx==0.4.4'] UDP_BROADCAST_PORT = 56700 @@ -84,6 +84,7 @@ class LIFXManager(object): entity = self.entities[device.mac_addr] _LOGGER.debug("%s register AGAIN", entity.ipaddr) entity.available = True + entity.device = device self.hass.async_add_job(entity.async_update_ha_state()) else: _LOGGER.debug("%s register NEW", device.ip_addr) diff --git a/homeassistant/const.py b/homeassistant/const.py index 85c3ba2260d..e75dd5a2125 100644 --- a/homeassistant/const.py +++ b/homeassistant/const.py @@ -2,7 +2,7 @@ """Constants used by Home Assistant components.""" MAJOR_VERSION = 0 MINOR_VERSION = 42 -PATCH_VERSION = '2' +PATCH_VERSION = '3' __short_version__ = '{}.{}'.format(MAJOR_VERSION, MINOR_VERSION) __version__ = '{}.{}'.format(__short_version__, PATCH_VERSION) REQUIRED_PYTHON_VER = (3, 4, 2) diff --git a/homeassistant/core.py b/homeassistant/core.py index 899bed064ed..320e857ac9e 100644 --- a/homeassistant/core.py +++ b/homeassistant/core.py @@ -164,15 +164,16 @@ class HomeAssistant(object): self.bus.async_fire(EVENT_HOMEASSISTANT_START) try: + # only block for EVENT_HOMEASSISTANT_START listener + self.async_stop_track_tasks() with timeout(TIMEOUT_EVENT_START, loop=self.loop): - yield from self.async_stop_track_tasks() + yield from self.async_block_till_done() except asyncio.TimeoutError: _LOGGER.warning( 'Something is blocking Home Assistant from wrapping up the ' 'start up phase. We\'re going to continue anyway. Please ' 'report the following info at http://bit.ly/2ogP58T : %s', ', '.join(self.config.components)) - self._track_task = False self.state = CoreState.running _async_create_timer(self) @@ -218,10 +219,9 @@ class HomeAssistant(object): """Track tasks so you can wait for all tasks to be done.""" self._track_task = True - @asyncio.coroutine + @callback def async_stop_track_tasks(self): - """Track tasks so you can wait for all tasks to be done.""" - yield from self.async_block_till_done() + """Stop track tasks so you can't wait for all tasks to be done.""" self._track_task = False @callback @@ -246,8 +246,6 @@ class HomeAssistant(object): @asyncio.coroutine def async_block_till_done(self): """Block till all pending work is done.""" - assert self._track_task, 'Not tracking tasks' - # To flush out any call_soon_threadsafe yield from asyncio.sleep(0, loop=self.loop) diff --git a/requirements_all.txt b/requirements_all.txt index 7e800d62548..07712308235 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -44,7 +44,7 @@ aiodns==1.1.1 aiohttp_cors==0.5.2 # homeassistant.components.light.lifx -aiolifx==0.4.2 +aiolifx==0.4.4 # homeassistant.components.camera.amcrest # homeassistant.components.sensor.amcrest @@ -475,7 +475,7 @@ pyHS100==0.2.4.2 pyRFXtrx==0.17.0 # homeassistant.components.alarm_control_panel.alarmdotcom -pyalarmdotcom==0.2.9 +pyalarmdotcom==0.3.0 # homeassistant.components.notify.xmpp pyasn1-modules==0.0.8 diff --git a/tests/common.py b/tests/common.py index 9dc077dc3f7..03a4de235d7 100644 --- a/tests/common.py +++ b/tests/common.py @@ -122,8 +122,7 @@ def async_test_home_assistant(loop): # 1. We only mock time during tests # 2. We want block_till_done that is called inside stop_track_tasks with patch('homeassistant.core._async_create_timer'), \ - patch.object(hass, 'async_stop_track_tasks', - hass.async_block_till_done): + patch.object(hass, 'async_stop_track_tasks'): yield from orig_start() hass.async_start = mock_async_start diff --git a/tests/components/test_input_slider.py b/tests/components/test_input_slider.py index 7097e87e646..f550091e31f 100644 --- a/tests/components/test_input_slider.py +++ b/tests/components/test_input_slider.py @@ -133,3 +133,21 @@ def test_initial_state_overrules_restore_state(hass): state = hass.states.get('input_slider.b2') assert state assert float(state.state) == 60 + + +@asyncio.coroutine +def test_no_initial_state_and_no_restore_state(hass): + """Ensure that entity is create without initial and restore feature.""" + hass.state = CoreState.starting + + yield from async_setup_component(hass, DOMAIN, { + DOMAIN: { + 'b1': { + 'min': 0, + 'max': 100, + }, + }}) + + state = hass.states.get('input_slider.b1') + assert state + assert float(state.state) == 0 diff --git a/tests/test_core.py b/tests/test_core.py index b2fca047292..89ae6c5f651 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -901,7 +901,6 @@ def test_start_taking_too_long(loop, caplog): patch('homeassistant.core._async_create_timer') as mock_timer: yield from hass.async_start() - assert not hass._track_task assert hass.state == ha.CoreState.running assert len(mock_timer.mock_calls) == 1 assert mock_timer.mock_calls[0][1][0] is hass @@ -910,3 +909,19 @@ def test_start_taking_too_long(loop, caplog): finally: yield from hass.async_stop() assert hass.state == ha.CoreState.not_running + + +@asyncio.coroutine +def test_track_task_functions(loop): + """Test function to start/stop track task and initial state.""" + hass = ha.HomeAssistant(loop=loop) + try: + assert hass._track_task + + hass.async_stop_track_tasks() + assert not hass._track_task + + hass.async_track_tasks() + assert hass._track_task + finally: + yield from hass.async_stop()