1 """Support for Qwikswitch Binary Sensors."""
3 from __future__
import annotations
7 from pyqwikswitch.qwikswitch
import SENSORS
14 from .
import DOMAIN
as QWIKSWITCH
15 from .entity
import QSEntity
17 _LOGGER = logging.getLogger(__name__)
23 add_entities: AddEntitiesCallback,
24 discovery_info: DiscoveryInfoType |
None =
None,
26 """Add binary sensor from the main Qwikswitch component."""
27 if discovery_info
is None:
30 qsusb = hass.data[QWIKSWITCH]
31 _LOGGER.debug(
"Setup qwikswitch.binary_sensor %s, %s", qsusb, discovery_info)
32 devs = [
QSBinarySensor(sensor)
for sensor
in discovery_info[QWIKSWITCH]]
37 """Sensor based on a Qwikswitch relay/dimmer module."""
42 """Initialize the sensor."""
44 super().
__init__(sensor[
"id"], sensor[
"name"])
46 sensor_type = sensor[
"type"]
48 self._decode, _ = SENSORS[sensor_type]
49 self.
_invert_invert =
not sensor.get(
"invert",
False)
50 self.
_class_class = sensor.get(
"class",
"door")
54 """Receive update packet from QSUSB."""
55 val = self._decode(packet, channel=self.
channelchannel)
57 "Update %s (%s:%s) decoded as %s: %s",
70 """Check if device is on (non-zero)."""
75 """Return a unique identifier for this sensor."""
76 return f
"qs{self.qsid}:{self.channel}"
80 """Return the class of this sensor."""
def __init__(self, sensor)
def update_packet(self, packet)
None async_write_ha_state(self)
None add_entities(AsusWrtRouter router, AddEntitiesCallback async_add_entities, set[str] tracked)
None async_setup_platform(HomeAssistant hass, ConfigType _, AddEntitiesCallback add_entities, DiscoveryInfoType|None discovery_info=None)