Qwikswitch fix listen loop (#22600)

* Qwikswitch fix listen loop
* 0.93 fix qwikcord upstream
pull/22655/head
Johann Kellerman 2019-04-02 05:57:25 +02:00 committed by GitHub
parent 7646dc00e0
commit 2578c8525b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 17 additions and 13 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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