def to_code(config):
    var = cg.new_Pvariable(config[CONF_ID])
    yield cg.register_component(var, config)
    yield esp32_ble_tracker.register_ble_device(var, config)

    cg.add(var.set_address(config[CONF_MAC_ADDRESS].as_hex))
    cg.add(var.set_bindkey(config[CONF_BINDKEY]))

    if CONF_LIGHT in config:
        sens = yield binary_sensor.new_binary_sensor(config[CONF_LIGHT])
        cg.add(var.set_light(sens))
    if CONF_OPEN in config:
        sens = yield binary_sensor.new_binary_sensor(config[CONF_OPEN])
        cg.add(var.set_open(sens))
    if CONF_BATTERY_LEVEL in config:
        sens = yield sensor.new_sensor(config[CONF_BATTERY_LEVEL])
        cg.add(var.set_battery_level(sens))
def to_code(config):
    hub = yield cg.get_variable(config[CONF_APDS9960_ID])
    var = yield binary_sensor.new_binary_sensor(config)
    func = getattr(hub, DIRECTIONS[config[CONF_DIRECTION]])
    cg.add(func(var))
Example #3
0
def to_code(config):
    hub = yield cg.get_variable(config[CONF_AS3935_ID])
    var = yield binary_sensor.new_binary_sensor(config)
    cg.add(hub.set_thunder_alert_binary_sensor(var))
def to_code(config):
    hub = yield cg.get_variable(config[CONF_FINGERPRINT_GROW_ID])
    var = yield binary_sensor.new_binary_sensor(config)
    cg.add(hub.set_enrolling_binary_sensor(var))