diff --git a/homeassistant/components/qwikswitch/__init__.py b/homeassistant/components/qwikswitch/__init__.py index 63e30a9491e..23144ed82b8 100644 --- a/homeassistant/components/qwikswitch/__init__.py +++ b/homeassistant/components/qwikswitch/__init__.py @@ -19,7 +19,7 @@ import homeassistant.helpers.config_validation as cv from homeassistant.helpers.discovery import load_platform from homeassistant.helpers.entity import Entity -REQUIREMENTS = ['pyqwikswitch==0.8'] +REQUIREMENTS = ['pyqwikswitch==0.93'] _LOGGER = logging.getLogger(__name__) @@ -119,7 +119,8 @@ class QSToggleEntity(QSEntity): async def async_setup(hass, config): """Qwiskswitch component setup.""" from pyqwikswitch.async_ import QSUsb - from pyqwikswitch import CMD_BUTTONS, QS_CMD, QS_ID, QSType, SENSORS + from pyqwikswitch.qwikswitch import ( + CMD_BUTTONS, QS_CMD, QS_ID, QSType, SENSORS) # Add cmd's to in /&listen packets will fire events # By default only buttons of type [TOGGLE,SCENE EXE,LEVEL] diff --git a/homeassistant/components/qwikswitch/binary_sensor.py b/homeassistant/components/qwikswitch/binary_sensor.py index 17021f7a9e9..6cdc29deae4 100644 --- a/homeassistant/components/qwikswitch/binary_sensor.py +++ b/homeassistant/components/qwikswitch/binary_sensor.py @@ -35,7 +35,7 @@ class QSBinarySensor(QSEntity, BinarySensorDevice): def __init__(self, sensor): """Initialize the sensor.""" - from pyqwikswitch import SENSORS + from pyqwikswitch.qwikswitch import SENSORS super().__init__(sensor['id'], sensor['name']) self.channel = sensor['channel'] diff --git a/homeassistant/components/qwikswitch/sensor.py b/homeassistant/components/qwikswitch/sensor.py index 07d0247e4f6..b9ccb3c3a7b 100644 --- a/homeassistant/components/qwikswitch/sensor.py +++ b/homeassistant/components/qwikswitch/sensor.py @@ -33,7 +33,7 @@ class QSSensor(QSEntity): def __init__(self, sensor): """Initialize the sensor.""" - from pyqwikswitch import SENSORS + from pyqwikswitch.qwikswitch import SENSORS super().__init__(sensor['id'], sensor['name']) self.channel = sensor['channel'] diff --git a/requirements_all.txt b/requirements_all.txt index 9f7ee3d3f3a..1ef9af9c970 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -1238,7 +1238,7 @@ pypollencom==2.2.3 pyps4-homeassistant==0.5.2 # homeassistant.components.qwikswitch -pyqwikswitch==0.8 +pyqwikswitch==0.93 # homeassistant.components.nmbs.sensor pyrail==0.0.3 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 974cfef9cd0..5d58e42e8b2 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -234,7 +234,7 @@ pyotp==2.2.6 pyps4-homeassistant==0.5.2 # homeassistant.components.qwikswitch -pyqwikswitch==0.8 +pyqwikswitch==0.93 # homeassistant.components.smartthings pysmartapp==0.3.2 diff --git a/tests/components/qwikswitch/test_init.py b/tests/components/qwikswitch/test_init.py index 76655f32816..d6ad0607d42 100644 --- a/tests/components/qwikswitch/test_init.py +++ b/tests/components/qwikswitch/test_init.py @@ -7,6 +7,7 @@ from homeassistant.const import EVENT_HOMEASSISTANT_START from homeassistant.components.qwikswitch import DOMAIN as QWIKSWITCH from homeassistant.bootstrap import async_setup_component from tests.test_util.aiohttp import mock_aiohttp_client +from aiohttp.client_exceptions import ClientError _LOGGER = logging.getLogger(__name__) @@ -23,6 +24,8 @@ class AiohttpClientMockResponseList(list): try: res = list.pop(self, 0) _LOGGER.debug("MockResponseList popped %s: %s", res, self) + if isinstance(res, Exception): + raise res return res except IndexError: raise AssertionError("MockResponseList empty") @@ -54,7 +57,7 @@ def aioclient_mock(): yield mock_session -async def test_binary_sensor_device(hass, aioclient_mock): +async def test_binary_sensor_device(hass, aioclient_mock): # noqa """Test a binary sensor device.""" config = { 'qwikswitch': { @@ -75,7 +78,8 @@ async def test_binary_sensor_device(hass, aioclient_mock): hass.bus.async_fire(EVENT_HOMEASSISTANT_START) LISTEN.append('{"id":"@a00001","cmd":"","data":"4e0e1601","rssi":"61%"}') - LISTEN.append('') # Will cause a sleep + LISTEN.append(ClientError()) # Will cause a sleep + await hass.async_block_till_done() state_obj = hass.states.get('binary_sensor.s1') assert state_obj.state == 'on' @@ -87,7 +91,7 @@ async def test_binary_sensor_device(hass, aioclient_mock): assert state_obj.state == 'off' -async def test_sensor_device(hass, aioclient_mock): +async def test_sensor_device(hass, aioclient_mock): # noqa """Test a sensor device.""" config = { 'qwikswitch': { @@ -100,8 +104,8 @@ async def test_sensor_device(hass, aioclient_mock): } } await async_setup_component(hass, QWIKSWITCH, config) - await hass.async_block_till_done() + await hass.async_block_till_done() state_obj = hass.states.get('sensor.ss1') assert state_obj.state == 'None' @@ -110,8 +114,7 @@ async def test_sensor_device(hass, aioclient_mock): LISTEN.append( '{"id":"@a00001","name":"ss1","type":"rel",' '"val":"4733800001a00000"}') - LISTEN.append('') # Will cause a sleep - await LISTEN.wait_till_empty(hass) # await hass.async_block_till_done() + await hass.async_block_till_done() state_obj = hass.states.get('sensor.ss1') - assert state_obj.state == 'None' + assert state_obj.state == '416'