def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) yield cg.register_component(var, config) yield uart.register_uart_device(var, config) cg.add(var.set_type(config[CONF_TYPE])) if CONF_PM_1_0 in config: sens = yield sensor.new_sensor(config[CONF_PM_1_0]) cg.add(var.set_pm_1_0_sensor(sens)) if CONF_PM_2_5 in config: sens = yield sensor.new_sensor(config[CONF_PM_2_5]) cg.add(var.set_pm_2_5_sensor(sens)) if CONF_PM_10_0 in config: sens = yield sensor.new_sensor(config[CONF_PM_10_0]) cg.add(var.set_pm_10_0_sensor(sens)) if CONF_TEMPERATURE in config: sens = yield sensor.new_sensor(config[CONF_TEMPERATURE]) cg.add(var.set_temperature_sensor(sens)) if CONF_HUMIDITY in config: sens = yield sensor.new_sensor(config[CONF_HUMIDITY]) cg.add(var.set_humidity_sensor(sens)) if CONF_FORMALDEHYDE in config: sens = yield sensor.new_sensor(config[CONF_FORMALDEHYDE]) cg.add(var.set_formaldehyde_sensor(sens))
def to_code(config): sender = yield cg.get_variable(config[CONF_GCODE_SENDER]) queue = yield cg.get_variable(config[CONF_GCODE_QUEUE]) var = cg.new_Pvariable(config[CONF_ID], sender, queue) yield cg.register_component(var, config) yield uart.register_uart_device(var, config)
def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) if CONF_PORT in config: cg.add(var.set_port(config[CONF_PORT])) yield cg.register_component(var, config) yield uart.register_uart_device(var, config)
def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) yield cg.register_component(var, config) yield uart.register_uart_device(var, config) # https://platformio.org/lib/show/1655/TinyGPSPlus cg.add_library('TinyGPSPlus', '1.0.2')
def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) yield cg.register_component(var, config) yield uart.register_uart_device(var, config) if CONF_LATITUDE in config: sens = yield sensor.new_sensor(config[CONF_LATITUDE]) cg.add(var.set_latitude_sensor(sens)) if CONF_LONGITUDE in config: sens = yield sensor.new_sensor(config[CONF_LONGITUDE]) cg.add(var.set_longitude_sensor(sens)) if CONF_SPEED in config: sens = yield sensor.new_sensor(config[CONF_SPEED]) cg.add(var.set_speed_sensor(sens)) if CONF_COURSE in config: sens = yield sensor.new_sensor(config[CONF_COURSE]) cg.add(var.set_course_sensor(sens)) if CONF_ALTITUDE in config: sens = yield sensor.new_sensor(config[CONF_ALTITUDE]) cg.add(var.set_altitude_sensor(sens)) if CONF_SATELLITES in config: sens = yield sensor.new_sensor(config[CONF_SATELLITES]) cg.add(var.set_satellites_sensor(sens)) # https://platformio.org/lib/show/1655/TinyGPSPlus cg.add_library("1655", "1.0.2") # TinyGPSPlus, has name conflict
def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) yield cg.register_component(var, config) yield uart.register_uart_device(var, config) if CONF_CO2 in config: sens = yield sensor.new_sensor(config[CONF_CO2]) cg.add(var.set_co2_sensor(sens))
def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) yield cg.register_component(var, config) yield uart.register_uart_device(var, config) for conf in config.get(CONF_ON_FINISHED_PLAYBACK, []): trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], var) yield automation.build_automation(trigger, [], conf)
def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) yield cg.register_component(var, config) cg.add(var.set_port(config[CONF_PORT])) cg.add(var.set_multi_client(config[CONF_MULTI_CLIENT])) yield uart.register_uart_device(var, config)
def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) yield cg.register_component(var, config) yield uart.register_uart_device(var, config) for conf in config.get(CONF_ON_CODE_RECEIVED, []): trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], var) yield automation.build_automation(trigger, [(RFBridgeData, 'data')], conf)
def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) yield cg.register_component(var, config) yield uart.register_uart_device(var, config) for conf in config.get(CONF_ON_TAG, []): trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID]) cg.add(var.register_trigger(trigger)) yield automation.build_automation(trigger, [(cg.uint32, "x")], conf)
def to_code(config): queue = yield cg.get_variable(config[CONF_GCODE_QUEUE]) var = cg.new_Pvariable(config[CONF_ID], queue) yield cg.register_component(var, config) yield uart.register_uart_device(var, config) if CONF_RESEND_BUFFER_SIZE in config: cg.add(var.setResendBufferSize(config[CONF_RESEND_BUFFER_SIZE]))
def to_code(config): var = cg.new_Pvariable(config[CONF_ID], config[CONF_HISTORICAL_MODE]) yield cg.register_component(var, config) yield uart.register_uart_device(var, config) if CONF_TAGS in config: for tag in config[CONF_TAGS]: sens = yield sensor.new_sensor(tag[CONF_SENSOR]) cg.add(var.register_teleinfo_sensor(tag[CONF_TAG_NAME], sens))
def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) yield cg.register_component(var, config) yield uart.register_uart_device(var, config) if CONF_TIME_ID in config: time_ = yield cg.get_variable(config[CONF_TIME_ID]) cg.add(var.set_time_id(time_)) if CONF_IGNORE_MCU_UPDATE_ON_DATAPOINTS in config: for dp in config[CONF_IGNORE_MCU_UPDATE_ON_DATAPOINTS]: cg.add(var.add_ignore_mcu_update_on_datapoints(dp))
def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) yield cg.register_component(var, config) yield uart.register_uart_device(var, config) for conf in config.get(CONF_ON_SMS_RECEIVED, []): trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], var) yield automation.build_automation(trigger, [(cg.std_string, "message"), (cg.std_string, "sender")], conf)
def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) yield cg.register_component(var, config) yield switch.register_switch(var, config) yield uart.register_uart_device(var, config) data = config[CONF_DATA] if isinstance(data, bytes): data = [HexInt(x) for x in data] cg.add(var.set_data(data))
def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) if CONF_PORT in config: cg.add(var.set_port(config[CONF_PORT])) if CONF_MAX_CLIENTS in config: cg.add(var.set_max_clients(config[CONF_MAX_CLIENTS])) if CONF_HELLO_MESSAGE in config: cg.add(var.set_hello_message(config[CONF_HELLO_MESSAGE])) yield cg.register_component(var, config) yield uart.register_uart_device(var, config)
def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) yield cg.register_component(var, config) yield uart.register_uart_device(var, config) if CONF_LAMBDA in config: lambda_ = yield cg.process_lambda(config[CONF_LAMBDA], [(NextionRef, 'it')], return_type=cg.void) cg.add(var.set_writer(lambda_)) yield display.register_display(var, config)
def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) yield cg.register_component(var, config) yield uart.register_uart_device(var, config) if CONF_CO2 in config: sens = yield sensor.new_sensor(config[CONF_CO2]) cg.add(var.set_co2_sensor(sens)) if CONF_TEMPERATURE in config: sens = yield sensor.new_sensor(config[CONF_TEMPERATURE]) cg.add(var.set_temperature_sensor(sens)) if CONF_AUTOMATIC_BASELINE_CALIBRATION in config: cg.add(var.set_abc_enabled(config[CONF_AUTOMATIC_BASELINE_CALIBRATION]))
def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) yield cg.register_component(var, config) yield uart.register_uart_device(var, config) if CONF_CHARGE_MODE in config: sens = yield sensor.new_sensor(config[CONF_CHARGE_MODE]) cg.add(var.set_charge_mode_sensor(sens)) if CONF_INPUT_VOLTAGE in config: sens = yield sensor.new_sensor(config[CONF_INPUT_VOLTAGE]) cg.add(var.set_input_voltage_sensor(sens)) if CONF_BATTERY_VOLTAGE in config: sens = yield sensor.new_sensor(config[CONF_BATTERY_VOLTAGE]) cg.add(var.set_battery_voltage_sensor(sens)) if CONF_CHARGING_CURRENT in config: sens = yield sensor.new_sensor(config[CONF_CHARGING_CURRENT]) cg.add(var.set_charging_current_sensor(sens)) if CONF_LOAD_VOLTAGE in config: sens = yield sensor.new_sensor(config[CONF_LOAD_VOLTAGE]) cg.add(var.set_load_voltage_sensor(sens)) if CONF_LOAD_CURRENT in config: sens = yield sensor.new_sensor(config[CONF_LOAD_CURRENT]) cg.add(var.set_load_current_sensor(sens)) if CONF_CHARGING_POWER in config: sens = yield sensor.new_sensor(config[CONF_CHARGING_POWER]) cg.add(var.set_charging_power_sensor(sens)) if CONF_LOAD_POWER in config: sens = yield sensor.new_sensor(config[CONF_LOAD_POWER]) cg.add(var.set_load_power_sensor(sens)) if CONF_BATTERY_TEMP in config: sens = yield sensor.new_sensor(config[CONF_BATTERY_TEMP]) cg.add(var.set_battery_temp_sensor(sens)) if CONF_INTERNAL_TEMP in config: sens = yield sensor.new_sensor(config[CONF_INTERNAL_TEMP]) cg.add(var.set_internal_temp_sensor(sens)) if CONF_BATTERY_LEVEL in config: sens = yield sensor.new_sensor(config[CONF_BATTERY_LEVEL]) cg.add(var.set_battery_level_sensor(sens))
def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) yield cg.register_component(var, config) yield uart.register_uart_device(var, config) if CONF_UPDATE_INTERVAL in config: cg.add(var.set_update_interval_min(config[CONF_UPDATE_INTERVAL])) cg.add(var.set_rx_mode_only(config[CONF_RX_ONLY])) if CONF_PM_2_5 in config: sens = yield sensor.new_sensor(config[CONF_PM_2_5]) cg.add(var.set_pm_2_5_sensor(sens)) if CONF_PM_10_0 in config: sens = yield sensor.new_sensor(config[CONF_PM_10_0]) cg.add(var.set_pm_10_0_sensor(sens))
def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) yield cg.register_component(var, config) yield uart.register_uart_device(var, config) if CONF_VOLTAGE in config: conf = config[CONF_VOLTAGE] sens = yield sensor.new_sensor(conf) cg.add(var.set_voltage_sensor(sens)) if CONF_CURRENT in config: conf = config[CONF_CURRENT] sens = yield sensor.new_sensor(conf) cg.add(var.set_current_sensor(sens)) if CONF_POWER in config: conf = config[CONF_POWER] sens = yield sensor.new_sensor(conf) cg.add(var.set_power_sensor(sens))
def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) yield cg.register_component(var, config) if CONF_PASSWORD in config: password = config[CONF_PASSWORD] cg.add(var.set_password(password)) yield uart.register_uart_device(var, config) if CONF_NEW_PASSWORD in config: new_password = config[CONF_NEW_PASSWORD] cg.add(var.set_new_password(new_password)) if CONF_SENSING_PIN in config: sensing_pin = yield cg.gpio_pin_expression(config[CONF_SENSING_PIN]) cg.add(var.set_sensing_pin(sensing_pin)) for conf in config.get(CONF_ON_FINGER_SCAN_MATCHED, []): trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], var) yield automation.build_automation(trigger, [(cg.uint16, "finger_id"), (cg.uint16, "confidence")], conf) for conf in config.get(CONF_ON_FINGER_SCAN_UNMATCHED, []): trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], var) yield automation.build_automation(trigger, [], conf) for conf in config.get(CONF_ON_ENROLLMENT_SCAN, []): trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], var) yield automation.build_automation(trigger, [(cg.uint8, "scan_num"), (cg.uint16, "finger_id")], conf) for conf in config.get(CONF_ON_ENROLLMENT_DONE, []): trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], var) yield automation.build_automation(trigger, [(cg.uint16, "finger_id")], conf) for conf in config.get(CONF_ON_ENROLLMENT_FAILED, []): trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], var) yield automation.build_automation(trigger, [(cg.uint16, "finger_id")], conf)
def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) yield cg.register_component(var, config) yield uart.register_uart_device(var, config) if CONF_PM_1_0 in config: sens = yield sensor.new_sensor(config[CONF_PM_1_0]) cg.add(var.set_pm_1_0_sensor(sens)) if CONF_PM_2_5 in config: sens = yield sensor.new_sensor(config[CONF_PM_2_5]) cg.add(var.set_pm_2_5_sensor(sens)) if CONF_PM_10_0 in config: sens = yield sensor.new_sensor(config[CONF_PM_10_0]) cg.add(var.set_pm_10_0_sensor(sens)) if CONF_PMC_0_3 in config: sens = yield sensor.new_sensor(config[CONF_PMC_0_3]) cg.add(var.set_pmc_0_3_sensor(sens)) if CONF_PMC_0_5 in config: sens = yield sensor.new_sensor(config[CONF_PMC_0_5]) cg.add(var.set_pmc_0_5_sensor(sens)) if CONF_PMC_1_0 in config: sens = yield sensor.new_sensor(config[CONF_PMC_1_0]) cg.add(var.set_pmc_1_0_sensor(sens)) if CONF_PMC_2_5 in config: sens = yield sensor.new_sensor(config[CONF_PMC_2_5]) cg.add(var.set_pmc_2_5_sensor(sens)) if CONF_PMC_5_0 in config: sens = yield sensor.new_sensor(config[CONF_PMC_5_0]) cg.add(var.set_pmc_5_0_sensor(sens)) if CONF_PMC_10_0 in config: sens = yield sensor.new_sensor(config[CONF_PMC_10_0]) cg.add(var.set_pmc_10_0_sensor(sens))
def to_code(config): fw_hex = get_firmware(config[CONF_FIRMWARE]) fw_major, fw_minor = parse_firmware_version( config[CONF_FIRMWARE][CONF_VERSION]) if fw_hex is not None: cg.add_define("USE_SHD_FIRMWARE_DATA", fw_hex) cg.add_define("USE_SHD_FIRMWARE_MAJOR_VERSION", fw_major) cg.add_define("USE_SHD_FIRMWARE_MINOR_VERSION", fw_minor) var = cg.new_Pvariable(config[CONF_OUTPUT_ID]) yield cg.register_component(var, config) config.pop( CONF_UPDATE_INTERVAL ) # drop UPDATE_INTERVAL as it does not apply to the light component yield light.register_light(var, config) yield uart.register_uart_device(var, config) nrst_pin = yield cg.gpio_pin_expression(config[CONF_NRST_PIN]) cg.add(var.set_nrst_pin(nrst_pin)) boot0_pin = yield cg.gpio_pin_expression(config[CONF_BOOT0_PIN]) cg.add(var.set_boot0_pin(boot0_pin)) cg.add(var.set_leading_edge(config[CONF_LEADING_EDGE])) cg.add(var.set_warmup_brightness(config[CONF_WARMUP_BRIGHTNESS])) # cg.add(var.set_warmup_time(config[CONF_WARMUP_TIME])) cg.add(var.set_min_brightness(config[CONF_MIN_BRIGHTNESS])) cg.add(var.set_max_brightness(config[CONF_MAX_BRIGHTNESS])) for key in [CONF_POWER, CONF_VOLTAGE, CONF_CURRENT]: if key not in config: continue conf = config[key] sens = yield sensor.new_sensor(conf) cg.add(getattr(var, f"set_{key}_sensor")(sens))
def adalight_light_effect_to_code(config, effect_id): effect = cg.new_Pvariable(effect_id, config[CONF_NAME]) yield uart.register_uart_device(effect, config) yield effect
def to_code(config): var = cg.new_Pvariable(config[CONF_ID], config[CONF_HISTORICAL_MODE]) yield cg.register_component(var, config) yield uart.register_uart_device(var, config)
def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) yield cg.register_component(var, config) yield uart.register_uart_device(var, config) cg.add(var.use_strength_icon(config[CONF_STRENGTH_ICON]))
def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) yield cg.register_component(var, config) yield sensor.register_sensor(var, config) yield uart.register_uart_device(var, config)
def to_code(config): cg.add_global(modbus_ns.using) var = cg.new_Pvariable(config[CONF_ID]) yield cg.register_component(var, config) yield uart.register_uart_device(var, config)
def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) yield cg.register_component(var, config) yield uart.register_uart_device(var, config) cg.add_library('TinyGPSPlus', '1.0.2')