import voluptuous as vol import esphomeyaml.config_validation as cv from esphomeyaml.components import sensor from esphomeyaml.const import CONF_MAKE_ID, CONF_NAME, CONF_UPDATE_INTERVAL, ESP_PLATFORM_ESP32 from esphomeyaml.helpers import App, Application, variable, setup_component ESP_PLATFORMS = [ESP_PLATFORM_ESP32] MakeESP32HallSensor = Application.struct('MakeESP32HallSensor') ESP32HallSensor = sensor.sensor_ns.class_('ESP32HallSensor', sensor.PollingSensorComponent) PLATFORM_SCHEMA = cv.nameable( sensor.SENSOR_PLATFORM_SCHEMA.extend({ cv.GenerateID(): cv.declare_variable_id(ESP32HallSensor), cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeESP32HallSensor), vol.Optional(CONF_UPDATE_INTERVAL): cv.update_interval, }).extend(cv.COMPONENT_SCHEMA.schema)) 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) sensor.setup_sensor(make.Phall, make.Pmqtt, config) setup_component(make.Phall, config)
CONF_MAKE_ID, CONF_NAME, CONF_PIN, CONF_PULL_MODE, CONF_RISING_EDGE, CONF_UPDATE_INTERVAL, \ ESP_PLATFORM_ESP32 from esphomeyaml.helpers import App, Application, add, variable, gpio_input_pin_expression, \ setup_component PulseCounterCountMode = sensor.sensor_ns.enum('PulseCounterCountMode') COUNT_MODES = { 'DISABLE': PulseCounterCountMode.PULSE_COUNTER_DISABLE, 'INCREMENT': PulseCounterCountMode.PULSE_COUNTER_INCREMENT, 'DECREMENT': PulseCounterCountMode.PULSE_COUNTER_DECREMENT, } COUNT_MODE_SCHEMA = vol.All(vol.Upper, cv.one_of(*COUNT_MODES)) PulseCounterBase = sensor.sensor_ns.class_('PulseCounterBase') MakePulseCounterSensor = Application.struct('MakePulseCounterSensor') PulseCounterSensorComponent = sensor.sensor_ns.class_( 'PulseCounterSensorComponent', sensor.PollingSensorComponent, PulseCounterBase) def validate_internal_filter(value): if core.ESP_PLATFORM == ESP_PLATFORM_ESP32: if isinstance(value, int): raise vol.Invalid( "Please specify the internal filter in microseconds now " "(since 1.7.0). For example '17ms'") value = cv.positive_time_period_microseconds(value) if value.total_microseconds > 13: raise vol.Invalid( "Maximum internal filter value for ESP32 is 13us")
import voluptuous as vol from esphomeyaml.components import text_sensor import esphomeyaml.config_validation as cv from esphomeyaml.const import CONF_MAKE_ID, CONF_NAME, CONF_QOS, CONF_TOPIC from esphomeyaml.helpers import App, Application, add, variable, setup_component, Component DEPENDENCIES = ['mqtt'] MakeMQTTSubscribeTextSensor = Application.struct('MakeMQTTSubscribeTextSensor') MQTTSubscribeTextSensor = text_sensor.text_sensor_ns.class_( 'MQTTSubscribeTextSensor', text_sensor.TextSensor, Component) PLATFORM_SCHEMA = cv.nameable( text_sensor.TEXT_SENSOR_PLATFORM_SCHEMA.extend({ cv.GenerateID(): cv.declare_variable_id(MQTTSubscribeTextSensor), cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeMQTTSubscribeTextSensor), vol.Required(CONF_TOPIC): cv.subscribe_topic, vol.Optional(CONF_QOS): cv.mqtt_qos, }).extend(cv.COMPONENT_SCHEMA.schema)) def to_code(config): rhs = App.make_mqtt_subscribe_text_sensor(config[CONF_NAME], config[CONF_TOPIC]) make = variable(config[CONF_MAKE_ID], rhs) sensor_ = make.Psensor
import voluptuous as vol from esphomeyaml.components import i2c, sensor import esphomeyaml.config_validation as cv from esphomeyaml.const import CONF_ADDRESS, CONF_HUMIDITY, CONF_MAKE_ID, CONF_NAME, \ CONF_TEMPERATURE, CONF_UPDATE_INTERVAL, CONF_ID from esphomeyaml.helpers import App, Application, PollingComponent, setup_component, variable, \ Pvariable DEPENDENCIES = ['i2c'] MakeSHT3XDSensor = Application.struct('MakeSHT3XDSensor') SHT3XDComponent = sensor.sensor_ns.class_('SHT3XDComponent', PollingComponent, i2c.I2CDevice) SHT3XDTemperatureSensor = sensor.sensor_ns.class_('SHT3XDTemperatureSensor', sensor.EmptyPollingParentSensor) SHT3XDHumiditySensor = sensor.sensor_ns.class_('SHT3XDHumiditySensor', sensor.EmptyPollingParentSensor) PLATFORM_SCHEMA = sensor.PLATFORM_SCHEMA.extend({ cv.GenerateID(): cv.declare_variable_id(SHT3XDComponent), cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeSHT3XDSensor), vol.Required(CONF_TEMPERATURE): cv.nameable(sensor.SENSOR_SCHEMA.extend({ cv.GenerateID(): cv.declare_variable_id(SHT3XDTemperatureSensor), })), vol.Required(CONF_HUMIDITY): cv.nameable(sensor.SENSOR_SCHEMA.extend({ cv.GenerateID(): cv.declare_variable_id(SHT3XDHumiditySensor), })), vol.Optional(CONF_ADDRESS, default=0x44): cv.i2c_address, vol.Optional(CONF_UPDATE_INTERVAL): cv.update_interval, }).extend(cv.COMPONENT_SCHEMA.schema)
import voluptuous as vol import esphomeyaml.config_validation as cv from esphomeyaml import pins from esphomeyaml.components import sensor, spi from esphomeyaml.components.spi import SPIComponent from esphomeyaml.const import CONF_CS_PIN, CONF_MAKE_ID, CONF_NAME, CONF_SPI_ID, \ CONF_UPDATE_INTERVAL from esphomeyaml.helpers import App, Application, get_variable, gpio_output_pin_expression, \ variable, setup_component MakeMAX6675Sensor = Application.struct('MakeMAX6675Sensor') MAX6675Sensor = sensor.sensor_ns.class_('MAX6675Sensor', sensor.PollingSensorComponent, spi.SPIDevice) PLATFORM_SCHEMA = cv.nameable( sensor.SENSOR_PLATFORM_SCHEMA.extend({ cv.GenerateID(): cv.declare_variable_id(MAX6675Sensor), 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.update_interval, }).extend(cv.COMPONENT_SCHEMA.schema))
import voluptuous as vol import esphomeyaml.config_validation as cv from esphomeyaml import pins from esphomeyaml.components import sensor from esphomeyaml.const import CONF_GAIN, CONF_MAKE_ID, CONF_NAME, CONF_UPDATE_INTERVAL, CONF_CLK_PIN from esphomeyaml.helpers import App, Application, add, gpio_input_pin_expression, variable, \ setup_component MakeHX711Sensor = Application.struct('MakeHX711Sensor') HX711Sensor = sensor.sensor_ns.class_('HX711Sensor', sensor.PollingSensorComponent) CONF_DOUT_PIN = 'dout_pin' HX711Gain = sensor.sensor_ns.enum('HX711Gain') GAINS = { 128: HX711Gain.HX711_GAIN_128, 32: HX711Gain.HX711_GAIN_32, 64: HX711Gain.HX711_GAIN_64, } PLATFORM_SCHEMA = cv.nameable( sensor.SENSOR_PLATFORM_SCHEMA.extend({ cv.GenerateID(): cv.declare_variable_id(HX711Sensor), cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeHX711Sensor), vol.Required(CONF_DOUT_PIN): pins.gpio_input_pin_schema, vol.Required(CONF_CLK_PIN):
import voluptuous as vol import esphomeyaml.config_validation as cv from esphomeyaml import automation from esphomeyaml.components import cover from esphomeyaml.const import CONF_CLOSE_ACTION, CONF_LAMBDA, CONF_MAKE_ID, CONF_NAME, \ CONF_OPEN_ACTION, CONF_STOP_ACTION, CONF_OPTIMISTIC from esphomeyaml.helpers import App, Application, NoArg, add, process_lambda, variable, optional, \ setup_component MakeTemplateCover = Application.struct('MakeTemplateCover') TemplateCover = cover.cover_ns.class_('TemplateCover', cover.Cover) PLATFORM_SCHEMA = cv.nameable( cover.COVER_PLATFORM_SCHEMA.extend({ cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeTemplateCover), cv.GenerateID(): cv.declare_variable_id(TemplateCover), vol.Optional(CONF_LAMBDA): cv.lambda_, vol.Optional(CONF_OPTIMISTIC): cv.boolean, vol.Optional(CONF_OPEN_ACTION): automation.validate_automation(single=True), vol.Optional(CONF_CLOSE_ACTION): automation.validate_automation(single=True), vol.Optional(CONF_STOP_ACTION): automation.validate_automation(single=True), }).extend(cv.COMPONENT_SCHEMA.schema), cv.has_at_least_one_key(CONF_LAMBDA, CONF_OPTIMISTIC))
import voluptuous as vol from esphomeyaml.components import binary_sensor import esphomeyaml.config_validation as cv from esphomeyaml.const import CONF_LAMBDA, CONF_MAKE_ID, CONF_NAME from esphomeyaml.helpers import App, Application, add, bool_, optional, process_lambda, variable, \ setup_component, Component MakeTemplateBinarySensor = Application.struct('MakeTemplateBinarySensor') TemplateBinarySensor = binary_sensor.binary_sensor_ns.class_('TemplateBinarySensor', binary_sensor.BinarySensor, Component) PLATFORM_SCHEMA = cv.nameable(binary_sensor.BINARY_SENSOR_PLATFORM_SCHEMA.extend({ cv.GenerateID(): cv.declare_variable_id(TemplateBinarySensor), cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeTemplateBinarySensor), vol.Required(CONF_LAMBDA): cv.lambda_, }).extend(cv.COMPONENT_SCHEMA.schema)) def to_code(config): rhs = App.make_template_binary_sensor(config[CONF_NAME]) make = variable(config[CONF_MAKE_ID], rhs) binary_sensor.setup_binary_sensor(make.Ptemplate_, make.Pmqtt, config) setup_component(make.Ptemplate_, config) template_ = None for template_ in process_lambda(config[CONF_LAMBDA], [], return_type=optional.template(bool_)): yield add(make.Ptemplate_.set_template(template_))
import voluptuous as vol import esphomeyaml.config_validation as cv from esphomeyaml.components import sensor from esphomeyaml.const import CONF_MAKE_ID, CONF_NAME, CONF_UPDATE_INTERVAL from esphomeyaml.helpers import App, Application, variable, setup_component MakeWiFiSignalSensor = Application.struct('MakeWiFiSignalSensor') WiFiSignalSensor = sensor.sensor_ns.class_('WiFiSignalSensor', sensor.PollingSensorComponent) PLATFORM_SCHEMA = cv.nameable(sensor.SENSOR_PLATFORM_SCHEMA.extend({ cv.GenerateID(): cv.declare_variable_id(WiFiSignalSensor), cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeWiFiSignalSensor), vol.Optional(CONF_UPDATE_INTERVAL): cv.update_interval, }).extend(cv.COMPONENT_SCHEMA.schema)) def to_code(config): rhs = App.make_wifi_signal_sensor(config[CONF_NAME], config.get(CONF_UPDATE_INTERVAL)) make = variable(config[CONF_MAKE_ID], rhs) wifi = make.Pwifi sensor.setup_sensor(wifi, make.Pmqtt, config) setup_component(wifi, config) BUILD_FLAGS = '-DUSE_WIFI_SIGNAL_SENSOR' def to_hass_config(data, config): return sensor.core_to_hass_config(data, config)
import esphomeyaml.config_validation as cv from esphomeyaml.components import binary_sensor from esphomeyaml.const import CONF_MAKE_ID, CONF_NAME from esphomeyaml.helpers import App, Application, variable, setup_component, Component DEPENDENCIES = ['mqtt'] MakeStatusBinarySensor = Application.struct('MakeStatusBinarySensor') StatusBinarySensor = binary_sensor.binary_sensor_ns.class_( 'StatusBinarySensor', binary_sensor.BinarySensor, Component) PLATFORM_SCHEMA = cv.nameable( binary_sensor.BINARY_SENSOR_PLATFORM_SCHEMA.extend({ cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeStatusBinarySensor), cv.GenerateID(): cv.declare_variable_id(StatusBinarySensor), }).extend(cv.COMPONENT_SCHEMA.schema)) def to_code(config): rhs = App.make_status_binary_sensor(config[CONF_NAME]) status = variable(config[CONF_MAKE_ID], rhs) binary_sensor.setup_binary_sensor(status.Pstatus, status.Pmqtt, config) setup_component(status.Pstatus, config) BUILD_FLAGS = '-DUSE_STATUS_BINARY_SENSOR' def to_hass_config(data, config):
import voluptuous as vol import esphomeyaml.config_validation as cv from esphomeyaml.components import sensor, i2c from esphomeyaml.const import CONF_HUMIDITY, CONF_MAKE_ID, CONF_NAME, CONF_TEMPERATURE, \ CONF_UPDATE_INTERVAL, CONF_ID from esphomeyaml.helpers import App, Application, variable, setup_component, PollingComponent, \ Pvariable DEPENDENCIES = ['i2c'] MakeHDC1080Sensor = Application.struct('MakeHDC1080Sensor') HDC1080Component = sensor.sensor_ns.class_('HDC1080Component', PollingComponent, i2c.I2CDevice) HDC1080TemperatureSensor = sensor.sensor_ns.class_( 'HDC1080TemperatureSensor', sensor.EmptyPollingParentSensor) HDC1080HumiditySensor = sensor.sensor_ns.class_( 'HDC1080HumiditySensor', sensor.EmptyPollingParentSensor) PLATFORM_SCHEMA = sensor.PLATFORM_SCHEMA.extend({ cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeHDC1080Sensor), cv.GenerateID(): cv.declare_variable_id(HDC1080Component), vol.Required(CONF_TEMPERATURE): cv.nameable( sensor.SENSOR_SCHEMA.extend({ cv.GenerateID(): cv.declare_variable_id(HDC1080TemperatureSensor), })), vol.Required(CONF_HUMIDITY):
import voluptuous as vol from esphomeyaml.components import i2c, sensor import esphomeyaml.config_validation as cv from esphomeyaml.const import CONF_HUMIDITY, CONF_MAKE_ID, CONF_NAME, CONF_TEMPERATURE, \ CONF_UPDATE_INTERVAL, CONF_ID from esphomeyaml.helpers import App, Application, PollingComponent, setup_component, variable, \ Pvariable DEPENDENCIES = ['i2c'] MakeHTU21DSensor = Application.struct('MakeHTU21DSensor') HTU21DComponent = sensor.sensor_ns.class_('HTU21DComponent', PollingComponent, i2c.I2CDevice) HTU21DTemperatureSensor = sensor.sensor_ns.class_( 'HTU21DTemperatureSensor', sensor.EmptyPollingParentSensor) HTU21DHumiditySensor = sensor.sensor_ns.class_('HTU21DHumiditySensor', sensor.EmptyPollingParentSensor) PLATFORM_SCHEMA = sensor.PLATFORM_SCHEMA.extend({ cv.GenerateID(): cv.declare_variable_id(HTU21DComponent), cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeHTU21DSensor), vol.Required(CONF_TEMPERATURE): cv.nameable( sensor.SENSOR_SCHEMA.extend({ cv.GenerateID(): cv.declare_variable_id(HTU21DTemperatureSensor), })), vol.Required(CONF_HUMIDITY):
import voluptuous as vol import esphomeyaml.config_validation as cv from esphomeyaml.components import switch from esphomeyaml.const import CONF_INVERTED, CONF_MAKE_ID, CONF_NAME from esphomeyaml.helpers import App, Application, variable MakeRestartSwitch = Application.struct('MakeRestartSwitch') RestartSwitch = switch.switch_ns.class_('RestartSwitch', switch.Switch) PLATFORM_SCHEMA = cv.nameable( switch.SWITCH_PLATFORM_SCHEMA.extend({ cv.GenerateID(): cv.declare_variable_id(RestartSwitch), cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeRestartSwitch), vol.Optional(CONF_INVERTED): cv.invalid("Restart switches do not support inverted mode!"), })) def to_code(config): rhs = App.make_restart_switch(config[CONF_NAME]) restart = variable(config[CONF_MAKE_ID], rhs) switch.setup_switch(restart.Prestart, restart.Pmqtt, config) BUILD_FLAGS = '-DUSE_RESTART_SWITCH' def to_hass_config(data, config):
import voluptuous as vol from esphomeyaml.components import sensor, time import esphomeyaml.config_validation as cv from esphomeyaml.const import CONF_MAKE_ID, CONF_NAME, CONF_TIME_ID from esphomeyaml.helpers import App, Application, Component, get_variable, setup_component, variable DEPENDENCIES = ['time'] CONF_POWER_ID = 'power_id' MakeTotalDailyEnergySensor = Application.struct('MakeTotalDailyEnergySensor') TotalDailyEnergy = sensor.sensor_ns.class_('TotalDailyEnergy', sensor.Sensor, Component) PLATFORM_SCHEMA = cv.nameable(sensor.SENSOR_PLATFORM_SCHEMA.extend({ cv.GenerateID(): cv.declare_variable_id(TotalDailyEnergy), cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeTotalDailyEnergySensor), cv.GenerateID(CONF_TIME_ID): cv.use_variable_id(time.RealTimeClockComponent), vol.Required(CONF_POWER_ID): cv.use_variable_id(sensor.Sensor), }).extend(cv.COMPONENT_SCHEMA.schema)) def to_code(config): for time_ in get_variable(config[CONF_TIME_ID]): yield for sens in get_variable(config[CONF_POWER_ID]): yield rhs = App.make_total_daily_energy_sensor(config[CONF_NAME], time_, sens) make = variable(config[CONF_MAKE_ID], rhs) total_energy = make.Ptotal_energy sensor.setup_sensor(total_energy, make.Pmqtt, config)
import voluptuous as vol 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, Application, HexIntLiteral, add, variable, setup_component DEPENDENCIES = ['i2c'] MakeBMP085Sensor = Application.struct('MakeBMP085Sensor') BMP085TemperatureSensor = sensor.sensor_ns.class_('BMP085TemperatureSensor', sensor.EmptyPollingParentSensor) BMP085PressureSensor = sensor.sensor_ns.class_('BMP085PressureSensor', sensor.EmptyPollingParentSensor) PLATFORM_SCHEMA = sensor.PLATFORM_SCHEMA.extend({ cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeBMP085Sensor), vol.Required(CONF_TEMPERATURE): cv.nameable(sensor.SENSOR_SCHEMA.extend({ cv.GenerateID(): cv.declare_variable_id(BMP085TemperatureSensor), })), vol.Required(CONF_PRESSURE): cv.nameable(sensor.SENSOR_SCHEMA.extend({ cv.GenerateID(): cv.declare_variable_id(BMP085PressureSensor), })), vol.Optional(CONF_ADDRESS): cv.i2c_address, vol.Optional(CONF_UPDATE_INTERVAL): cv.update_interval, }).extend(cv.COMPONENT_SCHEMA.schema) def to_code(config): rhs = App.make_bmp085_sensor(config[CONF_TEMPERATURE][CONF_NAME],
BME280IIRFilter = sensor.sensor_ns.enum('BME280IIRFilter') IIR_FILTER_OPTIONS = { 'OFF': BME280IIRFilter.BME280_IIR_FILTER_OFF, '2X': BME280IIRFilter.BME280_IIR_FILTER_2X, '4X': BME280IIRFilter.BME280_IIR_FILTER_4X, '8X': BME280IIRFilter.BME280_IIR_FILTER_8X, '16X': BME280IIRFilter.BME280_IIR_FILTER_16X, } BME280_OVERSAMPLING_SENSOR_SCHEMA = sensor.SENSOR_SCHEMA.extend({ vol.Optional(CONF_OVERSAMPLING): vol.All(vol.Upper, cv.one_of(*OVERSAMPLING_OPTIONS)), }) MakeBME280Sensor = Application.struct('MakeBME280Sensor') BME280TemperatureSensor = sensor.sensor_ns.class_( 'BME280TemperatureSensor', sensor.EmptyPollingParentSensor) BME280PressureSensor = sensor.sensor_ns.class_('BME280PressureSensor', sensor.EmptyPollingParentSensor) BME280HumiditySensor = sensor.sensor_ns.class_('BME280HumiditySensor', sensor.EmptyPollingParentSensor) PLATFORM_SCHEMA = sensor.PLATFORM_SCHEMA.extend({ cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeBME280Sensor), vol.Optional(CONF_ADDRESS, default=0x77): cv.i2c_address, vol.Required(CONF_TEMPERATURE): cv.nameable( BME280_OVERSAMPLING_SENSOR_SCHEMA.extend({
import esphomeyaml.config_validation as cv from esphomeyaml.components import sensor, i2c from esphomeyaml.const import CONF_ADDRESS, CONF_MAKE_ID, CONF_NAME, CONF_RESOLUTION, \ CONF_UPDATE_INTERVAL from esphomeyaml.helpers import App, Application, add, variable, setup_component DEPENDENCIES = ['i2c'] BH1750Resolution = sensor.sensor_ns.enum('BH1750Resolution') BH1750_RESOLUTIONS = { 4.0: BH1750Resolution.BH1750_RESOLUTION_4P0_LX, 1.0: BH1750Resolution.BH1750_RESOLUTION_1P0_LX, 0.5: BH1750Resolution.BH1750_RESOLUTION_0P5_LX, } MakeBH1750Sensor = Application.struct('MakeBH1750Sensor') BH1750Sensor = sensor.sensor_ns.class_('BH1750Sensor', sensor.PollingSensorComponent, i2c.I2CDevice) PLATFORM_SCHEMA = cv.nameable( sensor.SENSOR_PLATFORM_SCHEMA.extend({ cv.GenerateID(): cv.declare_variable_id(BH1750Sensor), 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):
import voluptuous as vol from esphomeyaml.components import i2c, sensor import esphomeyaml.config_validation as cv from esphomeyaml.const import CONF_ADDRESS, CONF_ID, CONF_MAKE_ID, CONF_NAME, CONF_PRESSURE, \ CONF_TEMPERATURE, CONF_UPDATE_INTERVAL from esphomeyaml.helpers import App, Application, PollingComponent, Pvariable, add, \ setup_component, \ variable DEPENDENCIES = ['i2c'] MakeMS5611Sensor = Application.struct('MakeMS5611Sensor') MS5611Component = sensor.sensor_ns.class_('MS5611Component', PollingComponent, i2c.I2CDevice) MS5611TemperatureSensor = sensor.sensor_ns.class_( 'MS5611TemperatureSensor', sensor.EmptyPollingParentSensor) MS5611PressureSensor = sensor.sensor_ns.class_('MS5611PressureSensor', sensor.EmptyPollingParentSensor) PLATFORM_SCHEMA = sensor.PLATFORM_SCHEMA.extend({ cv.GenerateID(): cv.declare_variable_id(MS5611Component), cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeMS5611Sensor), vol.Optional(CONF_ADDRESS): cv.i2c_address, vol.Required(CONF_TEMPERATURE): cv.nameable( sensor.SENSOR_SCHEMA.extend({ cv.GenerateID():
from esphomeyaml.components import text_sensor import esphomeyaml.config_validation as cv from esphomeyaml.const import CONF_MAKE_ID, CONF_NAME from esphomeyaml.helpers import App, Application, variable, setup_component, Component MakeVersionTextSensor = Application.struct('MakeVersionTextSensor') VersionTextSensor = text_sensor.text_sensor_ns.class_('VersionTextSensor', text_sensor.TextSensor, Component) PLATFORM_SCHEMA = cv.nameable( text_sensor.TEXT_SENSOR_PLATFORM_SCHEMA.extend({ cv.GenerateID(): cv.declare_variable_id(VersionTextSensor), cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeVersionTextSensor), }).extend(cv.COMPONENT_SCHEMA.schema)) def to_code(config): rhs = App.make_version_text_sensor(config[CONF_NAME]) make = variable(config[CONF_MAKE_ID], rhs) text_sensor.setup_text_sensor(make.Psensor, make.Pmqtt, config) setup_component(make.Psensor, config) BUILD_FLAGS = '-DUSE_VERSION_TEXT_SENSOR' def to_hass_config(data, config): return text_sensor.core_to_hass_config(data, config)
CONF_DEFAULT_TRANSITION_LENGTH, CONF_DURATION, CONF_EFFECTS, CONF_EFFECT_ID, \ CONF_GAMMA_CORRECT, CONF_GREEN, CONF_ID, CONF_INTERNAL, CONF_LAMBDA, CONF_MQTT_ID, CONF_NAME, \ CONF_NUM_LEDS, CONF_RANDOM, CONF_RED, CONF_SPEED, CONF_STATE, CONF_TRANSITION_LENGTH, \ CONF_UPDATE_INTERVAL, CONF_WHITE, CONF_WIDTH, CONF_FLASH_LENGTH, CONF_COLOR_TEMPERATURE, \ CONF_EFFECT from esphomeyaml.helpers import Application, ArrayInitializer, Pvariable, RawExpression, \ StructInitializer, add, add_job, esphomelib_ns, process_lambda, setup_mqtt_component, \ get_variable, TemplateArguments, templatable, uint32, float_, std_string, Nameable, Component, \ Action PLATFORM_SCHEMA = cv.PLATFORM_SCHEMA.extend({}) # Base light_ns = esphomelib_ns.namespace('light') LightState = light_ns.class_('LightState', Nameable, Component) MakeLight = Application.struct('MakeLight') LightOutput = light_ns.class_('LightOutput') FastLEDLightOutputComponent = light_ns.class_('FastLEDLightOutputComponent', LightOutput) # Actions ToggleAction = light_ns.class_('ToggleAction', Action) TurnOffAction = light_ns.class_('TurnOffAction', Action) TurnOnAction = light_ns.class_('TurnOnAction', Action) LightColorValues = light_ns.class_('LightColorValues') MQTTJSONLightComponent = light_ns.class_('MQTTJSONLightComponent', mqtt.MQTTComponent) # Effects
from esphomeyaml.const import CONF_MAKE_ID, CONF_NAME, CONF_RESOLUTION from esphomeyaml.helpers import App, Application, add, gpio_input_pin_expression, variable, \ setup_component, Component RotaryEncoderResolution = sensor.sensor_ns.enum('RotaryEncoderResolution') RESOLUTIONS = { '1': RotaryEncoderResolution.ROTARY_ENCODER_1_PULSE_PER_CYCLE, '2': RotaryEncoderResolution.ROTARY_ENCODER_2_PULSES_PER_CYCLE, '4': RotaryEncoderResolution.ROTARY_ENCODER_4_PULSES_PER_CYCLE, } CONF_PIN_A = 'pin_a' CONF_PIN_B = 'pin_b' CONF_PIN_RESET = 'pin_reset' MakeRotaryEncoderSensor = Application.struct('MakeRotaryEncoderSensor') RotaryEncoderSensor = sensor.sensor_ns.class_('RotaryEncoderSensor', sensor.Sensor, Component) PLATFORM_SCHEMA = cv.nameable( sensor.SENSOR_PLATFORM_SCHEMA.extend({ cv.GenerateID(): cv.declare_variable_id(RotaryEncoderSensor), cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeRotaryEncoderSensor), vol.Required(CONF_PIN_A): pins.internal_gpio_input_pin_schema, vol.Required(CONF_PIN_B): pins.internal_gpio_input_pin_schema, vol.Optional(CONF_PIN_RESET): pins.internal_gpio_input_pin_schema,
'P9813', 'APA102', 'SK9822', 'DOTSTAR', ] RGB_ORDERS = [ 'RGB', 'RBG', 'GRB', 'GBR', 'BRG', 'BGR', ] MakeFastLEDLight = Application.struct('MakeFastLEDLight') PLATFORM_SCHEMA = cv.nameable( light.LIGHT_PLATFORM_SCHEMA.extend({ cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeFastLEDLight), vol.Required(CONF_CHIPSET): vol.All(vol.Upper, cv.one_of(*CHIPSETS)), vol.Required(CONF_DATA_PIN): pins.output_pin, vol.Required(CONF_CLOCK_PIN): pins.output_pin, vol.Required(CONF_NUM_LEDS): cv.positive_not_null_int, vol.Optional(CONF_RGB_ORDER): vol.All(vol.Upper, cv.one_of(*RGB_ORDERS)),
import voluptuous as vol from esphomeyaml.components import output, switch import esphomeyaml.config_validation as cv from esphomeyaml.const import CONF_MAKE_ID, CONF_NAME, CONF_OUTPUT from esphomeyaml.helpers import App, Application, Component, get_variable, setup_component, variable MakeOutputSwitch = Application.struct('MakeOutputSwitch') OutputSwitch = switch.switch_ns.class_('OutputSwitch', switch.Switch, Component) PLATFORM_SCHEMA = cv.nameable( switch.SWITCH_PLATFORM_SCHEMA.extend({ cv.GenerateID(): cv.declare_variable_id(OutputSwitch), cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeOutputSwitch), vol.Required(CONF_OUTPUT): cv.use_variable_id(output.BinaryOutput), }).extend(cv.COMPONENT_SCHEMA.schema)) def to_code(config): for output_ in get_variable(config[CONF_OUTPUT]): yield rhs = App.make_output_switch(config[CONF_NAME], output_) make = variable(config[CONF_MAKE_ID], rhs) switch_ = make.Pswitch_ switch.setup_switch(switch_, make.Pmqtt, config) setup_component(switch, config)
import voluptuous as vol import esphomeyaml.config_validation as cv from esphomeyaml.components import switch, uart from esphomeyaml.components.uart import UARTComponent from esphomeyaml.const import CONF_DATA, CONF_INVERTED, CONF_MAKE_ID, CONF_NAME, CONF_UART_ID from esphomeyaml.core import HexInt from esphomeyaml.helpers import App, Application, ArrayInitializer, get_variable, variable DEPENDENCIES = ['uart'] MakeUARTSwitch = Application.struct('MakeUARTSwitch') UARTSwitch = switch.switch_ns.class_('UARTSwitch', switch.Switch, uart.UARTDevice) def validate_data(value): if isinstance(value, unicode): return value.encode('utf-8') elif isinstance(value, str): return value elif isinstance(value, list): return vol.Schema([cv.hex_uint8_t])(value) raise vol.Invalid( "data must either be a string wrapped in quotes or a list of bytes") PLATFORM_SCHEMA = cv.nameable( switch.SWITCH_PLATFORM_SCHEMA.extend({ cv.GenerateID(): cv.declare_variable_id(UARTSwitch),
import voluptuous as vol import esphomeyaml.config_validation as cv from esphomeyaml.components import sensor, i2c from esphomeyaml.const import CONF_HUMIDITY, CONF_MAKE_ID, CONF_NAME, CONF_TEMPERATURE, \ CONF_UPDATE_INTERVAL, CONF_ID from esphomeyaml.helpers import App, Application, variable, setup_component, PollingComponent, \ Pvariable DEPENDENCIES = ['i2c'] MakeDHT12Sensor = Application.struct('MakeDHT12Sensor') DHT12Component = sensor.sensor_ns.class_('DHT12Component', PollingComponent, i2c.I2CDevice) DHT12TemperatureSensor = sensor.sensor_ns.class_( 'DHT12TemperatureSensor', sensor.EmptyPollingParentSensor) DHT12HumiditySensor = sensor.sensor_ns.class_('DHT12HumiditySensor', sensor.EmptyPollingParentSensor) PLATFORM_SCHEMA = sensor.PLATFORM_SCHEMA.extend({ cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeDHT12Sensor), cv.GenerateID(): cv.declare_variable_id(DHT12Component), vol.Required(CONF_TEMPERATURE): cv.nameable( sensor.SENSOR_SCHEMA.extend({ cv.GenerateID(): cv.declare_variable_id(DHT12TemperatureSensor), })), vol.Required(CONF_HUMIDITY):
import voluptuous as vol import esphomeyaml.config_validation as cv from esphomeyaml import automation from esphomeyaml.components import switch from esphomeyaml.const import CONF_LAMBDA, CONF_MAKE_ID, CONF_NAME, CONF_TURN_OFF_ACTION, \ CONF_TURN_ON_ACTION, CONF_OPTIMISTIC, CONF_RESTORE_STATE from esphomeyaml.helpers import App, Application, process_lambda, variable, NoArg, add, bool_, \ optional, setup_component, Component MakeTemplateSwitch = Application.struct('MakeTemplateSwitch') TemplateSwitch = switch.switch_ns.class_('TemplateSwitch', switch.Switch, Component) PLATFORM_SCHEMA = cv.nameable( switch.SWITCH_PLATFORM_SCHEMA.extend({ cv.GenerateID(): cv.declare_variable_id(TemplateSwitch), cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeTemplateSwitch), vol.Optional(CONF_LAMBDA): cv.lambda_, vol.Optional(CONF_OPTIMISTIC): cv.boolean, vol.Optional(CONF_TURN_OFF_ACTION): automation.validate_automation(single=True), vol.Optional(CONF_TURN_ON_ACTION): automation.validate_automation(single=True), vol.Optional(CONF_RESTORE_STATE): cv.boolean, }).extend(cv.COMPONENT_SCHEMA.schema),
import voluptuous as vol from esphomeyaml import pins from esphomeyaml.components import switch import esphomeyaml.config_validation as cv from esphomeyaml.const import CONF_MAKE_ID, CONF_NAME, CONF_PIN from esphomeyaml.helpers import App, Application, gpio_output_pin_expression, variable, \ setup_component, Component MakeGPIOSwitch = Application.struct('MakeGPIOSwitch') GPIOSwitch = switch.switch_ns.class_('GPIOSwitch', switch.Switch, Component) PLATFORM_SCHEMA = cv.nameable(switch.SWITCH_PLATFORM_SCHEMA.extend({ cv.GenerateID(): cv.declare_variable_id(GPIOSwitch), cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeGPIOSwitch), vol.Required(CONF_PIN): pins.gpio_output_pin_schema, }).extend(cv.COMPONENT_SCHEMA.schema)) def to_code(config): for pin in gpio_output_pin_expression(config[CONF_PIN]): yield rhs = App.make_gpio_switch(config[CONF_NAME], pin) make = variable(config[CONF_MAKE_ID], rhs) gpio = make.Pswitch_ switch.setup_switch(gpio, make.Pmqtt, config) setup_component(gpio, config) BUILD_FLAGS = '-DUSE_GPIO_SWITCH'
import voluptuous as vol import esphomeyaml.config_validation as cv from esphomeyaml.components import sensor from esphomeyaml.const import CONF_LAMBDA, CONF_MAKE_ID, CONF_NAME, CONF_UPDATE_INTERVAL from esphomeyaml.helpers import App, process_lambda, variable, Application, float_, optional, add, \ setup_component MakeTemplateSensor = Application.struct('MakeTemplateSensor') TemplateSensor = sensor.sensor_ns.class_('TemplateSensor', sensor.PollingSensorComponent) PLATFORM_SCHEMA = cv.nameable( sensor.SENSOR_PLATFORM_SCHEMA.extend({ cv.GenerateID(): cv.declare_variable_id(TemplateSensor), cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeTemplateSensor), vol.Required(CONF_LAMBDA): cv.lambda_, vol.Optional(CONF_UPDATE_INTERVAL): cv.update_interval, }).extend(cv.COMPONENT_SCHEMA.schema)) def to_code(config): rhs = App.make_template_sensor(config[CONF_NAME], config.get(CONF_UPDATE_INTERVAL)) make = variable(config[CONF_MAKE_ID], rhs) template = make.Ptemplate_
import voluptuous as vol import esphomeyaml.config_validation as cv from esphomeyaml.components import switch from esphomeyaml.const import CONF_INVERTED, CONF_MAKE_ID, CONF_NAME from esphomeyaml.helpers import App, Application, variable MakeShutdownSwitch = Application.struct('MakeShutdownSwitch') ShutdownSwitch = switch.switch_ns.class_('ShutdownSwitch', switch.Switch) PLATFORM_SCHEMA = cv.nameable( switch.SWITCH_PLATFORM_SCHEMA.extend({ cv.GenerateID(): cv.declare_variable_id(ShutdownSwitch), cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeShutdownSwitch), vol.Optional(CONF_INVERTED): cv.invalid("Shutdown switches do not support inverted mode!"), })) def to_code(config): rhs = App.make_shutdown_switch(config[CONF_NAME]) shutdown = variable(config[CONF_MAKE_ID], rhs) switch.setup_switch(shutdown.Pshutdown, shutdown.Pmqtt, config) BUILD_FLAGS = '-DUSE_SHUTDOWN_SWITCH' def to_hass_config(data, config):
import voluptuous as vol import esphomeyaml.config_validation as cv from esphomeyaml import pins from esphomeyaml.components import sensor from esphomeyaml.const import CONF_ECHO_PIN, CONF_MAKE_ID, CONF_NAME, CONF_TIMEOUT_METER, \ CONF_TIMEOUT_TIME, CONF_TRIGGER_PIN, CONF_UPDATE_INTERVAL from esphomeyaml.helpers import App, Application, add, gpio_input_pin_expression, \ gpio_output_pin_expression, variable, setup_component MakeUltrasonicSensor = Application.struct('MakeUltrasonicSensor') UltrasonicSensorComponent = sensor.sensor_ns.class_( 'UltrasonicSensorComponent', sensor.PollingSensorComponent) PLATFORM_SCHEMA = cv.nameable( sensor.SENSOR_PLATFORM_SCHEMA.extend({ cv.GenerateID(): cv.declare_variable_id(UltrasonicSensorComponent), cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeUltrasonicSensor), vol.Required(CONF_TRIGGER_PIN): pins.gpio_output_pin_schema, 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.update_interval, }))