diff --git a/esphomeyaml/automation.py b/esphomeyaml/automation.py index fbaf8e13c1..9e29ff369e 100644 --- a/esphomeyaml/automation.py +++ b/esphomeyaml/automation.py @@ -8,7 +8,7 @@ from esphomeyaml.const import CONF_ABOVE, CONF_ACTION_ID, CONF_AND, CONF_AUTOMAT CONF_EFFECT, CONF_ELSE, CONF_FLASH_LENGTH, CONF_GREEN, CONF_ID, CONF_IF, CONF_LAMBDA, \ CONF_LEVEL, CONF_OR, CONF_OSCILLATING, CONF_PAYLOAD, CONF_QOS, CONF_RANGE, CONF_RED, \ CONF_RETAIN, CONF_SPEED, CONF_THEN, CONF_TOPIC, CONF_TRANSITION_LENGTH, CONF_TRIGGER_ID, \ - CONF_WHITE + CONF_WHITE, CONF_COLOR_TEMPERATURE from esphomeyaml.core import ESPHomeYAMLError from esphomeyaml.helpers import App, ArrayInitializer, Pvariable, TemplateArguments, add, add_job, \ bool_, esphomelib_ns, float_, get_variable, process_lambda, std_string, templatable, uint32, \ @@ -87,6 +87,7 @@ ACTIONS_SCHEMA = vol.All(cv.ensure_list, [vol.All({ vol.Optional(CONF_GREEN): cv.templatable(cv.percentage), vol.Optional(CONF_BLUE): cv.templatable(cv.percentage), vol.Optional(CONF_WHITE): cv.templatable(cv.percentage), + vol.Optional(CONF_COLOR_TEMPERATURE): cv.templatable(cv.positive_float), vol.Optional(CONF_EFFECT): cv.templatable(cv.string), }), vol.Optional(CONF_SWITCH_TOGGLE): maybe_simple_id({ @@ -256,13 +257,11 @@ def build_action(full_config, arg_type): rhs = App.register_component(DelayAction.new(template_arg)) type = DelayAction.template(template_arg) action = Pvariable(action_id, rhs, type=type) - template_ = None for template_ in templatable(config, arg_type, uint32): yield add(action.set_delay(template_)) yield action elif key == CONF_LAMBDA: - lambda_ = None for lambda_ in process_lambda(config, [(arg_type, 'x')]): yield None rhs = LambdaAction.new(template_arg, lambda_) @@ -272,22 +271,18 @@ def build_action(full_config, arg_type): rhs = App.Pget_mqtt_client().Pmake_publish_action(template_arg) type = mqtt.MQTTPublishAction.template(template_arg) action = Pvariable(action_id, rhs, type=type) - template_ = None for template_ in templatable(config[CONF_TOPIC], arg_type, std_string): yield None add(action.set_topic(template_)) - template_ = None for template_ in templatable(config[CONF_PAYLOAD], arg_type, std_string): yield None add(action.set_payload(template_)) if CONF_QOS in config: - template_ = None for template_ in templatable(config[CONF_QOS], arg_type, uint8): yield add(action.set_qos(template_)) if CONF_RETAIN in config: - template_ = None for template_ in templatable(config[CONF_RETAIN], arg_type, bool_): yield None add(action.set_retain(template_)) @@ -299,7 +294,6 @@ def build_action(full_config, arg_type): type = light.ToggleAction.template(template_arg) action = Pvariable(action_id, rhs, type=type) if CONF_TRANSITION_LENGTH in config: - template_ = None for template_ in templatable(config[CONF_TRANSITION_LENGTH], arg_type, uint32): yield None add(action.set_transition_length(template_)) @@ -311,7 +305,6 @@ def build_action(full_config, arg_type): type = light.TurnOffAction.template(template_arg) action = Pvariable(action_id, rhs, type=type) if CONF_TRANSITION_LENGTH in config: - template_ = None for template_ in templatable(config[CONF_TRANSITION_LENGTH], arg_type, uint32): yield None add(action.set_transition_length(template_)) @@ -323,42 +316,38 @@ def build_action(full_config, arg_type): type = light.TurnOnAction.template(template_arg) action = Pvariable(action_id, rhs, type=type) if CONF_TRANSITION_LENGTH in config: - template_ = None for template_ in templatable(config[CONF_TRANSITION_LENGTH], arg_type, uint32): yield None add(action.set_transition_length(template_)) if CONF_FLASH_LENGTH in config: - template_ = None for template_ in templatable(config[CONF_FLASH_LENGTH], arg_type, uint32): yield None add(action.set_flash_length(template_)) if CONF_BRIGHTNESS in config: - template_ = None for template_ in templatable(config[CONF_BRIGHTNESS], arg_type, float_): yield None add(action.set_brightness(template_)) if CONF_RED in config: - template_ = None for template_ in templatable(config[CONF_RED], arg_type, float_): yield None add(action.set_red(template_)) if CONF_GREEN in config: - template_ = None for template_ in templatable(config[CONF_GREEN], arg_type, float_): yield None add(action.set_green(template_)) if CONF_BLUE in config: - template_ = None for template_ in templatable(config[CONF_BLUE], arg_type, float_): yield None add(action.set_blue(template_)) if CONF_WHITE in config: - template_ = None for template_ in templatable(config[CONF_WHITE], arg_type, float_): yield None add(action.set_white(template_)) + if CONF_COLOR_TEMPERATURE in config: + for template_ in templatable(config[CONF_COLOR_TEMPERATURE], arg_type, float_): + yield None + add(action.set_color_temperature(template_)) if CONF_EFFECT in config: - template_ = None for template_ in templatable(config[CONF_EFFECT], arg_type, std_string): yield None add(action.set_effect(template_)) @@ -418,12 +407,10 @@ def build_action(full_config, arg_type): type = fan.TurnOnAction.template(arg_type) action = Pvariable(action_id, rhs, type=type) if CONF_OSCILLATING in config: - template_ = None for template_ in templatable(config[CONF_OSCILLATING], arg_type, bool_): yield None add(action.set_oscillating(template_)) if CONF_SPEED in config: - template_ = None for template_ in templatable(config[CONF_SPEED], arg_type, fan.FanSpeed): yield None add(action.set_speed(template_)) @@ -446,7 +433,6 @@ def build_action(full_config, arg_type): rhs = var.make_set_level_action(template_arg) type = output.SetLevelAction.template(arg_type) action = Pvariable(action_id, rhs, type=type) - template_ = None for template_ in templatable(config[CONF_LEVEL], arg_type, bool_): yield None add(action.set_level(template_)) diff --git a/esphomeyaml/components/binary_sensor/nextion.py b/esphomeyaml/components/binary_sensor/nextion.py new file mode 100644 index 0000000000..5f6b1529b5 --- /dev/null +++ b/esphomeyaml/components/binary_sensor/nextion.py @@ -0,0 +1,26 @@ +import voluptuous as vol + +import esphomeyaml.config_validation as cv +from esphomeyaml.components import binary_sensor +from esphomeyaml.components.display.nextion import Nextion +from esphomeyaml.const import CONF_COMPONENT_ID, CONF_NAME, CONF_PAGE_ID +from esphomeyaml.helpers import get_variable + +DEPENDENCIES = ['display'] + +CONF_NEXTION_ID = 'nextion_id' + +PLATFORM_SCHEMA = cv.nameable(binary_sensor.BINARY_SENSOR_PLATFORM_SCHEMA.extend({ + vol.Required(CONF_PAGE_ID): cv.uint8_t, + vol.Required(CONF_COMPONENT_ID): cv.uint8_t, + cv.GenerateID(CONF_NEXTION_ID): cv.use_variable_id(Nextion) +})) + + +def to_code(config): + hub = None + for hub in get_variable(config[CONF_NEXTION_ID]): + yield + rhs = hub.make_touch_component(config[CONF_NAME], config[CONF_PAGE_ID], + config[CONF_COMPONENT_ID]) + binary_sensor.register_binary_sensor(rhs, config) diff --git a/esphomeyaml/components/dallas.py b/esphomeyaml/components/dallas.py index 440e83b582..22c4ac3ee3 100644 --- a/esphomeyaml/components/dallas.py +++ b/esphomeyaml/components/dallas.py @@ -11,7 +11,7 @@ DallasComponent = sensor.sensor_ns.DallasComponent CONFIG_SCHEMA = vol.All(cv.ensure_list, [vol.Schema({ cv.GenerateID(): cv.declare_variable_id(DallasComponent), vol.Required(CONF_PIN): pins.input_output_pin, - vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds, + vol.Optional(CONF_UPDATE_INTERVAL): cv.update_interval, })]) diff --git a/esphomeyaml/components/display/__init__.py b/esphomeyaml/components/display/__init__.py index 82bb3793cc..cada701f87 100644 --- a/esphomeyaml/components/display/__init__.py +++ b/esphomeyaml/components/display/__init__.py @@ -33,7 +33,7 @@ def validate_rotation(value): BASIC_DISPLAY_PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ - vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds, + vol.Optional(CONF_UPDATE_INTERVAL): cv.update_interval, vol.Optional(CONF_LAMBDA): cv.lambda_, }) diff --git a/esphomeyaml/components/display/lcd_gpio.py b/esphomeyaml/components/display/lcd_gpio.py index 52dac25820..66cc021c5f 100644 --- a/esphomeyaml/components/display/lcd_gpio.py +++ b/esphomeyaml/components/display/lcd_gpio.py @@ -3,8 +3,8 @@ import voluptuous as vol import esphomeyaml.config_validation as cv from esphomeyaml import pins from esphomeyaml.components import display -from esphomeyaml.const import CONF_DIMENSIONS, CONF_ENABLE_PIN, CONF_ID, CONF_LAMBDA, CONF_DATA_PINS, \ - CONF_RS_PIN, CONF_RW_PIN +from esphomeyaml.const import CONF_DATA_PINS, CONF_DIMENSIONS, CONF_ENABLE_PIN, CONF_ID, \ + CONF_LAMBDA, CONF_RS_PIN, CONF_RW_PIN from esphomeyaml.helpers import App, Pvariable, add, gpio_output_pin_expression, process_lambda GPIOLCDDisplay = display.display_ns.GPIOLCDDisplay diff --git a/esphomeyaml/components/display/nextion.py b/esphomeyaml/components/display/nextion.py new file mode 100644 index 0000000000..44e69c74cf --- /dev/null +++ b/esphomeyaml/components/display/nextion.py @@ -0,0 +1,32 @@ +import esphomeyaml.config_validation as cv +from esphomeyaml.components import display +from esphomeyaml.components.uart import UARTComponent +from esphomeyaml.const import CONF_ID, CONF_LAMBDA, CONF_UART_ID +from esphomeyaml.helpers import App, Pvariable, add, get_variable, process_lambda + +DEPENDENCIES = ['uart'] + +Nextion = display.display_ns.Nextion +NextionRef = Nextion.operator('ref') + +PLATFORM_SCHEMA = display.BASIC_DISPLAY_PLATFORM_SCHEMA.extend({ + cv.GenerateID(): cv.declare_variable_id(Nextion), + cv.GenerateID(CONF_UART_ID): cv.use_variable_id(UARTComponent), +}) + + +def to_code(config): + for uart in get_variable(config[CONF_UART_ID]): + yield + rhs = App.make_nextion(uart) + nextion = Pvariable(config[CONF_ID], rhs) + + if CONF_LAMBDA in config: + for lambda_ in process_lambda(config[CONF_LAMBDA], [(NextionRef, 'it')]): + yield + add(nextion.set_writer(lambda_)) + + display.setup_display(nextion, config) + + +BUILD_FLAGS = '-DUSE_NEXTION' diff --git a/esphomeyaml/components/light/cwww.py b/esphomeyaml/components/light/cwww.py new file mode 100644 index 0000000000..53a19bdd1e --- /dev/null +++ b/esphomeyaml/components/light/cwww.py @@ -0,0 +1,34 @@ +import voluptuous as vol + +import esphomeyaml.config_validation as cv +from esphomeyaml.components import light +from esphomeyaml.components.light.rgbww import validate_cold_white_colder, \ + validate_color_temperature +from esphomeyaml.const import CONF_COLD_WHITE, CONF_COLD_WHITE_COLOR_TEMPERATURE, \ + CONF_DEFAULT_TRANSITION_LENGTH, CONF_EFFECTS, CONF_GAMMA_CORRECT, CONF_MAKE_ID, \ + CONF_NAME, CONF_WARM_WHITE, CONF_WARM_WHITE_COLOR_TEMPERATURE +from esphomeyaml.helpers import App, get_variable, variable + +PLATFORM_SCHEMA = cv.nameable(light.LIGHT_PLATFORM_SCHEMA.extend({ + cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(light.MakeLight), + vol.Required(CONF_COLD_WHITE): cv.use_variable_id(None), + vol.Required(CONF_WARM_WHITE): cv.use_variable_id(None), + vol.Required(CONF_COLD_WHITE_COLOR_TEMPERATURE): validate_color_temperature, + vol.Required(CONF_WARM_WHITE_COLOR_TEMPERATURE): validate_color_temperature, + + vol.Optional(CONF_GAMMA_CORRECT): cv.positive_float, + vol.Optional(CONF_DEFAULT_TRANSITION_LENGTH): cv.positive_time_period_milliseconds, + vol.Optional(CONF_EFFECTS): light.validate_effects(light.RGB_EFFECTS), +}), validate_cold_white_colder) + + +def to_code(config): + for cold_white in get_variable(config[CONF_COLD_WHITE]): + yield + for warm_white in get_variable(config[CONF_WARM_WHITE]): + yield + rhs = App.make_cwww_light(config[CONF_NAME], config[CONF_COLD_WHITE_COLOR_TEMPERATURE], + config[CONF_WARM_WHITE_COLOR_TEMPERATURE], + cold_white, warm_white) + light_struct = variable(config[CONF_MAKE_ID], rhs) + light.setup_light(light_struct.Pstate, light_struct.Pmqtt, config) diff --git a/esphomeyaml/components/light/rgbww.py b/esphomeyaml/components/light/rgbww.py new file mode 100644 index 0000000000..fe69993698 --- /dev/null +++ b/esphomeyaml/components/light/rgbww.py @@ -0,0 +1,62 @@ +import voluptuous as vol + +import esphomeyaml.config_validation as cv +from esphomeyaml.components import light +from esphomeyaml.const import CONF_BLUE, CONF_COLD_WHITE, CONF_COLD_WHITE_COLOR_TEMPERATURE, \ + CONF_DEFAULT_TRANSITION_LENGTH, CONF_EFFECTS, CONF_GAMMA_CORRECT, CONF_GREEN, CONF_MAKE_ID, \ + CONF_NAME, CONF_RED, CONF_WARM_WHITE, CONF_WARM_WHITE_COLOR_TEMPERATURE +from esphomeyaml.helpers import App, get_variable, variable + + +def validate_color_temperature(value): + try: + val = cv.float_with_unit('Color Temperature', 'mireds')(value) + except vol.Invalid: + val = 1000000.0 / cv.float_with_unit('Color Temperature', 'K')(value) + if val < 0: + raise vol.Invalid("Color temperature cannot be negative") + return val + + +def validate_cold_white_colder(value): + cw = value[CONF_COLD_WHITE_COLOR_TEMPERATURE] + ww = value[CONF_WARM_WHITE_COLOR_TEMPERATURE] + if cw > ww: + raise vol.Invalid("Cold white color temperature cannot be higher than warm white") + if cw == ww: + raise vol.Invalid("Cold white color temperature cannot be the same as warm white") + return value + + +PLATFORM_SCHEMA = cv.nameable(light.LIGHT_PLATFORM_SCHEMA.extend({ + cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(light.MakeLight), + vol.Required(CONF_RED): cv.use_variable_id(None), + vol.Required(CONF_GREEN): cv.use_variable_id(None), + vol.Required(CONF_BLUE): cv.use_variable_id(None), + vol.Required(CONF_COLD_WHITE): cv.use_variable_id(None), + vol.Required(CONF_WARM_WHITE): cv.use_variable_id(None), + vol.Required(CONF_COLD_WHITE_COLOR_TEMPERATURE): validate_color_temperature, + vol.Required(CONF_WARM_WHITE_COLOR_TEMPERATURE): validate_color_temperature, + + vol.Optional(CONF_GAMMA_CORRECT): cv.positive_float, + vol.Optional(CONF_DEFAULT_TRANSITION_LENGTH): cv.positive_time_period_milliseconds, + vol.Optional(CONF_EFFECTS): light.validate_effects(light.RGB_EFFECTS), +}), validate_cold_white_colder) + + +def to_code(config): + for red in get_variable(config[CONF_RED]): + yield + for green in get_variable(config[CONF_GREEN]): + yield + for blue in get_variable(config[CONF_BLUE]): + yield + for cold_white in get_variable(config[CONF_COLD_WHITE]): + yield + for warm_white in get_variable(config[CONF_WARM_WHITE]): + yield + rhs = App.make_rgbww_light(config[CONF_NAME], config[CONF_COLD_WHITE_COLOR_TEMPERATURE], + config[CONF_WARM_WHITE_COLOR_TEMPERATURE], + red, green, blue, cold_white, warm_white) + light_struct = variable(config[CONF_MAKE_ID], rhs) + light.setup_light(light_struct.Pstate, light_struct.Pmqtt, config) diff --git a/esphomeyaml/components/pn532.py b/esphomeyaml/components/pn532.py index 08aa4d3f15..68dc52ab90 100644 --- a/esphomeyaml/components/pn532.py +++ b/esphomeyaml/components/pn532.py @@ -15,7 +15,7 @@ CONFIG_SCHEMA = vol.All(cv.ensure_list, [vol.Schema({ cv.GenerateID(): cv.declare_variable_id(PN532Component), cv.GenerateID(CONF_SPI_ID): cv.use_variable_id(SPIComponent), vol.Required(CONF_CS_PIN): pins.gpio_output_pin_schema, - vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds, + vol.Optional(CONF_UPDATE_INTERVAL): cv.update_interval, })]) diff --git a/esphomeyaml/components/sensor/adc.py b/esphomeyaml/components/sensor/adc.py index b8ce2ccc8c..6d75251c69 100644 --- a/esphomeyaml/components/sensor/adc.py +++ b/esphomeyaml/components/sensor/adc.py @@ -28,7 +28,7 @@ PLATFORM_SCHEMA = cv.nameable(sensor.SENSOR_PLATFORM_SCHEMA.extend({ cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeADCSensor), vol.Required(CONF_PIN): validate_adc_pin, vol.Optional(CONF_ATTENUATION): vol.All(cv.only_on_esp32, cv.one_of(*ATTENUATION_MODES)), - vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds, + vol.Optional(CONF_UPDATE_INTERVAL): cv.update_interval, })) diff --git a/esphomeyaml/components/sensor/ads1115.py b/esphomeyaml/components/sensor/ads1115.py index 3630953d2b..ab9b594a78 100644 --- a/esphomeyaml/components/sensor/ads1115.py +++ b/esphomeyaml/components/sensor/ads1115.py @@ -49,7 +49,7 @@ PLATFORM_SCHEMA = cv.nameable(sensor.SENSOR_PLATFORM_SCHEMA.extend({ vol.Required(CONF_MULTIPLEXER): validate_mux, vol.Required(CONF_GAIN): validate_gain, cv.GenerateID(CONF_ADS1115_ID): cv.use_variable_id(ADS1115Component), - vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds, + vol.Optional(CONF_UPDATE_INTERVAL): cv.update_interval, })) diff --git a/esphomeyaml/components/sensor/bh1750.py b/esphomeyaml/components/sensor/bh1750.py index 3aaf8e116f..c50a1494ab 100644 --- a/esphomeyaml/components/sensor/bh1750.py +++ b/esphomeyaml/components/sensor/bh1750.py @@ -20,7 +20,7 @@ PLATFORM_SCHEMA = cv.nameable(sensor.SENSOR_PLATFORM_SCHEMA.extend({ cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeBH1750Sensor), vol.Optional(CONF_ADDRESS, default=0x23): cv.i2c_address, vol.Optional(CONF_RESOLUTION): vol.All(cv.positive_float, cv.one_of(*BH1750_RESOLUTIONS)), - vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds, + vol.Optional(CONF_UPDATE_INTERVAL): cv.update_interval, })) diff --git a/esphomeyaml/components/sensor/bme280.py b/esphomeyaml/components/sensor/bme280.py index 882cec4891..e123134fb7 100644 --- a/esphomeyaml/components/sensor/bme280.py +++ b/esphomeyaml/components/sensor/bme280.py @@ -38,7 +38,7 @@ PLATFORM_SCHEMA = sensor.PLATFORM_SCHEMA.extend({ vol.Required(CONF_PRESSURE): cv.nameable(BME280_OVERSAMPLING_SENSOR_SCHEMA), vol.Required(CONF_HUMIDITY): cv.nameable(BME280_OVERSAMPLING_SENSOR_SCHEMA), vol.Optional(CONF_IIR_FILTER): vol.All(vol.Upper, cv.one_of(*IIR_FILTER_OPTIONS)), - vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds, + vol.Optional(CONF_UPDATE_INTERVAL): cv.update_interval, }) diff --git a/esphomeyaml/components/sensor/bme680.py b/esphomeyaml/components/sensor/bme680.py index f1dc90a197..43cebc5d49 100644 --- a/esphomeyaml/components/sensor/bme680.py +++ b/esphomeyaml/components/sensor/bme680.py @@ -49,7 +49,7 @@ PLATFORM_SCHEMA = sensor.PLATFORM_SCHEMA.extend({ vol.Optional(CONF_DURATION, default='150ms'): vol.All( cv.positive_time_period_milliseconds, vol.Range(max=core.TimePeriod(milliseconds=4032))) }, cv.has_at_least_one_key(CONF_TEMPERATURE, CONF_DURATION)))), - vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds, + vol.Optional(CONF_UPDATE_INTERVAL): cv.update_interval, }) diff --git a/esphomeyaml/components/sensor/bmp085.py b/esphomeyaml/components/sensor/bmp085.py index a7f6ed4553..01659d9852 100644 --- a/esphomeyaml/components/sensor/bmp085.py +++ b/esphomeyaml/components/sensor/bmp085.py @@ -15,7 +15,7 @@ PLATFORM_SCHEMA = sensor.PLATFORM_SCHEMA.extend({ vol.Required(CONF_TEMPERATURE): cv.nameable(sensor.SENSOR_SCHEMA), vol.Required(CONF_PRESSURE): cv.nameable(sensor.SENSOR_SCHEMA), vol.Optional(CONF_ADDRESS): cv.i2c_address, - vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds, + vol.Optional(CONF_UPDATE_INTERVAL): cv.update_interval, }) diff --git a/esphomeyaml/components/sensor/bmp280.py b/esphomeyaml/components/sensor/bmp280.py index d2a04af7ee..53d4a34e48 100644 --- a/esphomeyaml/components/sensor/bmp280.py +++ b/esphomeyaml/components/sensor/bmp280.py @@ -37,7 +37,7 @@ PLATFORM_SCHEMA = sensor.PLATFORM_SCHEMA.extend({ vol.Required(CONF_TEMPERATURE): cv.nameable(BMP280_OVERSAMPLING_SENSOR_SCHEMA), vol.Required(CONF_PRESSURE): cv.nameable(BMP280_OVERSAMPLING_SENSOR_SCHEMA), vol.Optional(CONF_IIR_FILTER): vol.All(vol.Upper, cv.one_of(*IIR_FILTER_OPTIONS)), - vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds, + vol.Optional(CONF_UPDATE_INTERVAL): cv.update_interval, }) diff --git a/esphomeyaml/components/sensor/dht.py b/esphomeyaml/components/sensor/dht.py index 14d2c3dd85..0b4f013e2a 100644 --- a/esphomeyaml/components/sensor/dht.py +++ b/esphomeyaml/components/sensor/dht.py @@ -23,7 +23,7 @@ PLATFORM_SCHEMA = sensor.PLATFORM_SCHEMA.extend({ vol.Required(CONF_TEMPERATURE): cv.nameable(sensor.SENSOR_SCHEMA), vol.Required(CONF_HUMIDITY): cv.nameable(sensor.SENSOR_SCHEMA), vol.Optional(CONF_MODEL): vol.All(vol.Upper, cv.one_of(*DHT_MODELS)), - vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds, + vol.Optional(CONF_UPDATE_INTERVAL): cv.update_interval, }) diff --git a/esphomeyaml/components/sensor/dht12.py b/esphomeyaml/components/sensor/dht12.py index 1bc42ddbb2..f6526ada08 100644 --- a/esphomeyaml/components/sensor/dht12.py +++ b/esphomeyaml/components/sensor/dht12.py @@ -14,7 +14,7 @@ PLATFORM_SCHEMA = sensor.PLATFORM_SCHEMA.extend({ cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeDHT12Sensor), vol.Required(CONF_TEMPERATURE): cv.nameable(sensor.SENSOR_SCHEMA), vol.Required(CONF_HUMIDITY): cv.nameable(sensor.SENSOR_SCHEMA), - vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds, + vol.Optional(CONF_UPDATE_INTERVAL): cv.update_interval, }) diff --git a/esphomeyaml/components/sensor/duty_cycle.py b/esphomeyaml/components/sensor/duty_cycle.py index f4d0e17053..0153f12010 100644 --- a/esphomeyaml/components/sensor/duty_cycle.py +++ b/esphomeyaml/components/sensor/duty_cycle.py @@ -11,7 +11,7 @@ MakeDutyCycleSensor = Application.MakeDutyCycleSensor PLATFORM_SCHEMA = cv.nameable(sensor.SENSOR_PLATFORM_SCHEMA.extend({ cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeDutyCycleSensor), vol.Required(CONF_PIN): pins.internal_gpio_input_pin_schema, - vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds, + vol.Optional(CONF_UPDATE_INTERVAL): cv.update_interval, })) diff --git a/esphomeyaml/components/sensor/esp32_hall.py b/esphomeyaml/components/sensor/esp32_hall.py index b454b7b3b0..dd6a5fc545 100644 --- a/esphomeyaml/components/sensor/esp32_hall.py +++ b/esphomeyaml/components/sensor/esp32_hall.py @@ -11,7 +11,7 @@ MakeESP32HallSensor = Application.MakeESP32HallSensor PLATFORM_SCHEMA = cv.nameable(sensor.SENSOR_PLATFORM_SCHEMA.extend({ cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeESP32HallSensor), - vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds, + vol.Optional(CONF_UPDATE_INTERVAL): cv.update_interval, })) diff --git a/esphomeyaml/components/sensor/hdc1080.py b/esphomeyaml/components/sensor/hdc1080.py index 6484d07354..642dc68f1f 100644 --- a/esphomeyaml/components/sensor/hdc1080.py +++ b/esphomeyaml/components/sensor/hdc1080.py @@ -14,7 +14,7 @@ PLATFORM_SCHEMA = sensor.PLATFORM_SCHEMA.extend({ cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeHDC1080Sensor), vol.Required(CONF_TEMPERATURE): cv.nameable(sensor.SENSOR_SCHEMA), vol.Required(CONF_HUMIDITY): cv.nameable(sensor.SENSOR_SCHEMA), - vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds, + vol.Optional(CONF_UPDATE_INTERVAL): cv.update_interval, }) diff --git a/esphomeyaml/components/sensor/hlw8012.py b/esphomeyaml/components/sensor/hlw8012.py new file mode 100644 index 0000000000..83de464c86 --- /dev/null +++ b/esphomeyaml/components/sensor/hlw8012.py @@ -0,0 +1,57 @@ +import voluptuous as vol + +import esphomeyaml.config_validation as cv +from esphomeyaml import pins +from esphomeyaml.components import sensor +from esphomeyaml.const import CONF_CF1_PIN, CONF_CF_PIN, CONF_CHANGE_MODE_EVERY, CONF_CURRENT, \ + CONF_CURRENT_RESISTOR, CONF_ID, CONF_NAME, CONF_POWER, CONF_SEL_PIN, CONF_UPDATE_INTERVAL, \ + CONF_VOLTAGE, CONF_VOLTAGE_DIVIDER +from esphomeyaml.helpers import App, Pvariable, add, gpio_output_pin_expression + +HLW8012Component = sensor.sensor_ns.HLW8012Component +HLW8012VoltageSensor = sensor.sensor_ns.HLW8012VoltageSensor +HLW8012CurrentSensor = sensor.sensor_ns.HLW8012CurrentSensor +HLW8012PowerSensor = sensor.sensor_ns.HLW8012PowerSensor + +PLATFORM_SCHEMA = vol.All(sensor.PLATFORM_SCHEMA.extend({ + cv.GenerateID(): cv.declare_variable_id(HLW8012Component), + vol.Required(CONF_SEL_PIN): pins.gpio_output_pin_schema, + vol.Required(CONF_CF_PIN): pins.input_pin, + vol.Required(CONF_CF1_PIN): pins.input_pin, + + vol.Optional(CONF_VOLTAGE): cv.nameable(sensor.SENSOR_SCHEMA), + vol.Optional(CONF_CURRENT): cv.nameable(sensor.SENSOR_SCHEMA), + vol.Optional(CONF_POWER): cv.nameable(sensor.SENSOR_SCHEMA), + + vol.Optional(CONF_CURRENT_RESISTOR): cv.resistance, + vol.Optional(CONF_VOLTAGE_DIVIDER): cv.positive_float, + vol.Optional(CONF_CHANGE_MODE_EVERY): vol.All(cv.uint32_t, vol.Range(min=1)), + vol.Optional(CONF_UPDATE_INTERVAL): cv.update_interval, +}), cv.has_at_least_one_key(CONF_VOLTAGE, CONF_CURRENT, CONF_POWER)) + + +def to_code(config): + sel = None + 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_VOLTAGE] + sensor.register_sensor(hlw.make_current_sensor(conf[CONF_NAME]), conf) + if CONF_POWER in config: + conf = config[CONF_VOLTAGE] + 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_CHANGE_MODE_EVERY in config: + add(hlw.set_change_mode_every(config[CONF_CHANGE_MODE_EVERY])) + + +BUILD_FLAGS = '-DUSE_HLW8012' diff --git a/esphomeyaml/components/sensor/hmc5883l.py b/esphomeyaml/components/sensor/hmc5883l.py index 7fdae9f831..827843fef1 100644 --- a/esphomeyaml/components/sensor/hmc5883l.py +++ b/esphomeyaml/components/sensor/hmc5883l.py @@ -43,7 +43,7 @@ PLATFORM_SCHEMA = vol.All(sensor.PLATFORM_SCHEMA.extend({ vol.Optional(CONF_FIELD_STRENGTH_Y): cv.nameable(sensor.SENSOR_SCHEMA), vol.Optional(CONF_FIELD_STRENGTH_Z): cv.nameable(sensor.SENSOR_SCHEMA), vol.Optional(CONF_HEADING): cv.nameable(sensor.SENSOR_SCHEMA), - vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds, + vol.Optional(CONF_UPDATE_INTERVAL): cv.update_interval, vol.Optional(CONF_RANGE): validate_range, }), cv.has_at_least_one_key(CONF_FIELD_STRENGTH_X, CONF_FIELD_STRENGTH_Y, CONF_FIELD_STRENGTH_Z, CONF_HEADING)) diff --git a/esphomeyaml/components/sensor/htu21d.py b/esphomeyaml/components/sensor/htu21d.py index 596d2de697..c0a381107d 100644 --- a/esphomeyaml/components/sensor/htu21d.py +++ b/esphomeyaml/components/sensor/htu21d.py @@ -14,7 +14,7 @@ PLATFORM_SCHEMA = sensor.PLATFORM_SCHEMA.extend({ cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeHTU21DSensor), vol.Required(CONF_TEMPERATURE): cv.nameable(sensor.SENSOR_SCHEMA), vol.Required(CONF_HUMIDITY): cv.nameable(sensor.SENSOR_SCHEMA), - vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds, + vol.Optional(CONF_UPDATE_INTERVAL): cv.update_interval, }) diff --git a/esphomeyaml/components/sensor/hx711.py b/esphomeyaml/components/sensor/hx711.py index 18696ed8f1..721c915383 100644 --- a/esphomeyaml/components/sensor/hx711.py +++ b/esphomeyaml/components/sensor/hx711.py @@ -21,7 +21,7 @@ PLATFORM_SCHEMA = cv.nameable(sensor.SENSOR_PLATFORM_SCHEMA.extend({ vol.Required(CONF_DOUT_PIN): pins.gpio_input_pin_schema, vol.Required(CONF_CLK_PIN): pins.gpio_output_pin_schema, vol.Optional(CONF_GAIN): vol.All(cv.int_, cv.one_of(*GAINS)), - vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds, + vol.Optional(CONF_UPDATE_INTERVAL): cv.update_interval, })) diff --git a/esphomeyaml/components/sensor/ina219.py b/esphomeyaml/components/sensor/ina219.py index 01f9388347..3aefb945e1 100644 --- a/esphomeyaml/components/sensor/ina219.py +++ b/esphomeyaml/components/sensor/ina219.py @@ -26,7 +26,7 @@ PLATFORM_SCHEMA = vol.All(sensor.PLATFORM_SCHEMA.extend({ vol.Range(min=0.0, max=32.0)), vol.Optional(CONF_MAX_VOLTAGE, default=32.0): vol.All(cv.voltage, vol.Range(min=0.0, max=32.0)), vol.Optional(CONF_MAX_CURRENT, default=3.2): vol.All(cv.current, vol.Range(min=0.0)), - vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds, + vol.Optional(CONF_UPDATE_INTERVAL): cv.update_interval, }), cv.has_at_least_one_key(CONF_BUS_VOLTAGE, CONF_SHUNT_VOLTAGE, CONF_CURRENT, CONF_POWER)) diff --git a/esphomeyaml/components/sensor/ina3221.py b/esphomeyaml/components/sensor/ina3221.py index 9921113a0d..bd9d574906 100644 --- a/esphomeyaml/components/sensor/ina3221.py +++ b/esphomeyaml/components/sensor/ina3221.py @@ -34,7 +34,7 @@ PLATFORM_SCHEMA = sensor.PLATFORM_SCHEMA.extend({ vol.Optional(CONF_CHANNEL_1): INA3221_CHANNEL_SCHEMA, vol.Optional(CONF_CHANNEL_2): INA3221_CHANNEL_SCHEMA, vol.Optional(CONF_CHANNEL_3): INA3221_CHANNEL_SCHEMA, - vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds, + vol.Optional(CONF_UPDATE_INTERVAL): cv.update_interval, }) diff --git a/esphomeyaml/components/sensor/max6675.py b/esphomeyaml/components/sensor/max6675.py index db2484f23f..ae9ce0ee16 100644 --- a/esphomeyaml/components/sensor/max6675.py +++ b/esphomeyaml/components/sensor/max6675.py @@ -14,7 +14,7 @@ PLATFORM_SCHEMA = cv.nameable(sensor.SENSOR_PLATFORM_SCHEMA.extend({ cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeMAX6675Sensor), cv.GenerateID(CONF_SPI_ID): cv.use_variable_id(SPIComponent), vol.Required(CONF_CS_PIN): pins.gpio_output_pin_schema, - vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds, + vol.Optional(CONF_UPDATE_INTERVAL): cv.update_interval, })) diff --git a/esphomeyaml/components/sensor/mhz19.py b/esphomeyaml/components/sensor/mhz19.py index 4c40cd1a64..7af15aa341 100644 --- a/esphomeyaml/components/sensor/mhz19.py +++ b/esphomeyaml/components/sensor/mhz19.py @@ -16,7 +16,7 @@ PLATFORM_SCHEMA = sensor.PLATFORM_SCHEMA.extend({ cv.GenerateID(CONF_UART_ID): cv.use_variable_id(UARTComponent), vol.Required(CONF_CO2): cv.nameable(sensor.SENSOR_SCHEMA), vol.Optional(CONF_TEMPERATURE): cv.nameable(sensor.SENSOR_SCHEMA), - vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds, + vol.Optional(CONF_UPDATE_INTERVAL): cv.update_interval, }) diff --git a/esphomeyaml/components/sensor/mpu6050.py b/esphomeyaml/components/sensor/mpu6050.py index 0af2772d25..8aa989312e 100644 --- a/esphomeyaml/components/sensor/mpu6050.py +++ b/esphomeyaml/components/sensor/mpu6050.py @@ -30,7 +30,7 @@ PLATFORM_SCHEMA = vol.All(sensor.PLATFORM_SCHEMA.extend({ vol.Optional(CONF_GYRO_Y): cv.nameable(sensor.SENSOR_SCHEMA), vol.Optional(CONF_GYRO_Z): cv.nameable(sensor.SENSOR_SCHEMA), vol.Optional(CONF_TEMPERATURE): cv.nameable(sensor.SENSOR_SCHEMA), - vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds, + vol.Optional(CONF_UPDATE_INTERVAL): cv.update_interval, }), cv.has_at_least_one_key(CONF_ACCEL_X, CONF_ACCEL_Y, CONF_ACCEL_Z, CONF_GYRO_X, CONF_GYRO_Y, CONF_GYRO_Z)) diff --git a/esphomeyaml/components/sensor/ms5611.py b/esphomeyaml/components/sensor/ms5611.py index e0f337d4bb..92afc930dd 100644 --- a/esphomeyaml/components/sensor/ms5611.py +++ b/esphomeyaml/components/sensor/ms5611.py @@ -15,7 +15,7 @@ PLATFORM_SCHEMA = sensor.PLATFORM_SCHEMA.extend({ vol.Optional(CONF_ADDRESS): cv.i2c_address, vol.Required(CONF_TEMPERATURE): cv.nameable(sensor.SENSOR_SCHEMA), vol.Required(CONF_PRESSURE): cv.nameable(sensor.SENSOR_SCHEMA), - vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds, + vol.Optional(CONF_UPDATE_INTERVAL): cv.update_interval, }) diff --git a/esphomeyaml/components/sensor/pulse_counter.py b/esphomeyaml/components/sensor/pulse_counter.py index f7c2700ea9..575d1a76c4 100644 --- a/esphomeyaml/components/sensor/pulse_counter.py +++ b/esphomeyaml/components/sensor/pulse_counter.py @@ -40,7 +40,7 @@ PLATFORM_SCHEMA = cv.nameable(sensor.SENSOR_PLATFORM_SCHEMA.extend({ vol.Required(CONF_FALLING_EDGE): COUNT_MODE_SCHEMA, }), vol.Optional(CONF_INTERNAL_FILTER): validate_internal_filter, - vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds, + vol.Optional(CONF_UPDATE_INTERVAL): cv.update_interval, vol.Optional(CONF_PULL_MODE): cv.invalid("The pull_mode option has been removed in 1.7.0, " "please use the pin mode schema now.") diff --git a/esphomeyaml/components/sensor/sht3xd.py b/esphomeyaml/components/sensor/sht3xd.py index 108b010038..f78d988dc8 100644 --- a/esphomeyaml/components/sensor/sht3xd.py +++ b/esphomeyaml/components/sensor/sht3xd.py @@ -15,7 +15,7 @@ PLATFORM_SCHEMA = sensor.PLATFORM_SCHEMA.extend({ vol.Required(CONF_TEMPERATURE): cv.nameable(sensor.SENSOR_SCHEMA), vol.Required(CONF_HUMIDITY): cv.nameable(sensor.SENSOR_SCHEMA), vol.Optional(CONF_ADDRESS, default=0x44): cv.i2c_address, - vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds, + vol.Optional(CONF_UPDATE_INTERVAL): cv.update_interval, vol.Optional(CONF_ACCURACY): cv.invalid("The accuracy option has been removed and now " "defaults to HIGH."), diff --git a/esphomeyaml/components/sensor/tcs34725.py b/esphomeyaml/components/sensor/tcs34725.py index 50ea527e5d..5da00be172 100644 --- a/esphomeyaml/components/sensor/tcs34725.py +++ b/esphomeyaml/components/sensor/tcs34725.py @@ -43,7 +43,7 @@ PLATFORM_SCHEMA = vol.All(sensor.PLATFORM_SCHEMA.extend({ vol.Optional(CONF_COLOR_TEMPERATURE): cv.nameable(sensor.SENSOR_SCHEMA), vol.Optional(CONF_INTEGRATION_TIME): cv.one_of(*TCS34725_INTEGRATION_TIMES), vol.Optional(CONF_GAIN): vol.All(vol.Upper, cv.one_of(*TCS34725_GAINS)), - vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds, + vol.Optional(CONF_UPDATE_INTERVAL): cv.update_interval, }), cv.has_at_least_one_key(CONF_RED_CHANNEL, CONF_GREEN_CHANNEL, CONF_BLUE_CHANNEL, CONF_CLEAR_CHANNEL, CONF_ILLUMINANCE, CONF_COLOR_TEMPERATURE)) diff --git a/esphomeyaml/components/sensor/template.py b/esphomeyaml/components/sensor/template.py index 9ad1952215..6ae6138d5c 100644 --- a/esphomeyaml/components/sensor/template.py +++ b/esphomeyaml/components/sensor/template.py @@ -10,7 +10,7 @@ MakeTemplateSensor = Application.MakeTemplateSensor PLATFORM_SCHEMA = cv.nameable(sensor.SENSOR_PLATFORM_SCHEMA.extend({ cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeTemplateSensor), vol.Required(CONF_LAMBDA): cv.lambda_, - vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds, + vol.Optional(CONF_UPDATE_INTERVAL): cv.update_interval, })) diff --git a/esphomeyaml/components/sensor/tsl2561.py b/esphomeyaml/components/sensor/tsl2561.py index 20e8257d08..b97919038d 100644 --- a/esphomeyaml/components/sensor/tsl2561.py +++ b/esphomeyaml/components/sensor/tsl2561.py @@ -36,7 +36,7 @@ PLATFORM_SCHEMA = cv.nameable(sensor.SENSOR_PLATFORM_SCHEMA.extend({ vol.Optional(CONF_INTEGRATION_TIME): validate_integration_time, vol.Optional(CONF_GAIN): vol.All(vol.Upper, cv.one_of(*GAINS)), vol.Optional(CONF_IS_CS_PACKAGE): cv.boolean, - vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds, + vol.Optional(CONF_UPDATE_INTERVAL): cv.update_interval, })) diff --git a/esphomeyaml/components/sensor/ultrasonic.py b/esphomeyaml/components/sensor/ultrasonic.py index 353ce4a471..31ba1f4027 100644 --- a/esphomeyaml/components/sensor/ultrasonic.py +++ b/esphomeyaml/components/sensor/ultrasonic.py @@ -16,7 +16,7 @@ PLATFORM_SCHEMA = cv.nameable(sensor.SENSOR_PLATFORM_SCHEMA.extend({ vol.Required(CONF_ECHO_PIN): pins.internal_gpio_input_pin_schema, vol.Exclusive(CONF_TIMEOUT_METER, 'timeout'): cv.positive_float, vol.Exclusive(CONF_TIMEOUT_TIME, 'timeout'): cv.positive_time_period_microseconds, - vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds, + vol.Optional(CONF_UPDATE_INTERVAL): cv.update_interval, })) diff --git a/esphomeyaml/components/sensor/uptime.py b/esphomeyaml/components/sensor/uptime.py index dcb8c7498c..1abb5ecd91 100644 --- a/esphomeyaml/components/sensor/uptime.py +++ b/esphomeyaml/components/sensor/uptime.py @@ -9,7 +9,7 @@ MakeUptimeSensor = Application.MakeUptimeSensor PLATFORM_SCHEMA = cv.nameable(sensor.SENSOR_PLATFORM_SCHEMA.extend({ cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeUptimeSensor), - vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds, + vol.Optional(CONF_UPDATE_INTERVAL): cv.update_interval, })) diff --git a/esphomeyaml/components/sensor/wifi_signal.py b/esphomeyaml/components/sensor/wifi_signal.py index 0f070c1e61..93c6172e08 100644 --- a/esphomeyaml/components/sensor/wifi_signal.py +++ b/esphomeyaml/components/sensor/wifi_signal.py @@ -9,7 +9,7 @@ MakeWiFiSignalSensor = Application.MakeWiFiSignalSensor PLATFORM_SCHEMA = cv.nameable(sensor.SENSOR_PLATFORM_SCHEMA.extend({ cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeWiFiSignalSensor), - vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds, + vol.Optional(CONF_UPDATE_INTERVAL): cv.update_interval, })) diff --git a/esphomeyaml/config_validation.py b/esphomeyaml/config_validation.py index 2982c0e0ac..94e3c434aa 100644 --- a/esphomeyaml/config_validation.py +++ b/esphomeyaml/config_validation.py @@ -328,6 +328,12 @@ def time_period_in_seconds_(value): return TimePeriodSeconds(**value.as_dict()) +def update_interval(value): + if value == 'never': + return 4294967295 # uint32_t max + return positive_time_period_milliseconds(value) + + time_period = vol.Any(time_period_str_unit, time_period_str_colon, time_period_dict) positive_time_period = vol.All(time_period, vol.Range(min=TimePeriod())) positive_time_period_milliseconds = vol.All(positive_time_period, time_period_in_milliseconds_) diff --git a/esphomeyaml/const.py b/esphomeyaml/const.py index b5c10bc206..9f3fa23ab8 100644 --- a/esphomeyaml/const.py +++ b/esphomeyaml/const.py @@ -309,6 +309,19 @@ CONF_EXTERNAL_VCC = 'external_vcc' CONF_TIMEZONE = 'timezone' CONF_SERVERS = 'servers' CONF_HEATER = 'heater' +CONF_VOLTAGE = 'voltage' +CONF_CURRENT_RESISTOR = 'current_resistor' +CONF_VOLTAGE_DIVIDER = 'voltage_divider' +CONF_SEL_PIN = 'sel_pin' +CONF_CF_PIN = 'cf_pin' +CONF_CF1_PIN = 'cf1_pin' +CONF_CHANGE_MODE_EVERY = 'change_mode_every' +CONF_PAGE_ID = 'page_id' +CONF_COMPONENT_ID = 'component_id' +CONF_COLD_WHITE = 'cold_white' +CONF_WARM_WHITE = 'warm_white' +CONF_COLD_WHITE_COLOR_TEMPERATURE = 'cold_white_color_temperature' +CONF_WARM_WHITE_COLOR_TEMPERATURE = 'warm_white_color_temperature' ESP32_BOARDS = [ 'featheresp32', 'node32s', 'espea32', 'firebeetle32', 'esp32doit-devkit-v1', diff --git a/esphomeyaml/helpers.py b/esphomeyaml/helpers.py index 7f008507d4..21e7ea0ce7 100644 --- a/esphomeyaml/helpers.py +++ b/esphomeyaml/helpers.py @@ -273,6 +273,12 @@ class IntLiteral(Literal): self.i = i def __str__(self): + if self.i > 4294967295: + return u'{}ULL'.format(self.i) + if self.i > 2147483647: + return u'{}UL'.format(self.i) + if self.i < -2147483648: + return u'{}LL'.format(self.i) return unicode(self.i)