mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-31 07:03:55 +00:00 
			
		
		
		
	add_job
This commit is contained in:
		| @@ -5,7 +5,8 @@ from esphomeyaml import automation | ||||
| from esphomeyaml.const import CONF_DEVICE_CLASS, CONF_ID, CONF_INVERTED, CONF_MAX_LENGTH, \ | ||||
|     CONF_MIN_LENGTH, CONF_MQTT_ID, CONF_ON_CLICK, CONF_ON_DOUBLE_CLICK, CONF_ON_PRESS, \ | ||||
|     CONF_ON_RELEASE, CONF_TRIGGER_ID | ||||
| from esphomeyaml.helpers import App, NoArg, Pvariable, add, esphomelib_ns, setup_mqtt_component | ||||
| from esphomeyaml.helpers import App, NoArg, Pvariable, add, esphomelib_ns, setup_mqtt_component, \ | ||||
|     add_job | ||||
|  | ||||
| DEVICE_CLASSES = [ | ||||
|     '', 'battery', 'cold', 'connectivity', 'door', 'garage_door', 'gas', | ||||
| @@ -60,27 +61,23 @@ def setup_binary_sensor_core_(binary_sensor_var, mqtt_var, config): | ||||
|     for conf in config.get(CONF_ON_PRESS, []): | ||||
|         rhs = binary_sensor_var.make_press_trigger() | ||||
|         trigger = Pvariable(conf[CONF_TRIGGER_ID], rhs) | ||||
|         for _ in automation.build_automation(trigger, NoArg, conf): | ||||
|             yield | ||||
|         automation.build_automation(trigger, NoArg, conf) | ||||
|  | ||||
|     for conf in config.get(CONF_ON_RELEASE, []): | ||||
|         rhs = binary_sensor_var.make_release_trigger() | ||||
|         trigger = Pvariable(conf[CONF_TRIGGER_ID], rhs) | ||||
|         for _ in automation.build_automation(trigger, NoArg, conf): | ||||
|             yield | ||||
|         automation.build_automation(trigger, NoArg, conf) | ||||
|  | ||||
|     for conf in config.get(CONF_ON_CLICK, []): | ||||
|         rhs = binary_sensor_var.make_click_trigger(conf[CONF_MIN_LENGTH], conf[CONF_MAX_LENGTH]) | ||||
|         trigger = Pvariable(conf[CONF_TRIGGER_ID], rhs) | ||||
|         for _ in automation.build_automation(trigger, NoArg, conf): | ||||
|             yield | ||||
|         automation.build_automation(trigger, NoArg, conf) | ||||
|  | ||||
|     for conf in config.get(CONF_ON_DOUBLE_CLICK, []): | ||||
|         rhs = binary_sensor_var.make_double_click_trigger(conf[CONF_MIN_LENGTH], | ||||
|                                                           conf[CONF_MAX_LENGTH]) | ||||
|         trigger = Pvariable(conf[CONF_TRIGGER_ID], rhs) | ||||
|         for _ in automation.build_automation(trigger, NoArg, conf): | ||||
|             yield | ||||
|         automation.build_automation(trigger, NoArg, conf) | ||||
|  | ||||
|     setup_mqtt_component(mqtt_var, config) | ||||
|  | ||||
| @@ -90,16 +87,14 @@ def setup_binary_sensor(binary_sensor_obj, mqtt_obj, config): | ||||
|                                   has_side_effects=False) | ||||
|     mqtt_var = Pvariable(config[CONF_MQTT_ID], mqtt_obj, | ||||
|                          has_side_effects=False) | ||||
|     for _ in setup_binary_sensor_core_(binary_sensor_var, mqtt_var, config): | ||||
|         yield | ||||
|     add_job(setup_binary_sensor_core_, binary_sensor_var, mqtt_var, config) | ||||
|  | ||||
|  | ||||
| def register_binary_sensor(var, config): | ||||
|     binary_sensor_var = Pvariable(config[CONF_ID], var, has_side_effects=True) | ||||
|     rhs = App.register_binary_sensor(binary_sensor_var) | ||||
|     mqtt_var = Pvariable(config[CONF_MQTT_ID], rhs, has_side_effects=True) | ||||
|     for _ in setup_binary_sensor_core_(binary_sensor_var, mqtt_var, config): | ||||
|         yield | ||||
|     add_job(setup_binary_sensor_core_, binary_sensor_var, mqtt_var, config) | ||||
|  | ||||
|  | ||||
| BUILD_FLAGS = '-DUSE_BINARY_SENSOR' | ||||
|   | ||||
| @@ -42,8 +42,7 @@ def to_code(config): | ||||
|         yield | ||||
|     addr = [HexInt(i) for i in config[CONF_MAC_ADDRESS].parts] | ||||
|     rhs = hub.make_device(config[CONF_NAME], ArrayInitializer(*addr, multiline=False)) | ||||
|     for _ in binary_sensor.register_binary_sensor(rhs, config): | ||||
|         yield | ||||
|     binary_sensor.register_binary_sensor(rhs, config) | ||||
|  | ||||
|  | ||||
| BUILD_FLAGS = '-DUSE_ESP32_BLE_TRACKER' | ||||
|   | ||||
| @@ -47,8 +47,7 @@ def to_code(config): | ||||
|         yield | ||||
|     touch_pad = TOUCH_PADS[config[CONF_PIN]] | ||||
|     rhs = hub.make_touch_pad(config[CONF_NAME], touch_pad, config[CONF_THRESHOLD]) | ||||
|     for _ in binary_sensor.register_binary_sensor(rhs, config): | ||||
|         yield | ||||
|     binary_sensor.register_binary_sensor(rhs, config) | ||||
|  | ||||
|  | ||||
| BUILD_FLAGS = '-DUSE_ESP32_TOUCH_BINARY_SENSOR' | ||||
|   | ||||
| @@ -20,8 +20,7 @@ def to_code(config): | ||||
|         yield | ||||
|     rhs = App.make_gpio_binary_sensor(config[CONF_NAME], pin) | ||||
|     gpio = variable(config[CONF_MAKE_ID], rhs) | ||||
|     for _ in binary_sensor.setup_binary_sensor(gpio.Pgpio, gpio.Pmqtt, config): | ||||
|         yield | ||||
|     binary_sensor.setup_binary_sensor(gpio.Pgpio, gpio.Pmqtt, config) | ||||
|  | ||||
|  | ||||
| BUILD_FLAGS = '-DUSE_GPIO_BINARY_SENSOR' | ||||
|   | ||||
| @@ -15,8 +15,7 @@ PLATFORM_SCHEMA = binary_sensor.PLATFORM_SCHEMA.extend({ | ||||
| def to_code(config): | ||||
|     rhs = App.make_status_binary_sensor(config[CONF_NAME]) | ||||
|     status = variable(config[CONF_MAKE_ID], rhs) | ||||
|     for _ in binary_sensor.setup_binary_sensor(status.Pstatus, status.Pmqtt, config): | ||||
|         yield | ||||
|     binary_sensor.setup_binary_sensor(status.Pstatus, status.Pmqtt, config) | ||||
|  | ||||
|  | ||||
| BUILD_FLAGS = '-DUSE_STATUS_BINARY_SENSOR' | ||||
|   | ||||
| @@ -19,8 +19,7 @@ def to_code(config): | ||||
|         yield | ||||
|     rhs = App.make_template_binary_sensor(config[CONF_NAME], template_) | ||||
|     make = variable(config[CONF_MAKE_ID], rhs) | ||||
|     for _ in binary_sensor.setup_binary_sensor(make.Ptemplate_, make.Pmqtt, config): | ||||
|         yield | ||||
|     binary_sensor.setup_binary_sensor(make.Ptemplate_, make.Pmqtt, config) | ||||
|  | ||||
|  | ||||
| BUILD_FLAGS = '-DUSE_TEMPLATE_BINARY_SENSOR' | ||||
|   | ||||
| @@ -134,8 +134,7 @@ def to_code(config): | ||||
|     for conf in config.get(CONF_ON_MESSAGE, []): | ||||
|         rhs = mqtt.make_message_trigger(conf[CONF_TOPIC], conf[CONF_QOS]) | ||||
|         trigger = Pvariable(conf[CONF_TRIGGER_ID], rhs) | ||||
|         for _ in automation.build_automation(trigger, std_string, conf): | ||||
|             yield | ||||
|         automation.build_automation(trigger, std_string, conf) | ||||
|  | ||||
|  | ||||
| def required_build_flags(config): | ||||
|   | ||||
| @@ -9,7 +9,7 @@ from esphomeyaml.const import CONF_ABOVE, CONF_ACCURACY_DECIMALS, CONF_ALPHA, CO | ||||
|     CONF_ON_VALUE_RANGE, CONF_OR, CONF_SEND_EVERY, CONF_SLIDING_WINDOW_MOVING_AVERAGE, \ | ||||
|     CONF_THROTTLE, CONF_TRIGGER_ID, CONF_UNIQUE, CONF_UNIT_OF_MEASUREMENT, CONF_WINDOW_SIZE | ||||
| from esphomeyaml.helpers import App, ArrayInitializer, Pvariable, add, esphomelib_ns, float_, \ | ||||
|     process_lambda, setup_mqtt_component, templatable | ||||
|     process_lambda, setup_mqtt_component, templatable, add_job | ||||
|  | ||||
| PLATFORM_SCHEMA = cv.PLATFORM_SCHEMA.extend({ | ||||
|  | ||||
| @@ -152,13 +152,11 @@ def setup_sensor_core_(sensor_var, mqtt_var, config): | ||||
|     for conf in config.get(CONF_ON_VALUE, []): | ||||
|         rhs = sensor_var.make_value_trigger() | ||||
|         trigger = Pvariable(conf[CONF_TRIGGER_ID], rhs) | ||||
|         for _ in automation.build_automation(trigger, float_, conf): | ||||
|             yield | ||||
|         automation.build_automation(trigger, float_, conf) | ||||
|     for conf in config.get(CONF_ON_RAW_VALUE, []): | ||||
|         rhs = sensor_var.make_raw_value_trigger() | ||||
|         trigger = Pvariable(conf[CONF_TRIGGER_ID], rhs) | ||||
|         for _ in automation.build_automation(trigger, float_, conf): | ||||
|             yield | ||||
|         automation.build_automation(trigger, float_, conf) | ||||
|     for conf in config.get(CONF_ON_VALUE_RANGE, []): | ||||
|         rhs = sensor_var.make_value_range_trigger() | ||||
|         trigger = Pvariable(conf[CONF_TRIGGER_ID], rhs) | ||||
| @@ -172,8 +170,7 @@ def setup_sensor_core_(sensor_var, mqtt_var, config): | ||||
|             for template_ in templatable(conf[CONF_BELOW], float_, float_): | ||||
|                 yield | ||||
|             trigger.set_max(template_) | ||||
|         for _ in automation.build_automation(trigger, float_, conf): | ||||
|             yield | ||||
|         automation.build_automation(trigger, float_, conf) | ||||
|  | ||||
|     if CONF_EXPIRE_AFTER in config: | ||||
|         if config[CONF_EXPIRE_AFTER] is None: | ||||
| @@ -186,16 +183,14 @@ def setup_sensor_core_(sensor_var, mqtt_var, config): | ||||
| def setup_sensor(sensor_obj, mqtt_obj, config): | ||||
|     sensor_var = Pvariable(config[CONF_ID], sensor_obj, has_side_effects=False) | ||||
|     mqtt_var = Pvariable(config[CONF_MQTT_ID], mqtt_obj, has_side_effects=False) | ||||
|     for _ in setup_sensor_core_(sensor_var, mqtt_var, config): | ||||
|         yield | ||||
|     add_job(setup_sensor_core_, sensor_var, mqtt_var, config) | ||||
|  | ||||
|  | ||||
| def register_sensor(var, config): | ||||
|     sensor_var = Pvariable(config[CONF_ID], var, has_side_effects=True) | ||||
|     rhs = App.register_sensor(sensor_var) | ||||
|     mqtt_var = Pvariable(config[CONF_MQTT_ID], rhs, has_side_effects=True) | ||||
|     for _ in setup_sensor_core_(sensor_var, mqtt_var, config): | ||||
|         yield | ||||
|     add_job(setup_sensor_core_, sensor_var, mqtt_var, config) | ||||
|  | ||||
|  | ||||
| BUILD_FLAGS = '-DUSE_SENSOR' | ||||
|   | ||||
| @@ -42,8 +42,7 @@ def to_code(config): | ||||
|     adc = make.Padc | ||||
|     if CONF_ATTENUATION in config: | ||||
|         add(adc.set_attenuation(ATTENUATION_MODES[config[CONF_ATTENUATION]])) | ||||
|     for _ in sensor.setup_sensor(make.Padc, make.Pmqtt, config): | ||||
|         yield | ||||
|     sensor.setup_sensor(make.Padc, make.Pmqtt, config) | ||||
|  | ||||
|  | ||||
| BUILD_FLAGS = '-DUSE_ADC_SENSOR' | ||||
|   | ||||
| @@ -61,8 +61,7 @@ def to_code(config): | ||||
|     mux = MUX[config[CONF_MULTIPLEXER]] | ||||
|     gain = GAIN[config[CONF_GAIN]] | ||||
|     rhs = hub.get_sensor(config[CONF_NAME], mux, gain, config.get(CONF_UPDATE_INTERVAL)) | ||||
|     for _ in sensor.register_sensor(rhs, config): | ||||
|         yield | ||||
|     sensor.register_sensor(rhs, config) | ||||
|  | ||||
|  | ||||
| BUILD_FLAGS = '-DUSE_ADS1115_SENSOR' | ||||
|   | ||||
| @@ -31,8 +31,7 @@ def to_code(config): | ||||
|     bh1750 = make_bh1750.Pbh1750 | ||||
|     if CONF_RESOLUTION in config: | ||||
|         add(bh1750.set_resolution(BH1750_RESOLUTIONS[config[CONF_RESOLUTION]])) | ||||
|     for _ in sensor.setup_sensor(bh1750, make_bh1750.Pmqtt, config): | ||||
|         yield | ||||
|     sensor.setup_sensor(bh1750, make_bh1750.Pmqtt, config) | ||||
|  | ||||
|  | ||||
| BUILD_FLAGS = '-DUSE_BH1750' | ||||
|   | ||||
| @@ -63,15 +63,12 @@ def to_code(config): | ||||
|         constant = IIR_FILTER_OPTIONS[config[CONF_IIR_FILTER]] | ||||
|         add(bme280.set_iir_filter(constant)) | ||||
|  | ||||
|     for _ in sensor.setup_sensor(bme280.Pget_temperature_sensor(), make.Pmqtt_temperature, | ||||
|                                  config[CONF_TEMPERATURE]): | ||||
|         yield | ||||
|     for _ in sensor.setup_sensor(bme280.Pget_pressure_sensor(), make.Pmqtt_pressure, | ||||
|                                  config[CONF_PRESSURE]): | ||||
|         yield | ||||
|     for _ in sensor.setup_sensor(bme280.Pget_humidity_sensor(), make.Pmqtt_humidity, | ||||
|                                  config[CONF_HUMIDITY]): | ||||
|         yield | ||||
|     sensor.setup_sensor(bme280.Pget_temperature_sensor(), make.Pmqtt_temperature, | ||||
|                         config[CONF_TEMPERATURE]) | ||||
|     sensor.setup_sensor(bme280.Pget_pressure_sensor(), make.Pmqtt_pressure, | ||||
|                         config[CONF_PRESSURE]) | ||||
|     sensor.setup_sensor(bme280.Pget_humidity_sensor(), make.Pmqtt_humidity, | ||||
|                         config[CONF_HUMIDITY]) | ||||
|  | ||||
|  | ||||
| BUILD_FLAGS = '-DUSE_BME280' | ||||
|   | ||||
| @@ -70,18 +70,14 @@ def to_code(config): | ||||
|         constant = IIR_FILTER_OPTIONS[config[CONF_IIR_FILTER]] | ||||
|         add(bme680.set_iir_filter(constant)) | ||||
|  | ||||
|     for _ in sensor.setup_sensor(bme680.Pget_temperature_sensor(), make.Pmqtt_temperature, | ||||
|                                  config[CONF_TEMPERATURE]): | ||||
|         yield | ||||
|     for _ in sensor.setup_sensor(bme680.Pget_pressure_sensor(), make.Pmqtt_pressure, | ||||
|                                  config[CONF_PRESSURE]): | ||||
|         yield | ||||
|     for _ in sensor.setup_sensor(bme680.Pget_humidity_sensor(), make.Pmqtt_humidity, | ||||
|                                  config[CONF_HUMIDITY]): | ||||
|         yield | ||||
|     for _ in sensor.setup_sensor(bme680.Pget_gas_resistance_sensor(), make.Pmqtt_gas_resistance, | ||||
|                                  config[CONF_GAS_RESISTANCE]): | ||||
|         yield | ||||
|     sensor.setup_sensor(bme680.Pget_temperature_sensor(), make.Pmqtt_temperature, | ||||
|                         config[CONF_TEMPERATURE]) | ||||
|     sensor.setup_sensor(bme680.Pget_pressure_sensor(), make.Pmqtt_pressure, | ||||
|                         config[CONF_PRESSURE]) | ||||
|     sensor.setup_sensor(bme680.Pget_humidity_sensor(), make.Pmqtt_humidity, | ||||
|                         config[CONF_HUMIDITY]) | ||||
|     sensor.setup_sensor(bme680.Pget_gas_resistance_sensor(), make.Pmqtt_gas_resistance, | ||||
|                         config[CONF_GAS_RESISTANCE]) | ||||
|  | ||||
|  | ||||
| BUILD_FLAGS = '-DUSE_BME680' | ||||
|   | ||||
| @@ -4,7 +4,7 @@ import esphomeyaml.config_validation as cv | ||||
| from esphomeyaml.components import sensor | ||||
| from esphomeyaml.const import CONF_ADDRESS, CONF_MAKE_ID, CONF_NAME, CONF_PRESSURE, \ | ||||
|     CONF_TEMPERATURE, CONF_UPDATE_INTERVAL | ||||
| from esphomeyaml.helpers import App, HexIntLiteral, add, variable, Application | ||||
| from esphomeyaml.helpers import App, Application, HexIntLiteral, add, variable | ||||
|  | ||||
| DEPENDENCIES = ['i2c'] | ||||
|  | ||||
| @@ -27,12 +27,10 @@ def to_code(config): | ||||
|     if CONF_ADDRESS in config: | ||||
|         add(bmp.Pbmp.set_address(HexIntLiteral(config[CONF_ADDRESS]))) | ||||
|  | ||||
|     for _ in sensor.setup_sensor(bmp.Pbmp.Pget_temperature_sensor(), bmp.Pmqtt_temperature, | ||||
|                                  config[CONF_TEMPERATURE]): | ||||
|         yield | ||||
|     for _ in sensor.setup_sensor(bmp.Pbmp.Pget_pressure_sensor(), bmp.Pmqtt_pressure, | ||||
|                                  config[CONF_PRESSURE]): | ||||
|         yield | ||||
|     sensor.setup_sensor(bmp.Pbmp.Pget_temperature_sensor(), bmp.Pmqtt_temperature, | ||||
|                         config[CONF_TEMPERATURE]) | ||||
|     sensor.setup_sensor(bmp.Pbmp.Pget_pressure_sensor(), bmp.Pmqtt_pressure, | ||||
|                         config[CONF_PRESSURE]) | ||||
|  | ||||
|  | ||||
| BUILD_FLAGS = '-DUSE_BMP085_SENSOR' | ||||
|   | ||||
| @@ -30,8 +30,7 @@ def to_code(config): | ||||
|     else: | ||||
|         rhs = hub.Pget_sensor_by_index(config[CONF_NAME], config[CONF_INDEX], | ||||
|                                        update_interval, config.get(CONF_RESOLUTION)) | ||||
|     for _ in sensor.register_sensor(rhs, config): | ||||
|         yield | ||||
|     sensor.register_sensor(rhs, config) | ||||
|  | ||||
|  | ||||
| BUILD_FLAGS = '-DUSE_DALLAS_SENSOR' | ||||
|   | ||||
| @@ -39,12 +39,10 @@ def to_code(config): | ||||
|         constant = DHT_MODELS[config[CONF_MODEL]] | ||||
|         add(dht.Pdht.set_dht_model(constant)) | ||||
|  | ||||
|     for _ in sensor.setup_sensor(dht.Pdht.Pget_temperature_sensor(), | ||||
|                                  dht.Pmqtt_temperature, config[CONF_TEMPERATURE]): | ||||
|         yield | ||||
|     for _ in sensor.setup_sensor(dht.Pdht.Pget_humidity_sensor(), | ||||
|                                  dht.Pmqtt_humidity, config[CONF_HUMIDITY]): | ||||
|         yield | ||||
|     sensor.setup_sensor(dht.Pdht.Pget_temperature_sensor(), | ||||
|                         dht.Pmqtt_temperature, config[CONF_TEMPERATURE]) | ||||
|     sensor.setup_sensor(dht.Pdht.Pget_humidity_sensor(), | ||||
|                         dht.Pmqtt_humidity, config[CONF_HUMIDITY]) | ||||
|  | ||||
|  | ||||
| BUILD_FLAGS = '-DUSE_DHT_SENSOR' | ||||
|   | ||||
| @@ -24,12 +24,10 @@ def to_code(config): | ||||
|                                 config.get(CONF_UPDATE_INTERVAL)) | ||||
|     dht = variable(config[CONF_MAKE_ID], rhs) | ||||
|  | ||||
|     for _ in sensor.setup_sensor(dht.Pdht.Pget_temperature_sensor(), dht.Pmqtt_temperature, | ||||
|                                  config[CONF_TEMPERATURE]): | ||||
|         yield | ||||
|     for _ in sensor.setup_sensor(dht.Pdht.Pget_humidity_sensor(), dht.Pmqtt_humidity, | ||||
|                                  config[CONF_HUMIDITY]): | ||||
|         yield | ||||
|     sensor.setup_sensor(dht.Pdht.Pget_temperature_sensor(), dht.Pmqtt_temperature, | ||||
|                         config[CONF_TEMPERATURE]) | ||||
|     sensor.setup_sensor(dht.Pdht.Pget_humidity_sensor(), dht.Pmqtt_humidity, | ||||
|                         config[CONF_HUMIDITY]) | ||||
|  | ||||
|  | ||||
| BUILD_FLAGS = '-DUSE_DHT12_SENSOR' | ||||
|   | ||||
| @@ -18,8 +18,7 @@ PLATFORM_SCHEMA = sensor.PLATFORM_SCHEMA.extend({ | ||||
| def to_code(config): | ||||
|     rhs = App.make_esp32_hall_sensor(config[CONF_NAME], config.get(CONF_UPDATE_INTERVAL)) | ||||
|     make = variable(config[CONF_MAKE_ID], rhs) | ||||
|     for _ in sensor.setup_sensor(make.Phall, make.Pmqtt, config): | ||||
|         yield | ||||
|     sensor.setup_sensor(make.Phall, make.Pmqtt, config) | ||||
|  | ||||
|  | ||||
| BUILD_FLAGS = '-DUSE_ESP32_HALL_SENSOR' | ||||
|   | ||||
| @@ -4,7 +4,7 @@ import esphomeyaml.config_validation as cv | ||||
| from esphomeyaml.components import sensor | ||||
| from esphomeyaml.const import CONF_HUMIDITY, CONF_MAKE_ID, CONF_NAME, CONF_TEMPERATURE, \ | ||||
|     CONF_UPDATE_INTERVAL | ||||
| from esphomeyaml.helpers import App, variable, Application | ||||
| from esphomeyaml.helpers import App, Application, variable | ||||
|  | ||||
| DEPENDENCIES = ['i2c'] | ||||
|  | ||||
| @@ -24,13 +24,11 @@ def to_code(config): | ||||
|                                   config.get(CONF_UPDATE_INTERVAL)) | ||||
|     hdc1080 = variable(config[CONF_MAKE_ID], rhs) | ||||
|  | ||||
|     for _ in sensor.setup_sensor(hdc1080.Phdc1080.Pget_temperature_sensor(), | ||||
|                                  hdc1080.Pmqtt_temperature, | ||||
|                                  config[CONF_TEMPERATURE]): | ||||
|         yield | ||||
|     for _ in sensor.setup_sensor(hdc1080.Phdc1080.Pget_humidity_sensor(), hdc1080.Pmqtt_humidity, | ||||
|                                  config[CONF_HUMIDITY]): | ||||
|         yield | ||||
|     sensor.setup_sensor(hdc1080.Phdc1080.Pget_temperature_sensor(), | ||||
|                         hdc1080.Pmqtt_temperature, | ||||
|                         config[CONF_TEMPERATURE]) | ||||
|     sensor.setup_sensor(hdc1080.Phdc1080.Pget_humidity_sensor(), hdc1080.Pmqtt_humidity, | ||||
|                         config[CONF_HUMIDITY]) | ||||
|  | ||||
|  | ||||
| BUILD_FLAGS = '-DUSE_HDC1080_SENSOR' | ||||
|   | ||||
| @@ -4,7 +4,7 @@ import esphomeyaml.config_validation as cv | ||||
| from esphomeyaml.components import sensor | ||||
| from esphomeyaml.const import CONF_HUMIDITY, CONF_MAKE_ID, CONF_NAME, CONF_TEMPERATURE, \ | ||||
|     CONF_UPDATE_INTERVAL | ||||
| from esphomeyaml.helpers import App, variable, Application | ||||
| from esphomeyaml.helpers import App, Application, variable | ||||
|  | ||||
| DEPENDENCIES = ['i2c'] | ||||
|  | ||||
| @@ -23,12 +23,10 @@ def to_code(config): | ||||
|                                  config[CONF_HUMIDITY][CONF_NAME], | ||||
|                                  config.get(CONF_UPDATE_INTERVAL)) | ||||
|     htu21d = variable(config[CONF_MAKE_ID], rhs) | ||||
|     for _ in sensor.setup_sensor(htu21d.Phtu21d.Pget_temperature_sensor(), htu21d.Pmqtt_temperature, | ||||
|                                  config[CONF_TEMPERATURE]): | ||||
|         yield | ||||
|     for _ in sensor.setup_sensor(htu21d.Phtu21d.Pget_humidity_sensor(), htu21d.Pmqtt_humidity, | ||||
|                                  config[CONF_HUMIDITY]): | ||||
|         yield | ||||
|     sensor.setup_sensor(htu21d.Phtu21d.Pget_temperature_sensor(), htu21d.Pmqtt_temperature, | ||||
|                         config[CONF_TEMPERATURE]) | ||||
|     sensor.setup_sensor(htu21d.Phtu21d.Pget_humidity_sensor(), htu21d.Pmqtt_humidity, | ||||
|                         config[CONF_HUMIDITY]) | ||||
|  | ||||
|  | ||||
| BUILD_FLAGS = '-DUSE_HTU21D_SENSOR' | ||||
|   | ||||
| @@ -32,8 +32,7 @@ def to_code(config): | ||||
|     rhs = App.make_max6675_sensor(config[CONF_NAME], pin_cs, pin_clock, pin_miso, | ||||
|                                   config.get(CONF_UPDATE_INTERVAL)) | ||||
|     make = variable(config[CONF_MAKE_ID], rhs) | ||||
|     for _ in sensor.setup_sensor(make.Pmax6675, make.Pmqtt, config): | ||||
|         yield | ||||
|     sensor.setup_sensor(make.Pmax6675, make.Pmqtt, config) | ||||
|  | ||||
|  | ||||
| BUILD_FLAGS = '-DUSE_MAX6675_SENSOR' | ||||
|   | ||||
| @@ -41,38 +41,31 @@ def to_code(config): | ||||
|     if CONF_ACCEL_X in config: | ||||
|         conf = config[CONF_ACCEL_X] | ||||
|         rhs = mpu.Pmake_accel_x_sensor(conf[CONF_NAME]) | ||||
|         for _ in sensor.register_sensor(rhs, conf): | ||||
|             yield | ||||
|         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]) | ||||
|         for _ in sensor.register_sensor(rhs, conf): | ||||
|             yield | ||||
|         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]) | ||||
|         for _ in sensor.register_sensor(rhs, conf): | ||||
|             yield | ||||
|         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]) | ||||
|         for _ in sensor.register_sensor(rhs, conf): | ||||
|             yield | ||||
|         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]) | ||||
|         for _ in sensor.register_sensor(rhs, conf): | ||||
|             yield | ||||
|         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]) | ||||
|         for _ in sensor.register_sensor(rhs, conf): | ||||
|             yield | ||||
|         sensor.register_sensor(rhs, conf) | ||||
|     if CONF_TEMPERATURE in config: | ||||
|         conf = config[CONF_TEMPERATURE] | ||||
|         rhs = mpu.Pmake_temperature_sensor(conf[CONF_NAME]) | ||||
|         for _ in sensor.register_sensor(rhs, conf): | ||||
|             yield | ||||
|         sensor.register_sensor(rhs, conf) | ||||
|  | ||||
|  | ||||
| BUILD_FLAGS = '-DUSE_MPU6050' | ||||
|   | ||||
| @@ -57,8 +57,7 @@ def to_code(config): | ||||
|         add(pcnt.set_edge_mode(rising_edge, falling_edge)) | ||||
|     if CONF_INTERNAL_FILTER in config: | ||||
|         add(pcnt.set_filter(config[CONF_INTERNAL_FILTER])) | ||||
|     for _ in sensor.setup_sensor(make.Ppcnt, make.Pmqtt, config): | ||||
|         yield | ||||
|     sensor.setup_sensor(make.Ppcnt, make.Pmqtt, config) | ||||
|  | ||||
|  | ||||
| BUILD_FLAGS = '-DUSE_PULSE_COUNTER_SENSOR' | ||||
|   | ||||
| @@ -45,8 +45,7 @@ def to_code(config): | ||||
|     if CONF_RESOLUTION in config: | ||||
|         resolution = RESOLUTIONS[config[CONF_RESOLUTION]] | ||||
|         add(encoder.set_resolution(resolution)) | ||||
|     for _ in sensor.setup_sensor(encoder, make.Pmqtt, config): | ||||
|         yield | ||||
|     sensor.setup_sensor(encoder, make.Pmqtt, config) | ||||
|  | ||||
|  | ||||
| BUILD_FLAGS = '-DUSE_ROTARY_ENCODER_SENSOR' | ||||
|   | ||||
| @@ -35,12 +35,10 @@ def to_code(config): | ||||
|     if CONF_ACCURACY in config: | ||||
|         add(sht3xd.Psht3xd.set_accuracy(SHT_ACCURACIES[config[CONF_ACCURACY]])) | ||||
|  | ||||
|     for _ in sensor.setup_sensor(sht3xd.Psht3xd.Pget_temperature_sensor(), sht3xd.Pmqtt_temperature, | ||||
|                                  config[CONF_TEMPERATURE]): | ||||
|         yield | ||||
|     for _ in sensor.setup_sensor(sht3xd.Psht3xd.Pget_humidity_sensor(), sht3xd.Pmqtt_humidity, | ||||
|                                  config[CONF_HUMIDITY]): | ||||
|         yield | ||||
|     sensor.setup_sensor(sht3xd.Psht3xd.Pget_temperature_sensor(), sht3xd.Pmqtt_temperature, | ||||
|                         config[CONF_TEMPERATURE]) | ||||
|     sensor.setup_sensor(sht3xd.Psht3xd.Pget_humidity_sensor(), sht3xd.Pmqtt_humidity, | ||||
|                         config[CONF_HUMIDITY]) | ||||
|  | ||||
|  | ||||
| BUILD_FLAGS = '-DUSE_SHT3XD' | ||||
|   | ||||
| @@ -21,8 +21,7 @@ def to_code(config): | ||||
|     rhs = App.make_template_sensor(config[CONF_NAME], template_, | ||||
|                                    config.get(CONF_UPDATE_INTERVAL)) | ||||
|     make = variable(config[CONF_MAKE_ID], rhs) | ||||
|     for _ in sensor.setup_sensor(make.Ptemplate_, make.Pmqtt, config): | ||||
|         yield | ||||
|     sensor.setup_sensor(make.Ptemplate_, make.Pmqtt, config) | ||||
|  | ||||
|  | ||||
| BUILD_FLAGS = '-DUSE_TEMPLATE_SENSOR' | ||||
|   | ||||
| @@ -51,8 +51,7 @@ def to_code(config): | ||||
|         add(tsl2561.set_gain(GAINS[config[CONF_GAIN]])) | ||||
|     if CONF_IS_CS_PACKAGE in config: | ||||
|         add(tsl2561.set_is_cs_package(config[CONF_IS_CS_PACKAGE])) | ||||
|     for _ in sensor.setup_sensor(tsl2561, make_tsl.Pmqtt, config): | ||||
|         yield | ||||
|     sensor.setup_sensor(tsl2561, make_tsl.Pmqtt, config) | ||||
|  | ||||
|  | ||||
| BUILD_FLAGS = '-DUSE_TSL2561' | ||||
|   | ||||
| @@ -35,8 +35,7 @@ def to_code(config): | ||||
|         add(ultrasonic.set_timeout_us(config[CONF_TIMEOUT_TIME])) | ||||
|     elif CONF_TIMEOUT_METER in config: | ||||
|         add(ultrasonic.set_timeout_m(config[CONF_TIMEOUT_METER])) | ||||
|     for _ in sensor.setup_sensor(ultrasonic, make.Pmqtt, config): | ||||
|         yield | ||||
|     sensor.setup_sensor(ultrasonic, make.Pmqtt, config) | ||||
|  | ||||
|  | ||||
| BUILD_FLAGS = '-DUSE_ULTRASONIC_SENSOR' | ||||
|   | ||||
		Reference in New Issue
	
	Block a user