def to_code(config): for hub in get_variable(config[CONF_ADS1115_ID]): yield mux = MUX[config[CONF_MULTIPLEXER]] gain = GAIN[config[CONF_GAIN]] rhs = hub.get_sensor(config[CONF_NAME], mux, gain, config.get(CONF_UPDATE_INTERVAL)) sensor.register_sensor(rhs, config)
def to_code(config): for hub in get_variable(config[CONF_DALLAS_ID]): yield if CONF_ADDRESS in config: address = HexIntLiteral(config[CONF_ADDRESS]) rhs = hub.Pget_sensor_by_address(config[CONF_NAME], address, config.get(CONF_RESOLUTION)) else: rhs = hub.Pget_sensor_by_index(config[CONF_NAME], config[CONF_INDEX], config.get(CONF_RESOLUTION)) sensor.register_sensor(rhs, config)
def to_code(config): for template_ in process_lambda(config[CONF_LAMBDA], [], return_type=std_vector.template( sensor.SensorPtr)): yield rhs = CustomSensorConstructor(template_) custom = variable(config[CONF_ID], rhs) for i, conf in enumerate(config[CONF_SENSORS]): rhs = custom.Pget_sensor(i) add(rhs.set_name(conf[CONF_NAME])) sensor.register_sensor(rhs, conf)
def to_code(config): rhs = App.make_ina3221(config[CONF_ADDRESS], config.get(CONF_UPDATE_INTERVAL)) ina = Pvariable(config[CONF_ID], rhs) for i, channel in enumerate( [CONF_CHANNEL_1, CONF_CHANNEL_2, CONF_CHANNEL_3]): if channel not in config: continue conf = config[channel] if CONF_SHUNT_RESISTANCE in conf: add(ina.set_shunt_resistance(i, conf[CONF_SHUNT_RESISTANCE])) if CONF_BUS_VOLTAGE in conf: c = conf[CONF_BUS_VOLTAGE] sensor.register_sensor( ina.Pmake_bus_voltage_sensor(i, c[CONF_NAME]), c) if CONF_SHUNT_VOLTAGE in conf: c = conf[CONF_SHUNT_VOLTAGE] sensor.register_sensor( ina.Pmake_shunt_voltage_sensor(i, c[CONF_NAME]), c) if CONF_CURRENT in conf: c = conf[CONF_CURRENT] sensor.register_sensor(ina.Pmake_current_sensor(i, c[CONF_NAME]), c) if CONF_POWER in conf: c = conf[CONF_POWER] sensor.register_sensor(ina.Pmake_power_sensor(i, c[CONF_NAME]), c) setup_component(ina, config)
def to_code(config): for uart_ in get_variable(config[CONF_UART_ID]): yield rhs = App.make_mhz19_sensor(uart_, config[CONF_CO2][CONF_NAME], config.get(CONF_UPDATE_INTERVAL)) mhz19 = Pvariable(config[CONF_ID], rhs) sensor.setup_sensor(mhz19.Pget_co2_sensor(), config[CONF_CO2]) if CONF_TEMPERATURE in config: sensor.register_sensor( mhz19.Pmake_temperature_sensor( config[CONF_TEMPERATURE][CONF_NAME]), config[CONF_TEMPERATURE]) setup_component(mhz19, config)
def to_code(config): for hub in get_variable(config[CONF_ESP32_BLE_ID]): yield rhs = hub.make_xiaomi_device(make_address_array(config[CONF_MAC_ADDRESS])) dev = Pvariable(config[CONF_ID], rhs) if CONF_TEMPERATURE in config: conf = config[CONF_TEMPERATURE] sensor.register_sensor(dev.Pmake_temperature_sensor(conf[CONF_NAME]), conf) if CONF_MOISTURE in config: conf = config[CONF_MOISTURE] sensor.register_sensor(dev.Pmake_moisture_sensor(conf[CONF_NAME]), conf) if CONF_ILLUMINANCE in config: conf = config[CONF_ILLUMINANCE] sensor.register_sensor(dev.Pmake_illuminance_sensor(conf[CONF_NAME]), conf) if CONF_CONDUCTIVITY in config: conf = config[CONF_CONDUCTIVITY] sensor.register_sensor(dev.Pmake_conductivity_sensor(conf[CONF_NAME]), conf) if CONF_BATTERY_LEVEL in config: conf = config[CONF_BATTERY_LEVEL] sensor.register_sensor(dev.Pmake_battery_level_sensor(conf[CONF_NAME]), conf)
def to_code(config): for uart_ in get_variable(config[CONF_UART_ID]): yield rhs = App.make_sds011(uart_) sds011 = Pvariable(config[CONF_ID], rhs) if CONF_UPDATE_INTERVAL in config: add(sds011.set_update_interval_min(config.get(CONF_UPDATE_INTERVAL))) if CONF_RX_ONLY in config: add(sds011.set_rx_mode_only(config[CONF_RX_ONLY])) if CONF_PM_2_5 in config: conf = config[CONF_PM_2_5] sensor.register_sensor(sds011.make_pm_2_5_sensor(conf[CONF_NAME]), conf) if CONF_PM_10_0 in config: conf = config[CONF_PM_10_0] sensor.register_sensor(sds011.make_pm_10_0_sensor(conf[CONF_NAME]), conf) setup_component(sds011, config)
def to_code(config): rhs = App.make_ina219(config[CONF_SHUNT_RESISTANCE], config[CONF_MAX_CURRENT], config[CONF_MAX_VOLTAGE], config[CONF_ADDRESS], config.get(CONF_UPDATE_INTERVAL)) ina = Pvariable(config[CONF_ID], rhs) if CONF_BUS_VOLTAGE in config: conf = config[CONF_BUS_VOLTAGE] sensor.register_sensor(ina.Pmake_bus_voltage_sensor(conf[CONF_NAME]), conf) if CONF_SHUNT_VOLTAGE in config: conf = config[CONF_SHUNT_VOLTAGE] sensor.register_sensor(ina.Pmake_shunt_voltage_sensor(conf[CONF_NAME]), conf) if CONF_CURRENT in config: conf = config[CONF_CURRENT] sensor.register_sensor(ina.Pmake_current_sensor(conf[CONF_NAME]), conf) if CONF_POWER in config: conf = config[CONF_POWER] sensor.register_sensor(ina.Pmake_power_sensor(conf[CONF_NAME]), conf) setup_component(ina, config)
def to_code(config): rhs = App.make_hmc5883l(config.get(CONF_UPDATE_INTERVAL)) hmc = Pvariable(config[CONF_ID], rhs) if CONF_ADDRESS in config: add(hmc.set_address(config[CONF_ADDRESS])) if CONF_RANGE in config: add(hmc.set_range(HMC5883L_RANGES[config[CONF_RANGE]])) if CONF_FIELD_STRENGTH_X in config: conf = config[CONF_FIELD_STRENGTH_X] sensor.register_sensor(hmc.Pmake_x_sensor(conf[CONF_NAME]), conf) if CONF_FIELD_STRENGTH_Y in config: conf = config[CONF_FIELD_STRENGTH_Y] sensor.register_sensor(hmc.Pmake_y_sensor(conf[CONF_NAME]), conf) if CONF_FIELD_STRENGTH_Z in config: conf = config[CONF_FIELD_STRENGTH_Z] sensor.register_sensor(hmc.Pmake_z_sensor(conf[CONF_NAME]), conf) if CONF_HEADING in config: conf = config[CONF_HEADING] sensor.register_sensor(hmc.Pmake_heading_sensor(conf[CONF_NAME]), conf) setup_component(hmc, config)
def to_code(config): for hub in get_variable(config[CONF_ESP32_BLE_ID]): yield rhs = hub.make_xiaomi_device(make_address_array(config[CONF_MAC_ADDRESS])) dev = Pvariable(config[CONF_MAKE_ID], rhs) if CONF_TEMPERATURE in config: conf = config[CONF_TEMPERATURE] sensor.register_sensor(dev.Pmake_temperature_sensor(conf[CONF_NAME]), conf) if CONF_HUMIDITY in config: conf = config[CONF_HUMIDITY] sensor.register_sensor(dev.Pmake_humidity_sensor(conf[CONF_NAME]), conf) if CONF_BATTERY_LEVEL in config: conf = config[CONF_BATTERY_LEVEL] sensor.register_sensor(dev.Pmake_battery_level_sensor(conf[CONF_NAME]), conf)
def to_code(config): for uart_ in get_variable(config[CONF_UART_ID]): yield rhs = App.make_cse7766(uart_, config.get(CONF_UPDATE_INTERVAL)) cse = Pvariable(config[CONF_ID], rhs) if CONF_VOLTAGE in config: conf = config[CONF_VOLTAGE] sensor.register_sensor(cse.make_voltage_sensor(conf[CONF_NAME]), conf) if CONF_CURRENT in config: conf = config[CONF_CURRENT] sensor.register_sensor(cse.make_current_sensor(conf[CONF_NAME]), conf) if CONF_POWER in config: conf = config[CONF_POWER] sensor.register_sensor(cse.make_power_sensor(conf[CONF_NAME]), conf) setup_component(cse, config)
def to_code(config): for sel in gpio_output_pin_expression(config[CONF_SEL_PIN]): yield rhs = App.make_hlw8012(sel, config[CONF_CF_PIN], config[CONF_CF1_PIN], config.get(CONF_UPDATE_INTERVAL)) hlw = Pvariable(config[CONF_ID], rhs) if CONF_VOLTAGE in config: conf = config[CONF_VOLTAGE] sensor.register_sensor(hlw.make_voltage_sensor(conf[CONF_NAME]), conf) if CONF_CURRENT in config: conf = config[CONF_CURRENT] sensor.register_sensor(hlw.make_current_sensor(conf[CONF_NAME]), conf) if CONF_POWER in config: conf = config[CONF_POWER] sensor.register_sensor(hlw.make_power_sensor(conf[CONF_NAME]), conf) if CONF_CURRENT_RESISTOR in config: add(hlw.set_current_resistor(config[CONF_CURRENT_RESISTOR])) if CONF_VOLTAGE_DIVIDER in config: add(hlw.set_voltage_divider(config[CONF_VOLTAGE_DIVIDER])) if CONF_CHANGE_MODE_EVERY in config: add(hlw.set_change_mode_every(config[CONF_CHANGE_MODE_EVERY])) setup_component(hlw, config)
def to_code(config): rhs = App.make_mpu6050_sensor(config[CONF_ADDRESS], config.get(CONF_UPDATE_INTERVAL)) mpu = Pvariable(config[CONF_ID], rhs) if CONF_ACCEL_X in config: conf = config[CONF_ACCEL_X] rhs = mpu.Pmake_accel_x_sensor(conf[CONF_NAME]) sensor.register_sensor(rhs, conf) if CONF_ACCEL_Y in config: conf = config[CONF_ACCEL_Y] rhs = mpu.Pmake_accel_y_sensor(conf[CONF_NAME]) sensor.register_sensor(rhs, conf) if CONF_ACCEL_Z in config: conf = config[CONF_ACCEL_Z] rhs = mpu.Pmake_accel_z_sensor(conf[CONF_NAME]) sensor.register_sensor(rhs, conf) if CONF_GYRO_X in config: conf = config[CONF_GYRO_X] rhs = mpu.Pmake_gyro_x_sensor(conf[CONF_NAME]) sensor.register_sensor(rhs, conf) if CONF_GYRO_Y in config: conf = config[CONF_GYRO_Y] rhs = mpu.Pmake_gyro_y_sensor(conf[CONF_NAME]) sensor.register_sensor(rhs, conf) if CONF_GYRO_Z in config: conf = config[CONF_GYRO_Z] rhs = mpu.Pmake_gyro_z_sensor(conf[CONF_NAME]) sensor.register_sensor(rhs, conf) if CONF_TEMPERATURE in config: conf = config[CONF_TEMPERATURE] rhs = mpu.Pmake_temperature_sensor(conf[CONF_NAME]) sensor.register_sensor(rhs, conf) setup_component(mpu, config)
def to_code(config): for hub in get_variable(config[CONF_ESP32_BLE_ID]): yield rhs = hub.make_rssi_sensor(config[CONF_NAME], make_address_array(config[CONF_MAC_ADDRESS])) sensor.register_sensor(rhs, config)
def to_code(config): for uart_ in get_variable(config[CONF_UART_ID]): yield rhs = App.make_pmsx003(uart_, PMSX003_TYPES[config[CONF_TYPE]]) pms = Pvariable(config[CONF_ID], rhs) if CONF_PM_1_0 in config: conf = config[CONF_PM_1_0] sensor.register_sensor(pms.make_pm_1_0_sensor(conf[CONF_NAME]), conf) if CONF_PM_2_5 in config: conf = config[CONF_PM_2_5] sensor.register_sensor(pms.make_pm_2_5_sensor(conf[CONF_NAME]), conf) if CONF_PM_10_0 in config: conf = config[CONF_PM_10_0] sensor.register_sensor(pms.make_pm_10_0_sensor(conf[CONF_NAME]), conf) if CONF_TEMPERATURE in config: conf = config[CONF_TEMPERATURE] sensor.register_sensor(pms.make_temperature_sensor(conf[CONF_NAME]), conf) if CONF_HUMIDITY in config: conf = config[CONF_HUMIDITY] sensor.register_sensor(pms.make_humidity_sensor(conf[CONF_NAME]), conf) if CONF_FORMALDEHYDE in config: conf = config[CONF_FORMALDEHYDE] sensor.register_sensor(pms.make_formaldehyde_sensor(conf[CONF_NAME]), conf) setup_component(pms, config)
def to_code(config): rhs = App.make_tcs34725(config.get(CONF_UPDATE_INTERVAL)) tcs = Pvariable(config[CONF_ID], rhs) if CONF_ADDRESS in config: add(tcs.set_address(config[CONF_ADDRESS])) if CONF_INTEGRATION_TIME in config: add( tcs.set_integration_time( TCS34725_INTEGRATION_TIMES[config[CONF_INTEGRATION_TIME]])) if CONF_GAIN in config: add(tcs.set_gain(TCS34725_GAINS[config[CONF_GAIN]])) if CONF_RED_CHANNEL in config: conf = config[CONF_RED_CHANNEL] sensor.register_sensor(tcs.Pmake_red_sensor(conf[CONF_NAME]), conf) if CONF_GREEN_CHANNEL in config: conf = config[CONF_GREEN_CHANNEL] sensor.register_sensor(tcs.Pmake_green_sensor(conf[CONF_NAME]), conf) if CONF_BLUE_CHANNEL in config: conf = config[CONF_BLUE_CHANNEL] sensor.register_sensor(tcs.Pmake_blue_sensor(conf[CONF_NAME]), conf) if CONF_CLEAR_CHANNEL in config: conf = config[CONF_CLEAR_CHANNEL] sensor.register_sensor(tcs.Pmake_clear_sensor(conf[CONF_NAME]), conf) if CONF_ILLUMINANCE in config: conf = config[CONF_ILLUMINANCE] sensor.register_sensor(tcs.Pmake_illuminance_sensor(conf[CONF_NAME]), conf) if CONF_COLOR_TEMPERATURE in config: conf = config[CONF_COLOR_TEMPERATURE] sensor.register_sensor( tcs.Pmake_color_temperature_sensor(conf[CONF_NAME]), conf) setup_component(tcs, config)
def to_code(config): for hub in get_variable(config[CONF_APDS9960_ID]): yield func = getattr(hub, TYPES[config[CONF_TYPE]]) rhs = func(config[CONF_NAME]) sensor.register_sensor(rhs, config)