def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) yield cg.register_component(var, config) yield modbus.register_modbus_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)) if CONF_ENERGY in config: conf = config[CONF_ENERGY] sens = yield sensor.new_sensor(conf) cg.add(var.set_energy_sensor(sens)) if CONF_FREQUENCY in config: conf = config[CONF_FREQUENCY] sens = yield sensor.new_sensor(conf) cg.add(var.set_frequency_sensor(sens)) if CONF_POWER_FACTOR in config: conf = config[CONF_POWER_FACTOR] sens = yield sensor.new_sensor(conf) cg.add(var.set_power_factor_sensor(sens))
def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) yield cg.register_component(var, config) yield modbus.register_modbus_device(var, config) if CONF_PH in config: conf = config[CONF_PH] sens = yield sensor.new_sensor(conf) cg.add(var.set_ph_sensor(sens)) if CONF_TEMPERATURE in config: conf = config[CONF_TEMPERATURE] sens = yield sensor.new_sensor(conf) cg.add(var.set_temperature_sensor(sens)) if CONF_DIS1 in config: conf = config[CONF_DIS1] sens = yield sensor.new_sensor(conf) cg.add(var.set_dis1_sensor(sens)) if CONF_DIS2 in config: conf = config[CONF_DIS2] sens = yield sensor.new_sensor(conf) cg.add(var.set_dis2_sensor(sens)) if CONF_REDOX in config: conf = config[CONF_REDOX] sens = yield sensor.new_sensor(conf) cg.add(var.set_redox_sensor(sens)) if CONF_EC in config: conf = config[CONF_EC] sens = yield sensor.new_sensor(conf) cg.add(var.set_ec_sensor(sens)) if CONF_OCI in config: conf = config[CONF_OCI] sens = yield sensor.new_sensor(conf) cg.add(var.set_oci_sensor(sens))
def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) yield cg.register_component(var, config) yield modbus.register_modbus_device(var, config) if CONF_ADDRESS in config: cg.add(var.set_address(config[CONF_ADDRESS])) if CONF_UPDATE_INTERVAL in config: cg.add(var.set_update_interval(config[CONF_UPDATE_INTERVAL]))
def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) yield cg.register_component(var, config) yield modbus.register_modbus_device(var, config) if CONF_TEMPERATURE in config: conf = config[CONF_TEMPERATURE] sens = yield sensor.new_sensor(conf) cg.add(var.set_temperature_sensor(sens)) if CONF_HUMIDITY in config: conf = config[CONF_HUMIDITY] sens = yield sensor.new_sensor(conf) cg.add(var.set_humidity_sensor(sens))
def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) yield cg.register_component(var, config) yield modbus.register_modbus_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) yield modbus.register_modbus_device(var, config) if CONF_INPUT_POWER_HIGH in config: conf = config[CONF_INPUT_POWER_HIGH] sens = yield sensor.new_sensor(conf) cg.add(var.set_input_power_high_sensor(sens)) if CONF_INPUT_POWER_LOW in config: conf = config[CONF_INPUT_POWER_LOW] sens = yield sensor.new_sensor(conf) cg.add(var.set_input_power_low_sensor(sens)) if CONF_PV1_VOLTAGE in config: conf = config[CONF_PV1_VOLTAGE] sens = yield sensor.new_sensor(conf) cg.add(var.set_pv1_voltage_sensor(sens)) if CONF_PV1_CURRENT in config: conf = config[CONF_PV1_CURRENT] sens = yield sensor.new_sensor(conf) cg.add(var.set_pv1_current_sensor(sens)) if CONF_PV1_POWER_HIGH in config: conf = config[CONF_PV1_POWER_HIGH] sens = yield sensor.new_sensor(conf) cg.add(var.set_pv1_power_high_sensor(sens)) if CONF_PV1_POWER_LOW in config: conf = config[CONF_PV1_POWER_LOW] sens = yield sensor.new_sensor(conf) cg.add(var.set_pv1_power_low_sensor(sens)) if CONF_PV2_VOLTAGE in config: conf = config[CONF_PV2_VOLTAGE] sens = yield sensor.new_sensor(conf) cg.add(var.set_pv2_voltage_sensor(sens)) if CONF_PV2_CURRENT in config: conf = config[CONF_PV2_CURRENT] sens = yield sensor.new_sensor(conf) cg.add(var.set_pv2_current_sensor(sens)) if CONF_PV2_POWER_HIGH in config: conf = config[CONF_PV2_POWER_HIGH] sens = yield sensor.new_sensor(conf) cg.add(var.set_pv2_power_high_sensor(sens)) if CONF_PV2_POWER_LOW in config: conf = config[CONF_PV2_POWER_LOW] sens = yield sensor.new_sensor(conf) cg.add(var.set_pv2_power_low_sensor(sens)) if CONF_OUTPUT_POWER_HIGH in config: conf = config[CONF_OUTPUT_POWER_HIGH] sens = yield sensor.new_sensor(conf) cg.add(var.set_output_power_high_sensor(sens)) if CONF_OUTPUT_POWER_LOW in config: conf = config[CONF_OUTPUT_POWER_LOW] sens = yield sensor.new_sensor(conf) cg.add(var.set_output_power_low_sensor(sens)) if CONF_GRID_FREQUENCY in config: conf = config[CONF_GRID_FREQUENCY] sens = yield sensor.new_sensor(conf) cg.add(var.set_grid_frequency_sensor(sens)) if CONF_AC_VOLTAGE in config: conf = config[CONF_AC_VOLTAGE] sens = yield sensor.new_sensor(conf) cg.add(var.set_ac_voltage_sensor(sens)) if CONF_AC_CURRENT in config: conf = config[CONF_AC_CURRENT] sens = yield sensor.new_sensor(conf) cg.add(var.set_ac_current_sensor(sens)) if CONF_AC_POWER_HIGH in config: conf = config[CONF_AC_POWER_HIGH] sens = yield sensor.new_sensor(conf) cg.add(var.set_ac_power_high_sensor(sens)) if CONF_AC_POWER_LOW in config: conf = config[CONF_AC_POWER_LOW] sens = yield sensor.new_sensor(conf) cg.add(var.set_ac_power_low_sensor(sens)) if CONF_TEMPERATURE in config: conf = config[CONF_TEMPERATURE] sens = yield sensor.new_sensor(conf) cg.add(var.set_temperature_sensor(sens))
def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) yield cg.register_component(var, config) yield modbus.register_modbus_device(var, config) pin = yield cg.gpio_pin_expression(config[CONF_RW_PIN]) cg.add(var.set_rw_pin(pin))