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): rhs = App.make_mpu6050_sensor(config[CONF_ADDRESS], config.get(CONF_UPDATE_INTERVAL)) mpu = Pvariable('sensor::MPU6050Component', 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_ = Pvariable('sensor::MPU6050AccelSensor', conf[CONF_MQTT_ID], rhs) sensor.register_sensor(sensor_, conf) if CONF_ACCEL_Y in config: conf = config[CONF_ACCEL_Y] rhs = mpu.Pmake_accel_y_sensor(conf[CONF_NAME]) sensor_ = Pvariable('sensor::MPU6050AccelSensor', conf[CONF_MQTT_ID], rhs) sensor.register_sensor(sensor_, conf) if CONF_ACCEL_Z in config: conf = config[CONF_ACCEL_Z] rhs = mpu.Pmake_accel_z_sensor(conf[CONF_NAME]) sensor_ = Pvariable('sensor::MPU6050AccelSensor', conf[CONF_MQTT_ID], rhs) sensor.register_sensor(sensor_, conf) if CONF_GYRO_X in config: conf = config[CONF_GYRO_X] rhs = mpu.Pmake_gyro_x_sensor(conf[CONF_NAME]) sensor_ = Pvariable('sensor::MPU6050GyroSensor', conf[CONF_MQTT_ID], rhs) sensor.register_sensor(sensor_, conf) if CONF_GYRO_Y in config: conf = config[CONF_GYRO_Y] rhs = mpu.Pmake_gyro_y_sensor(conf[CONF_NAME]) sensor_ = Pvariable('sensor::MPU6050GyroSensor', conf[CONF_MQTT_ID], rhs) sensor.register_sensor(sensor_, conf) if CONF_GYRO_Z in config: conf = config[CONF_GYRO_Z] rhs = mpu.Pmake_gyro_z_sensor(conf[CONF_NAME]) sensor_ = Pvariable('sensor::MPU6050GyroSensor', conf[CONF_MQTT_ID], rhs) sensor.register_sensor(sensor_, conf) if CONF_TEMPERATURE in config: conf = config[CONF_TEMPERATURE] rhs = mpu.Pmake_temperature_sensor(conf[CONF_NAME]) sensor_ = Pvariable('sensor::MPU6050TemperatureSensor', conf[CONF_MQTT_ID], rhs) sensor.register_sensor(sensor_, conf)