def light_update(event): """Handle light updates from the RFXtrx gateway.""" if not isinstance(event.device, rfxtrxmod.LightingDevice) or \ not event.device.known_to_be_dimmable: return new_device = rfxtrx.get_new_device(event, config, RfxtrxLight) if new_device: add_entities([new_device]) rfxtrx.apply_received_command(event)
def switch_update(event): """Callback for sensor updates from the RFXtrx gateway.""" if not isinstance(event.device, rfxtrxmod.LightingDevice) or \ event.device.known_to_be_dimmable: return new_device = rfxtrx.get_new_device(event, config, RfxtrxSwitch) if new_device: add_devices_callback([new_device]) rfxtrx.apply_received_command(event)
def cover_update(event): """Handle cover updates from the RFXtrx gateway.""" if not isinstance(event.device, rfxtrxmod.LightingDevice) or \ event.device.known_to_be_dimmable or \ not event.device.known_to_be_rollershutter: return new_device = rfxtrx.get_new_device(event, config, RfxtrxCover) if new_device: add_entities([new_device]) rfxtrx.apply_received_command(event)
def rollershutter_update(event): """Callback for roller shutter updates from the RFXtrx gateway.""" if not isinstance(event.device, rfxtrxmod.LightingDevice) or \ event.device.known_to_be_dimmable or \ not event.device.known_to_be_rollershutter: return new_device = rfxtrx.get_new_device(event, config, RfxtrxRollershutter) if new_device: add_devices_callback([new_device]) rfxtrx.apply_received_command(event)
def switch_update(event): """Handle sensor updates from the RFXtrx gateway.""" if (not isinstance(event.device, rfxtrxmod.LightingDevice) or event.device.known_to_be_dimmable or event.device.known_to_be_rollershutter): return new_device = rfxtrx.get_new_device(event, config, RfxtrxSwitch) if new_device: add_entities_callback([new_device]) rfxtrx.apply_received_command(event)
def binary_sensor_update(event): """Call for control updates from the RFXtrx gateway.""" if not isinstance(event, rfxtrxmod.ControlEvent): return device_id = slugify(event.device.id_string.lower()) if device_id in rfxtrx.RFX_DEVICES: sensor = rfxtrx.RFX_DEVICES[device_id] else: sensor = rfxtrx.get_pt2262_device(device_id) if sensor is None: # Add the entity if not exists and automatic_add is True if not config[CONF_AUTOMATIC_ADD]: return if event.device.packettype == 0x13: poss_dev = rfxtrx.find_possible_pt2262_device(device_id) if poss_dev is not None: poss_id = slugify(poss_dev.event.device.id_string.lower()) _LOGGER.debug( "Found possible matching device ID: %s", poss_id) pkt_id = "".join("{0:02x}".format(x) for x in event.data) sensor = RfxtrxBinarySensor(event, pkt_id) sensor.hass = hass rfxtrx.RFX_DEVICES[device_id] = sensor add_devices([sensor]) _LOGGER.info( "Added binary sensor %s (Device ID: %s Class: %s Sub: %s)", pkt_id, slugify(event.device.id_string.lower()), event.device.__class__.__name__, event.device.subtype) elif not isinstance(sensor, RfxtrxBinarySensor): return else: _LOGGER.debug( "Binary sensor update (Device ID: %s Class: %s Sub: %s)", slugify(event.device.id_string.lower()), event.device.__class__.__name__, event.device.subtype) 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) if (sensor.is_on and sensor.off_delay is not None and sensor.delay_listener is None): def off_delay_listener(now): """Switch device off after a delay.""" sensor.delay_listener = None sensor.update_state(False) sensor.delay_listener = evt.track_point_in_time( hass, off_delay_listener, dt_util.utcnow() + sensor.off_delay)