diff --git a/homeassistant/components/qwikswitch.py b/homeassistant/components/qwikswitch.py index 36bd726fa2d..4d34ccca24a 100644 --- a/homeassistant/components/qwikswitch.py +++ b/homeassistant/components/qwikswitch.py @@ -64,6 +64,12 @@ class QSEntity(Entity): """QS sensors gets packets in update_packet.""" return False + @property + def unique_id(self): + """Return a unique identifier for this sensor.""" + return "qs{}".format(self.qsid) + + @callback def update_packet(self, packet): """Receive update packet from QSUSB. Match dispather_send signature.""" self.async_schedule_update_ha_state() diff --git a/homeassistant/components/sensor/qwikswitch.py b/homeassistant/components/sensor/qwikswitch.py index 98c67b7a21c..ebd5f5254d4 100644 --- a/homeassistant/components/sensor/qwikswitch.py +++ b/homeassistant/components/sensor/qwikswitch.py @@ -7,6 +7,7 @@ https://home-assistant.io/components/sensor.qwikswitch/ import logging from homeassistant.components.qwikswitch import DOMAIN as QWIKSWITCH, QSEntity +from homeassistant.core import callback DEPENDENCIES = [QWIKSWITCH] @@ -41,6 +42,7 @@ class QSSensor(QSEntity): if isinstance(self.unit, type): self.unit = "{}:{}".format(self.sensor_type, self.channel) + @callback def update_packet(self, packet): """Receive update packet from QSUSB.""" val = self._decode(packet.get('data'), channel=self.channel) @@ -55,6 +57,11 @@ class QSSensor(QSEntity): """Return the value of the sensor.""" return str(self._val) + @property + def unique_id(self): + """Return a unique identifier for this sensor.""" + return "qs{}:{}".format(self.qsid, self.channel) + @property def unit_of_measurement(self): """Return the unit the value is expressed in.""" diff --git a/tests/components/sensor/test_qwikswitch.py b/tests/components/sensor/test_qwikswitch.py index d9799b8530e..d9dfe072fc0 100644 --- a/tests/components/sensor/test_qwikswitch.py +++ b/tests/components/sensor/test_qwikswitch.py @@ -1,5 +1,4 @@ """Test qwikswitch sensors.""" -import asyncio import logging import pytest @@ -29,7 +28,6 @@ class AiohttpClientMockResponseList(list): async def wait_till_empty(self, hass): """Wait until empty.""" while self: - await asyncio.sleep(1) await hass.async_block_till_done() await hass.async_block_till_done() @@ -54,7 +52,6 @@ def aioclient_mock(): yield mock_session -# @asyncio.coroutine async def test_sensor_device(hass, aioclient_mock): """Test a sensor device.""" config = {