Skip to content
Merged
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
6 changes: 6 additions & 0 deletions homeassistant/components/qwikswitch.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ def poll(self):
"""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()
Expand Down
7 changes: 7 additions & 0 deletions homeassistant/components/sensor/qwikswitch.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import logging

from homeassistant.components.qwikswitch import DOMAIN as QWIKSWITCH, QSEntity
from homeassistant.core import callback

DEPENDENCIES = [QWIKSWITCH]

Expand Down Expand Up @@ -41,6 +42,7 @@ def __init__(self, sensor):
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)
Expand All @@ -55,6 +57,11 @@ def state(self):
"""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."""
Expand Down
3 changes: 0 additions & 3 deletions tests/components/sensor/test_qwikswitch.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Test qwikswitch sensors."""
import asyncio
import logging

import pytest
Expand Down Expand Up @@ -29,7 +28,6 @@ def decode(self, _):
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()

Expand All @@ -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 = {
Expand Down