Black
This commit is contained in:
parent
da05dfe708
commit
4de97abc3a
2676 changed files with 163166 additions and 140084 deletions
|
@ -15,8 +15,7 @@ async def async_setup_platform(hass, _, add_entities, discovery_info=None):
|
|||
return
|
||||
|
||||
qsusb = hass.data[QWIKSWITCH]
|
||||
_LOGGER.debug("Setup qwikswitch.binary_sensor %s, %s",
|
||||
qsusb, discovery_info)
|
||||
_LOGGER.debug("Setup qwikswitch.binary_sensor %s, %s", qsusb, discovery_info)
|
||||
devs = [QSBinarySensor(sensor) for sensor in discovery_info[QWIKSWITCH]]
|
||||
add_entities(devs)
|
||||
|
||||
|
@ -30,20 +29,26 @@ class QSBinarySensor(QSEntity, BinarySensorDevice):
|
|||
"""Initialize the sensor."""
|
||||
from pyqwikswitch.qwikswitch import SENSORS
|
||||
|
||||
super().__init__(sensor['id'], sensor['name'])
|
||||
self.channel = sensor['channel']
|
||||
sensor_type = sensor['type']
|
||||
super().__init__(sensor["id"], sensor["name"])
|
||||
self.channel = sensor["channel"]
|
||||
sensor_type = sensor["type"]
|
||||
|
||||
self._decode, _ = SENSORS[sensor_type]
|
||||
self._invert = not sensor.get('invert', False)
|
||||
self._class = sensor.get('class', 'door')
|
||||
self._invert = not sensor.get("invert", False)
|
||||
self._class = sensor.get("class", "door")
|
||||
|
||||
@callback
|
||||
def update_packet(self, packet):
|
||||
"""Receive update packet from QSUSB."""
|
||||
val = self._decode(packet, channel=self.channel)
|
||||
_LOGGER.debug("Update %s (%s:%s) decoded as %s: %s",
|
||||
self.entity_id, self.qsid, self.channel, val, packet)
|
||||
_LOGGER.debug(
|
||||
"Update %s (%s:%s) decoded as %s: %s",
|
||||
self.entity_id,
|
||||
self.qsid,
|
||||
self.channel,
|
||||
val,
|
||||
packet,
|
||||
)
|
||||
if val is not None:
|
||||
self._val = bool(val)
|
||||
self.async_schedule_update_ha_state()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue