mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
parent
ae4e792651
commit
7595401dcb
@ -64,6 +64,12 @@ class QSEntity(Entity):
|
|||||||
"""QS sensors gets packets in update_packet."""
|
"""QS sensors gets packets in update_packet."""
|
||||||
return False
|
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):
|
def update_packet(self, packet):
|
||||||
"""Receive update packet from QSUSB. Match dispather_send signature."""
|
"""Receive update packet from QSUSB. Match dispather_send signature."""
|
||||||
self.async_schedule_update_ha_state()
|
self.async_schedule_update_ha_state()
|
||||||
|
@ -7,6 +7,7 @@ https://home-assistant.io/components/sensor.qwikswitch/
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
from homeassistant.components.qwikswitch import DOMAIN as QWIKSWITCH, QSEntity
|
from homeassistant.components.qwikswitch import DOMAIN as QWIKSWITCH, QSEntity
|
||||||
|
from homeassistant.core import callback
|
||||||
|
|
||||||
DEPENDENCIES = [QWIKSWITCH]
|
DEPENDENCIES = [QWIKSWITCH]
|
||||||
|
|
||||||
@ -41,6 +42,7 @@ class QSSensor(QSEntity):
|
|||||||
if isinstance(self.unit, type):
|
if isinstance(self.unit, type):
|
||||||
self.unit = "{}:{}".format(self.sensor_type, self.channel)
|
self.unit = "{}:{}".format(self.sensor_type, self.channel)
|
||||||
|
|
||||||
|
@callback
|
||||||
def update_packet(self, packet):
|
def update_packet(self, packet):
|
||||||
"""Receive update packet from QSUSB."""
|
"""Receive update packet from QSUSB."""
|
||||||
val = self._decode(packet.get('data'), channel=self.channel)
|
val = self._decode(packet.get('data'), channel=self.channel)
|
||||||
@ -55,6 +57,11 @@ class QSSensor(QSEntity):
|
|||||||
"""Return the value of the sensor."""
|
"""Return the value of the sensor."""
|
||||||
return str(self._val)
|
return str(self._val)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def unique_id(self):
|
||||||
|
"""Return a unique identifier for this sensor."""
|
||||||
|
return "qs{}:{}".format(self.qsid, self.channel)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unit_of_measurement(self):
|
def unit_of_measurement(self):
|
||||||
"""Return the unit the value is expressed in."""
|
"""Return the unit the value is expressed in."""
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
"""Test qwikswitch sensors."""
|
"""Test qwikswitch sensors."""
|
||||||
import asyncio
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
@ -29,7 +28,6 @@ class AiohttpClientMockResponseList(list):
|
|||||||
async def wait_till_empty(self, hass):
|
async def wait_till_empty(self, hass):
|
||||||
"""Wait until empty."""
|
"""Wait until empty."""
|
||||||
while self:
|
while self:
|
||||||
await asyncio.sleep(1)
|
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
@ -54,7 +52,6 @@ def aioclient_mock():
|
|||||||
yield mock_session
|
yield mock_session
|
||||||
|
|
||||||
|
|
||||||
# @asyncio.coroutine
|
|
||||||
async def test_sensor_device(hass, aioclient_mock):
|
async def test_sensor_device(hass, aioclient_mock):
|
||||||
"""Test a sensor device."""
|
"""Test a sensor device."""
|
||||||
config = {
|
config = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user