Skip to content
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

0.42.3 #7050

Merged
merged 8 commits into from
Apr 11, 2017
Merged

0.42.3 #7050

Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
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__)

Expand Down
5 changes: 3 additions & 2 deletions homeassistant/components/binary_sensor/workday.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 5 additions & 3 deletions homeassistant/components/camera/synology.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/input_slider.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ def async_added_to_hass(self):
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
Expand Down
3 changes: 2 additions & 1 deletion homeassistant/components/light/lifx.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

_LOGGER = logging.getLogger(__name__)

REQUIREMENTS = ['aiolifx==0.4.2']
REQUIREMENTS = ['aiolifx==0.4.4']

UDP_BROADCAST_PORT = 56700

Expand Down Expand Up @@ -84,6 +84,7 @@ def register(self, device):
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)
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 5 additions & 7 deletions homeassistant/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,15 +164,16 @@ def async_start(self):
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)
Expand Down Expand Up @@ -218,10 +219,9 @@ def async_track_tasks(self):
"""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
Expand All @@ -246,8 +246,6 @@ def block_till_done(self) -> None:
@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)

Expand Down
4 changes: 2 additions & 2 deletions requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,7 @@ def mock_async_start():
# 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
Expand Down
18 changes: 18 additions & 0 deletions tests/components/test_input_slider.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
17 changes: 16 additions & 1 deletion tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()