Fix broken status update for lighting4 devices (#8543)

* Fix broken status update for lighting4 devices

* Fixed indentation
This commit is contained in:
Yannick POLLART 2017-07-20 07:56:11 +02:00 committed by Paulus Schoutsen
parent fb6bdfaba9
commit 7b10f0a14f
2 changed files with 11 additions and 20 deletions

View file

@ -62,6 +62,7 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
entity[CONF_COMMAND_ON],
entity[CONF_COMMAND_OFF])
device.hass = hass
device.is_lighting4 = (packet_id[2:4] == '13')
sensors.append(device)
rfxtrx.RFX_DEVICES[device_id] = device
@ -94,6 +95,8 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
pkt_id = "".join("{0:02x}".format(x) for x in event.data)
sensor = RfxtrxBinarySensor(event, pkt_id)
sensor.hass = hass
sensor.is_lighting4 = (pkt_id[2:4] == '13')
rfxtrx.RFX_DEVICES[device_id] = sensor
add_devices_callback([sensor])
_LOGGER.info("Added binary sensor %s "
@ -111,12 +114,12 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
slugify(event.device.id_string.lower()),
event.device.__class__.__name__,
event.device.subtype)
if sensor.is_pt2262:
cmd = rfxtrx.get_pt2262_cmd(device_id, sensor.data_bits)
_LOGGER.info("applying cmd %s to device_id: %s)",
cmd, sensor.masked_id)
sensor.apply_cmd(int(cmd, 16))
if sensor.is_lighting4:
if sensor.data_bits is not None:
cmd = rfxtrx.get_pt2262_cmd(device_id, sensor.data_bits)
sensor.apply_cmd(int(cmd, 16))
else:
sensor.update_state(True)
else:
rfxtrx.apply_received_command(event)
@ -170,11 +173,6 @@ class RfxtrxBinarySensor(BinarySensorDevice):
"""Return the device name."""
return self._name
@property
def is_pt2262(self):
"""Return true if the device is PT2262-based."""
return self._data_bits is not None
@property
def masked_id(self):
"""Return the masked device id (isolated address bits)."""

View file

@ -247,10 +247,8 @@ def get_pt2262_device(device_id):
"""Look for the device which id matches the given device_id parameter."""
for dev_id, device in RFX_DEVICES.items():
try:
if (device.is_pt2262 and
device.masked_id == get_pt2262_deviceid(
device_id,
device.data_bits)):
if device.masked_id == get_pt2262_deviceid(device_id,
device.data_bits):
_LOGGER.info("rfxtrx: found matching device %s for %s",
device_id,
get_pt2262_deviceid(device_id, device.data_bits))
@ -414,11 +412,6 @@ class RfxtrxDevice(Entity):
"""Return is the device must fire event."""
return self._should_fire_event
@property
def is_pt2262(self):
"""Return true if the device is PT2262-based."""
return False
@property
def is_on(self):
"""Return true if device is on."""