mirror of
https://github.com/esphome/esphome.git
synced 2024-11-25 08:28:12 +01:00
parent
7b26ecc0dc
commit
176c712eeb
66 changed files with 389 additions and 530 deletions
|
@ -223,7 +223,7 @@ def setup_filters(config):
|
|||
yield ArrayInitializer(*filters)
|
||||
|
||||
|
||||
def setup_binary_sensor_core_(binary_sensor_var, mqtt_var, config):
|
||||
def setup_binary_sensor_core_(binary_sensor_var, config):
|
||||
if CONF_INTERNAL in config:
|
||||
add(binary_sensor_var.set_internal(CONF_INTERNAL))
|
||||
if CONF_DEVICE_CLASS in config:
|
||||
|
@ -278,22 +278,19 @@ def setup_binary_sensor_core_(binary_sensor_var, mqtt_var, config):
|
|||
trigger = Pvariable(conf[CONF_TRIGGER_ID], rhs)
|
||||
automation.build_automation(trigger, bool_, conf)
|
||||
|
||||
setup_mqtt_component(mqtt_var, config)
|
||||
setup_mqtt_component(binary_sensor_var.Pget_mqtt(), config)
|
||||
|
||||
|
||||
def setup_binary_sensor(binary_sensor_obj, mqtt_obj, config):
|
||||
binary_sensor_var = Pvariable(config[CONF_ID], binary_sensor_obj,
|
||||
has_side_effects=False)
|
||||
mqtt_var = Pvariable(config[CONF_MQTT_ID], mqtt_obj,
|
||||
has_side_effects=False)
|
||||
CORE.add_job(setup_binary_sensor_core_, binary_sensor_var, mqtt_var, config)
|
||||
def setup_binary_sensor(binary_sensor_obj, config):
|
||||
if not CORE.has_id(config[CONF_ID]):
|
||||
binary_sensor_obj = Pvariable(config[CONF_ID], binary_sensor_obj, has_side_effects=True)
|
||||
CORE.add_job(setup_binary_sensor_core_, binary_sensor_obj, 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)
|
||||
CORE.add_job(setup_binary_sensor_core_, binary_sensor_var, mqtt_var, config)
|
||||
add(App.register_binary_sensor(binary_sensor_var))
|
||||
CORE.add_job(setup_binary_sensor_core_, binary_sensor_var, config)
|
||||
|
||||
|
||||
def core_to_hass_config(data, config):
|
||||
|
|
|
@ -19,7 +19,6 @@ PLATFORM_SCHEMA = cv.nameable(binary_sensor.BINARY_SENSOR_PLATFORM_SCHEMA.extend
|
|||
|
||||
|
||||
def to_code(config):
|
||||
hub = None
|
||||
for hub in get_variable(config[CONF_ESP32_BLE_ID]):
|
||||
yield
|
||||
rhs = hub.make_presence_sensor(config[CONF_NAME], make_address_array(config[CONF_MAC_ADDRESS]))
|
||||
|
|
|
@ -1,21 +1,19 @@
|
|||
import voluptuous as vol
|
||||
|
||||
import esphomeyaml.config_validation as cv
|
||||
from esphomeyaml import pins
|
||||
from esphomeyaml.components import binary_sensor
|
||||
from esphomeyaml.const import CONF_MAKE_ID, CONF_NAME, CONF_PIN
|
||||
from esphomeyaml.cpp_generator import variable
|
||||
import esphomeyaml.config_validation as cv
|
||||
from esphomeyaml.const import CONF_ID, CONF_NAME, CONF_PIN
|
||||
from esphomeyaml.cpp_generator import Pvariable
|
||||
from esphomeyaml.cpp_helpers import gpio_input_pin_expression, setup_component
|
||||
from esphomeyaml.cpp_types import Application, Component, App
|
||||
from esphomeyaml.cpp_types import App, Component
|
||||
|
||||
MakeGPIOBinarySensor = Application.struct('MakeGPIOBinarySensor')
|
||||
GPIOBinarySensorComponent = binary_sensor.binary_sensor_ns.class_('GPIOBinarySensorComponent',
|
||||
binary_sensor.BinarySensor,
|
||||
Component)
|
||||
|
||||
PLATFORM_SCHEMA = cv.nameable(binary_sensor.BINARY_SENSOR_PLATFORM_SCHEMA.extend({
|
||||
cv.GenerateID(): cv.declare_variable_id(GPIOBinarySensorComponent),
|
||||
cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeGPIOBinarySensor),
|
||||
vol.Required(CONF_PIN): pins.gpio_input_pin_schema
|
||||
}).extend(cv.COMPONENT_SCHEMA.schema))
|
||||
|
||||
|
@ -25,9 +23,9 @@ def to_code(config):
|
|||
for pin in gpio_input_pin_expression(config[CONF_PIN]):
|
||||
yield
|
||||
rhs = App.make_gpio_binary_sensor(config[CONF_NAME], pin)
|
||||
gpio = variable(config[CONF_MAKE_ID], rhs)
|
||||
binary_sensor.setup_binary_sensor(gpio.Pgpio, gpio.Pmqtt, config)
|
||||
setup_component(gpio.Pgpio, config)
|
||||
gpio = Pvariable(config[CONF_ID], rhs)
|
||||
binary_sensor.setup_binary_sensor(gpio, config)
|
||||
setup_component(gpio, config)
|
||||
|
||||
|
||||
BUILD_FLAGS = '-DUSE_GPIO_BINARY_SENSOR'
|
||||
|
|
|
@ -1,27 +1,24 @@
|
|||
import esphomeyaml.config_validation as cv
|
||||
from esphomeyaml.components import binary_sensor
|
||||
from esphomeyaml.const import CONF_MAKE_ID, CONF_NAME
|
||||
from esphomeyaml.cpp_generator import variable
|
||||
import esphomeyaml.config_validation as cv
|
||||
from esphomeyaml.const import CONF_ID, CONF_NAME
|
||||
from esphomeyaml.cpp_generator import Pvariable
|
||||
from esphomeyaml.cpp_helpers import setup_component
|
||||
from esphomeyaml.cpp_types import Application, Component, App
|
||||
from esphomeyaml.cpp_types import App, Component
|
||||
|
||||
|
||||
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)
|
||||
status = Pvariable(config[CONF_ID], rhs)
|
||||
binary_sensor.setup_binary_sensor(status, config)
|
||||
setup_component(status, config)
|
||||
|
||||
|
||||
BUILD_FLAGS = '-DUSE_STATUS_BINARY_SENSOR'
|
||||
|
|
|
@ -2,34 +2,31 @@ 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.cpp_generator import variable, process_lambda, add
|
||||
from esphomeyaml.const import CONF_ID, CONF_LAMBDA, CONF_NAME
|
||||
from esphomeyaml.cpp_generator import Pvariable, add, process_lambda
|
||||
from esphomeyaml.cpp_helpers import setup_component
|
||||
from esphomeyaml.cpp_types import Application, Component, App, optional, bool_
|
||||
from esphomeyaml.cpp_types import App, Component, bool_, optional
|
||||
|
||||
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)
|
||||
var = Pvariable(config[CONF_ID], rhs)
|
||||
binary_sensor.setup_binary_sensor(var, config)
|
||||
setup_component(var, config)
|
||||
|
||||
template_ = None
|
||||
for template_ in process_lambda(config[CONF_LAMBDA], [],
|
||||
return_type=optional.template(bool_)):
|
||||
yield
|
||||
add(make.Ptemplate_.set_template(template_))
|
||||
add(var.set_template(template_))
|
||||
|
||||
|
||||
BUILD_FLAGS = '-DUSE_TEMPLATE_BINARY_SENSOR'
|
||||
|
|
|
@ -5,6 +5,7 @@ from esphomeyaml.components import mqtt
|
|||
from esphomeyaml.components.mqtt import setup_mqtt_component
|
||||
import esphomeyaml.config_validation as cv
|
||||
from esphomeyaml.const import CONF_ID, CONF_INTERNAL, CONF_MQTT_ID
|
||||
from esphomeyaml.core import CORE
|
||||
from esphomeyaml.cpp_generator import Pvariable, add, get_variable
|
||||
from esphomeyaml.cpp_types import Action, Nameable, esphomelib_ns
|
||||
|
||||
|
@ -34,16 +35,14 @@ COVER_SCHEMA = cv.MQTT_COMMAND_COMPONENT_SCHEMA.extend({
|
|||
COVER_PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(COVER_SCHEMA.schema)
|
||||
|
||||
|
||||
def setup_cover_core_(cover_var, mqtt_var, config):
|
||||
def setup_cover_core_(cover_var, config):
|
||||
if CONF_INTERNAL in config:
|
||||
add(cover_var.set_internal(config[CONF_INTERNAL]))
|
||||
setup_mqtt_component(mqtt_var, config)
|
||||
setup_mqtt_component(cover_var.Pget_mqtt(), config)
|
||||
|
||||
|
||||
def setup_cover(cover_obj, mqtt_obj, config):
|
||||
cover_var = Pvariable(config[CONF_ID], cover_obj, has_side_effects=False)
|
||||
mqtt_var = Pvariable(config[CONF_MQTT_ID], mqtt_obj, has_side_effects=False)
|
||||
setup_cover_core_(cover_var, mqtt_var, config)
|
||||
def setup_cover(cover_obj, config):
|
||||
CORE.add_job(setup_cover_core_, cover_obj, config)
|
||||
|
||||
|
||||
BUILD_FLAGS = '-DUSE_COVER'
|
||||
|
|
|
@ -1,19 +1,17 @@
|
|||
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.cpp_generator import variable, process_lambda, add
|
||||
import esphomeyaml.config_validation as cv
|
||||
from esphomeyaml.const import CONF_CLOSE_ACTION, CONF_ID, CONF_LAMBDA, CONF_NAME, \
|
||||
CONF_OPEN_ACTION, CONF_OPTIMISTIC, CONF_STOP_ACTION
|
||||
from esphomeyaml.cpp_generator import Pvariable, add, process_lambda
|
||||
from esphomeyaml.cpp_helpers import setup_component
|
||||
from esphomeyaml.cpp_types import Application, App, optional, NoArg
|
||||
from esphomeyaml.cpp_types import App, NoArg, optional
|
||||
|
||||
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,
|
||||
|
@ -25,27 +23,27 @@ PLATFORM_SCHEMA = cv.nameable(cover.COVER_PLATFORM_SCHEMA.extend({
|
|||
|
||||
def to_code(config):
|
||||
rhs = App.make_template_cover(config[CONF_NAME])
|
||||
make = variable(config[CONF_MAKE_ID], rhs)
|
||||
var = Pvariable(config[CONF_ID], rhs)
|
||||
|
||||
cover.setup_cover(make.Ptemplate_, make.Pmqtt, config)
|
||||
setup_component(make.Ptemplate_, config)
|
||||
cover.setup_cover(var, config)
|
||||
setup_component(var, config)
|
||||
|
||||
if CONF_LAMBDA in config:
|
||||
for template_ in process_lambda(config[CONF_LAMBDA], [],
|
||||
return_type=optional.template(cover.CoverState)):
|
||||
yield
|
||||
add(make.Ptemplate_.set_state_lambda(template_))
|
||||
add(var.set_state_lambda(template_))
|
||||
if CONF_OPEN_ACTION in config:
|
||||
automation.build_automation(make.Ptemplate_.get_open_trigger(), NoArg,
|
||||
automation.build_automation(var.get_open_trigger(), NoArg,
|
||||
config[CONF_OPEN_ACTION])
|
||||
if CONF_CLOSE_ACTION in config:
|
||||
automation.build_automation(make.Ptemplate_.get_close_trigger(), NoArg,
|
||||
automation.build_automation(var.get_close_trigger(), NoArg,
|
||||
config[CONF_CLOSE_ACTION])
|
||||
if CONF_STOP_ACTION in config:
|
||||
automation.build_automation(make.Ptemplate_.get_stop_trigger(), NoArg,
|
||||
automation.build_automation(var.get_stop_trigger(), NoArg,
|
||||
config[CONF_STOP_ACTION])
|
||||
if CONF_OPTIMISTIC in config:
|
||||
add(make.Ptemplate_.set_optimistic(config[CONF_OPTIMISTIC]))
|
||||
add(var.set_optimistic(config[CONF_OPTIMISTIC]))
|
||||
|
||||
|
||||
BUILD_FLAGS = '-DUSE_TEMPLATE_COVER'
|
||||
|
|
|
@ -7,6 +7,7 @@ import esphomeyaml.config_validation as cv
|
|||
from esphomeyaml.const import CONF_ID, CONF_INTERNAL, CONF_MQTT_ID, CONF_NAME, CONF_OSCILLATING, \
|
||||
CONF_OSCILLATION_COMMAND_TOPIC, CONF_OSCILLATION_OUTPUT, CONF_OSCILLATION_STATE_TOPIC, \
|
||||
CONF_SPEED, CONF_SPEED_COMMAND_TOPIC, CONF_SPEED_STATE_TOPIC
|
||||
from esphomeyaml.core import CORE
|
||||
from esphomeyaml.cpp_generator import add, Pvariable, get_variable, templatable
|
||||
from esphomeyaml.cpp_types import Application, Component, Nameable, esphomelib_ns, Action, bool_
|
||||
|
||||
|
@ -49,25 +50,25 @@ FAN_SPEEDS = {
|
|||
}
|
||||
|
||||
|
||||
def setup_fan_core_(fan_var, mqtt_var, config):
|
||||
def setup_fan_core_(fan_var, config):
|
||||
if CONF_INTERNAL in config:
|
||||
add(fan_var.set_internal(config[CONF_INTERNAL]))
|
||||
|
||||
mqtt_ = fan_var.Pget_mqtt()
|
||||
if CONF_OSCILLATION_STATE_TOPIC in config:
|
||||
add(mqtt_var.set_custom_oscillation_state_topic(config[CONF_OSCILLATION_STATE_TOPIC]))
|
||||
add(mqtt_.set_custom_oscillation_state_topic(config[CONF_OSCILLATION_STATE_TOPIC]))
|
||||
if CONF_OSCILLATION_COMMAND_TOPIC in config:
|
||||
add(mqtt_var.set_custom_oscillation_command_topic(config[CONF_OSCILLATION_COMMAND_TOPIC]))
|
||||
add(mqtt_.set_custom_oscillation_command_topic(config[CONF_OSCILLATION_COMMAND_TOPIC]))
|
||||
if CONF_SPEED_STATE_TOPIC in config:
|
||||
add(mqtt_var.set_custom_speed_state_topic(config[CONF_SPEED_STATE_TOPIC]))
|
||||
add(mqtt_.set_custom_speed_state_topic(config[CONF_SPEED_STATE_TOPIC]))
|
||||
if CONF_SPEED_COMMAND_TOPIC in config:
|
||||
add(mqtt_var.set_custom_speed_command_topic(config[CONF_SPEED_COMMAND_TOPIC]))
|
||||
setup_mqtt_component(mqtt_var, config)
|
||||
add(mqtt_.set_custom_speed_command_topic(config[CONF_SPEED_COMMAND_TOPIC]))
|
||||
setup_mqtt_component(mqtt_, config)
|
||||
|
||||
|
||||
def setup_fan(fan_obj, mqtt_obj, config):
|
||||
def setup_fan(fan_obj, config):
|
||||
fan_var = Pvariable(config[CONF_ID], fan_obj, has_side_effects=False)
|
||||
mqtt_var = Pvariable(config[CONF_MQTT_ID], mqtt_obj, has_side_effects=False)
|
||||
setup_fan_core_(fan_var, mqtt_var, config)
|
||||
CORE.add_job(setup_fan_core_, fan_var, config)
|
||||
|
||||
|
||||
BUILD_FLAGS = '-DUSE_FAN'
|
||||
|
|
|
@ -26,7 +26,7 @@ def to_code(config):
|
|||
yield
|
||||
add(fan_struct.Poutput.set_oscillation(oscillation_output))
|
||||
|
||||
fan.setup_fan(fan_struct.Pstate, fan_struct.Pmqtt, config)
|
||||
fan.setup_fan(fan_struct.Pstate, config)
|
||||
setup_component(fan_struct.Poutput, config)
|
||||
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ def to_code(config):
|
|||
yield
|
||||
add(fan_struct.Poutput.set_oscillation(oscillation_output))
|
||||
|
||||
fan.setup_fan(fan_struct.Pstate, fan_struct.Pmqtt, config)
|
||||
fan.setup_fan(fan_struct.Pstate, config)
|
||||
|
||||
|
||||
def to_hass_config(data, config):
|
||||
|
|
|
@ -370,7 +370,7 @@ def build_effect(full_config):
|
|||
raise NotImplementedError("Effect {} not implemented".format(next(config.keys())))
|
||||
|
||||
|
||||
def setup_light_core_(light_var, mqtt_var, config):
|
||||
def setup_light_core_(light_var, config):
|
||||
if CONF_INTERNAL in config:
|
||||
add(light_var.set_internal(config[CONF_INTERNAL]))
|
||||
if CONF_DEFAULT_TRANSITION_LENGTH in config:
|
||||
|
@ -385,13 +385,12 @@ def setup_light_core_(light_var, mqtt_var, config):
|
|||
if effects:
|
||||
add(light_var.add_effects(ArrayInitializer(*effects)))
|
||||
|
||||
setup_mqtt_component(mqtt_var, config)
|
||||
setup_mqtt_component(light_var.Pget_mqtt(), config)
|
||||
|
||||
|
||||
def setup_light(light_obj, mqtt_obj, config):
|
||||
def setup_light(light_obj, config):
|
||||
light_var = Pvariable(config[CONF_ID], light_obj, has_side_effects=False)
|
||||
mqtt_var = Pvariable(config[CONF_MQTT_ID], mqtt_obj, has_side_effects=False)
|
||||
CORE.add_job(setup_light_core_, light_var, mqtt_var, config)
|
||||
CORE.add_job(setup_light_core_, light_var, config)
|
||||
|
||||
|
||||
BUILD_FLAGS = '-DUSE_LIGHT'
|
||||
|
|
|
@ -19,7 +19,7 @@ def to_code(config):
|
|||
yield
|
||||
rhs = App.make_binary_light(config[CONF_NAME], output_)
|
||||
light_struct = variable(config[CONF_MAKE_ID], rhs)
|
||||
light.setup_light(light_struct.Pstate, light_struct.Pmqtt, config)
|
||||
light.setup_light(light_struct.Pstate, config)
|
||||
setup_component(light_struct.Pstate, config)
|
||||
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ def to_code(config):
|
|||
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)
|
||||
light.setup_light(light_struct.Pstate, config)
|
||||
setup_component(light_struct.Pstate, config)
|
||||
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ def to_code(config):
|
|||
r, g, b = config[CONF_COLOR_CORRECT]
|
||||
add(fast_led.set_correction(r, g, b))
|
||||
|
||||
light.setup_light(make.Pstate, make.Pmqtt, config)
|
||||
light.setup_light(make.Pstate, config)
|
||||
setup_component(fast_led, config)
|
||||
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ def to_code(config):
|
|||
r, g, b = config[CONF_COLOR_CORRECT]
|
||||
add(fast_led.set_correction(r, g, b))
|
||||
|
||||
light.setup_light(make.Pstate, make.Pmqtt, config)
|
||||
light.setup_light(make.Pstate, config)
|
||||
setup_component(fast_led, config)
|
||||
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ def to_code(config):
|
|||
yield
|
||||
rhs = App.make_monochromatic_light(config[CONF_NAME], output_)
|
||||
light_struct = variable(config[CONF_MAKE_ID], rhs)
|
||||
light.setup_light(light_struct.Pstate, light_struct.Pmqtt, config)
|
||||
light.setup_light(light_struct.Pstate, config)
|
||||
setup_component(light_struct.Pstate, config)
|
||||
|
||||
|
||||
|
|
|
@ -156,7 +156,7 @@ def to_code(config):
|
|||
if CONF_COLOR_CORRECT in config:
|
||||
add(output.set_correction(*config[CONF_COLOR_CORRECT]))
|
||||
|
||||
light.setup_light(make.Pstate, make.Pmqtt, config)
|
||||
light.setup_light(make.Pstate, config)
|
||||
setup_component(output, config)
|
||||
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ def to_code(config):
|
|||
yield
|
||||
rhs = App.make_rgb_light(config[CONF_NAME], red, green, blue)
|
||||
light_struct = variable(config[CONF_MAKE_ID], rhs)
|
||||
light.setup_light(light_struct.Pstate, light_struct.Pmqtt, config)
|
||||
light.setup_light(light_struct.Pstate, config)
|
||||
setup_component(light_struct.Pstate, config)
|
||||
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ def to_code(config):
|
|||
yield
|
||||
rhs = App.make_rgbw_light(config[CONF_NAME], red, green, blue, white)
|
||||
light_struct = variable(config[CONF_MAKE_ID], rhs)
|
||||
light.setup_light(light_struct.Pstate, light_struct.Pmqtt, config)
|
||||
light.setup_light(light_struct.Pstate, config)
|
||||
setup_component(light_struct.Pstate, config)
|
||||
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ def to_code(config):
|
|||
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)
|
||||
light.setup_light(light_struct.Pstate, config)
|
||||
setup_component(light_struct.Pstate, config)
|
||||
|
||||
|
||||
|
|
|
@ -337,3 +337,7 @@ def setup_mqtt_component(obj, config):
|
|||
else:
|
||||
add(obj.set_availability(availability[CONF_TOPIC], availability[CONF_PAYLOAD_AVAILABLE],
|
||||
availability[CONF_PAYLOAD_NOT_AVAILABLE]))
|
||||
|
||||
|
||||
LIB_DEPS = 'AsyncMqttClient@0.8.2'
|
||||
REQUIRED_BUILD_FLAGS = '-DUSE_MQTT'
|
||||
|
|
|
@ -136,7 +136,6 @@ def setup_filter(config):
|
|||
conf = config[CONF_EXPONENTIAL_MOVING_AVERAGE]
|
||||
yield ExponentialMovingAverageFilter.new(conf[CONF_ALPHA], conf[CONF_SEND_EVERY])
|
||||
elif CONF_LAMBDA in config:
|
||||
lambda_ = None
|
||||
for lambda_ in process_lambda(config[CONF_LAMBDA], [(float_, 'x')],
|
||||
return_type=optional.template(float_)):
|
||||
yield None
|
||||
|
@ -146,7 +145,6 @@ def setup_filter(config):
|
|||
elif CONF_DELTA in config:
|
||||
yield DeltaFilter.new(config[CONF_DELTA])
|
||||
elif CONF_OR in config:
|
||||
filters = None
|
||||
for filters in setup_filters(config[CONF_OR]):
|
||||
yield None
|
||||
yield OrFilter.new(filters)
|
||||
|
@ -167,7 +165,7 @@ def setup_filters(config):
|
|||
yield ArrayInitializer(*filters)
|
||||
|
||||
|
||||
def setup_sensor_core_(sensor_var, mqtt_var, config):
|
||||
def setup_sensor_core_(sensor_var, config):
|
||||
if CONF_INTERNAL in config:
|
||||
add(sensor_var.set_internal(config[CONF_INTERNAL]))
|
||||
if CONF_UNIT_OF_MEASUREMENT in config:
|
||||
|
@ -203,25 +201,25 @@ def setup_sensor_core_(sensor_var, mqtt_var, config):
|
|||
add(trigger.set_max(template_))
|
||||
automation.build_automation(trigger, float_, conf)
|
||||
|
||||
mqtt_ = sensor_var.Pget_mqtt()
|
||||
if CONF_EXPIRE_AFTER in config:
|
||||
if config[CONF_EXPIRE_AFTER] is None:
|
||||
add(mqtt_var.disable_expire_after())
|
||||
add(mqtt_.disable_expire_after())
|
||||
else:
|
||||
add(mqtt_var.set_expire_after(config[CONF_EXPIRE_AFTER]))
|
||||
setup_mqtt_component(mqtt_var, config)
|
||||
add(mqtt_.set_expire_after(config[CONF_EXPIRE_AFTER]))
|
||||
setup_mqtt_component(mqtt_, 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)
|
||||
CORE.add_job(setup_sensor_core_, sensor_var, mqtt_var, config)
|
||||
def setup_sensor(sensor_obj, config):
|
||||
if not CORE.has_id(config[CONF_ID]):
|
||||
sensor_obj = Pvariable(config[CONF_ID], sensor_obj, has_side_effects=True)
|
||||
CORE.add_job(setup_sensor_core_, sensor_obj, 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)
|
||||
CORE.add_job(setup_sensor_core_, sensor_var, mqtt_var, config)
|
||||
add(App.register_sensor(sensor_var))
|
||||
CORE.add_job(setup_sensor_core_, sensor_var, config)
|
||||
|
||||
|
||||
BUILD_FLAGS = '-DUSE_SENSOR'
|
||||
|
|
|
@ -3,11 +3,10 @@ import voluptuous as vol
|
|||
from esphomeyaml import pins
|
||||
from esphomeyaml.components import sensor
|
||||
import esphomeyaml.config_validation as cv
|
||||
from esphomeyaml.const import CONF_ATTENUATION, CONF_MAKE_ID, CONF_NAME, CONF_PIN, \
|
||||
CONF_UPDATE_INTERVAL
|
||||
from esphomeyaml.cpp_generator import add, variable
|
||||
from esphomeyaml.const import CONF_ATTENUATION, CONF_ID, CONF_NAME, CONF_PIN, CONF_UPDATE_INTERVAL
|
||||
from esphomeyaml.cpp_generator import Pvariable, add
|
||||
from esphomeyaml.cpp_helpers import setup_component
|
||||
from esphomeyaml.cpp_types import App, Application, global_ns
|
||||
from esphomeyaml.cpp_types import App, global_ns
|
||||
|
||||
ATTENUATION_MODES = {
|
||||
'0db': global_ns.ADC_0db,
|
||||
|
@ -24,12 +23,10 @@ def validate_adc_pin(value):
|
|||
return pins.analog_pin(value)
|
||||
|
||||
|
||||
MakeADCSensor = Application.struct('MakeADCSensor')
|
||||
ADCSensorComponent = sensor.sensor_ns.class_('ADCSensorComponent', sensor.PollingSensorComponent)
|
||||
|
||||
PLATFORM_SCHEMA = cv.nameable(sensor.SENSOR_PLATFORM_SCHEMA.extend({
|
||||
cv.GenerateID(): cv.declare_variable_id(ADCSensorComponent),
|
||||
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,
|
||||
lower=True)),
|
||||
|
@ -43,11 +40,10 @@ def to_code(config):
|
|||
pin = 0
|
||||
rhs = App.make_adc_sensor(config[CONF_NAME], pin,
|
||||
config.get(CONF_UPDATE_INTERVAL))
|
||||
make = variable(config[CONF_MAKE_ID], rhs)
|
||||
adc = make.Padc
|
||||
adc = Pvariable(config[CONF_ID], rhs)
|
||||
if CONF_ATTENUATION in config:
|
||||
add(adc.set_attenuation(ATTENUATION_MODES[config[CONF_ATTENUATION]]))
|
||||
sensor.setup_sensor(adc, make.Pmqtt, config)
|
||||
sensor.setup_sensor(adc, config)
|
||||
setup_component(adc, config)
|
||||
|
||||
|
||||
|
|
|
@ -2,11 +2,11 @@ import voluptuous as vol
|
|||
|
||||
from esphomeyaml.components import i2c, sensor
|
||||
import esphomeyaml.config_validation as cv
|
||||
from esphomeyaml.const import CONF_ADDRESS, CONF_MAKE_ID, CONF_NAME, CONF_RESOLUTION, \
|
||||
from esphomeyaml.const import CONF_ADDRESS, CONF_ID, CONF_NAME, CONF_RESOLUTION, \
|
||||
CONF_UPDATE_INTERVAL
|
||||
from esphomeyaml.cpp_generator import add, variable
|
||||
from esphomeyaml.cpp_generator import Pvariable, add
|
||||
from esphomeyaml.cpp_helpers import setup_component
|
||||
from esphomeyaml.cpp_types import App, Application
|
||||
from esphomeyaml.cpp_types import App
|
||||
|
||||
DEPENDENCIES = ['i2c']
|
||||
|
||||
|
@ -17,13 +17,11 @@ BH1750_RESOLUTIONS = {
|
|||
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): cv.update_interval,
|
||||
|
@ -33,11 +31,10 @@ PLATFORM_SCHEMA = cv.nameable(sensor.SENSOR_PLATFORM_SCHEMA.extend({
|
|||
def to_code(config):
|
||||
rhs = App.make_bh1750_sensor(config[CONF_NAME], config[CONF_ADDRESS],
|
||||
config.get(CONF_UPDATE_INTERVAL))
|
||||
make_bh1750 = variable(config[CONF_MAKE_ID], rhs)
|
||||
bh1750 = make_bh1750.Pbh1750
|
||||
bh1750 = Pvariable(config[CONF_ID], rhs)
|
||||
if CONF_RESOLUTION in config:
|
||||
add(bh1750.set_resolution(BH1750_RESOLUTIONS[config[CONF_RESOLUTION]]))
|
||||
sensor.setup_sensor(bh1750, make_bh1750.Pmqtt, config)
|
||||
sensor.setup_sensor(bh1750, config)
|
||||
setup_component(bh1750, config)
|
||||
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import voluptuous as vol
|
||||
|
||||
from esphomeyaml.components import i2c, sensor
|
||||
import esphomeyaml.config_validation as cv
|
||||
from esphomeyaml.components import sensor
|
||||
from esphomeyaml.const import CONF_ADDRESS, CONF_HUMIDITY, CONF_IIR_FILTER, CONF_MAKE_ID, \
|
||||
CONF_NAME, CONF_OVERSAMPLING, CONF_PRESSURE, CONF_TEMPERATURE, CONF_UPDATE_INTERVAL
|
||||
from esphomeyaml.cpp_generator import variable, add
|
||||
from esphomeyaml.const import CONF_ADDRESS, CONF_HUMIDITY, CONF_ID, CONF_IIR_FILTER, CONF_NAME, \
|
||||
CONF_OVERSAMPLING, CONF_PRESSURE, CONF_TEMPERATURE, CONF_UPDATE_INTERVAL
|
||||
from esphomeyaml.cpp_generator import Pvariable, add
|
||||
from esphomeyaml.cpp_helpers import setup_component
|
||||
from esphomeyaml.cpp_types import Application, App
|
||||
from esphomeyaml.cpp_types import App, PollingComponent
|
||||
|
||||
DEPENDENCIES = ['i2c']
|
||||
|
||||
|
@ -33,7 +33,7 @@ BME280_OVERSAMPLING_SENSOR_SCHEMA = sensor.SENSOR_SCHEMA.extend({
|
|||
vol.Optional(CONF_OVERSAMPLING): cv.one_of(*OVERSAMPLING_OPTIONS, upper=True),
|
||||
})
|
||||
|
||||
MakeBME280Sensor = Application.struct('MakeBME280Sensor')
|
||||
BME280Component = sensor.sensor_ns.class_('BME280Component', PollingComponent, i2c.I2CDevice)
|
||||
BME280TemperatureSensor = sensor.sensor_ns.class_('BME280TemperatureSensor',
|
||||
sensor.EmptyPollingParentSensor)
|
||||
BME280PressureSensor = sensor.sensor_ns.class_('BME280PressureSensor',
|
||||
|
@ -42,7 +42,7 @@ BME280HumiditySensor = sensor.sensor_ns.class_('BME280HumiditySensor',
|
|||
sensor.EmptyPollingParentSensor)
|
||||
|
||||
PLATFORM_SCHEMA = sensor.PLATFORM_SCHEMA.extend({
|
||||
cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeBME280Sensor),
|
||||
cv.GenerateID(): cv.declare_variable_id(BME280Component),
|
||||
vol.Optional(CONF_ADDRESS, default=0x77): cv.i2c_address,
|
||||
vol.Required(CONF_TEMPERATURE): cv.nameable(BME280_OVERSAMPLING_SENSOR_SCHEMA.extend({
|
||||
cv.GenerateID(): cv.declare_variable_id(BME280TemperatureSensor),
|
||||
|
@ -64,8 +64,7 @@ def to_code(config):
|
|||
config[CONF_HUMIDITY][CONF_NAME],
|
||||
config[CONF_ADDRESS],
|
||||
config.get(CONF_UPDATE_INTERVAL))
|
||||
make = variable(config[CONF_MAKE_ID], rhs)
|
||||
bme280 = make.Pbme280
|
||||
bme280 = Pvariable(config[CONF_ID], rhs)
|
||||
if CONF_OVERSAMPLING in config[CONF_TEMPERATURE]:
|
||||
constant = OVERSAMPLING_OPTIONS[config[CONF_TEMPERATURE][CONF_OVERSAMPLING]]
|
||||
add(bme280.set_temperature_oversampling(constant))
|
||||
|
@ -79,12 +78,9 @@ def to_code(config):
|
|||
constant = IIR_FILTER_OPTIONS[config[CONF_IIR_FILTER]]
|
||||
add(bme280.set_iir_filter(constant))
|
||||
|
||||
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])
|
||||
sensor.setup_sensor(bme280.Pget_temperature_sensor(), config[CONF_TEMPERATURE])
|
||||
sensor.setup_sensor(bme280.Pget_pressure_sensor(), config[CONF_PRESSURE])
|
||||
sensor.setup_sensor(bme280.Pget_humidity_sensor(), config[CONF_HUMIDITY])
|
||||
setup_component(bme280, config)
|
||||
|
||||
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
import voluptuous as vol
|
||||
|
||||
import esphomeyaml.config_validation as cv
|
||||
from esphomeyaml import core
|
||||
from esphomeyaml.components import sensor
|
||||
from esphomeyaml.const import CONF_ADDRESS, CONF_GAS_RESISTANCE, CONF_HUMIDITY, CONF_IIR_FILTER, \
|
||||
CONF_MAKE_ID, CONF_NAME, CONF_OVERSAMPLING, CONF_PRESSURE, CONF_TEMPERATURE, \
|
||||
CONF_UPDATE_INTERVAL, CONF_HEATER, CONF_DURATION
|
||||
from esphomeyaml.cpp_generator import variable, add
|
||||
from esphomeyaml.components import i2c, sensor
|
||||
import esphomeyaml.config_validation as cv
|
||||
from esphomeyaml.const import CONF_ADDRESS, CONF_DURATION, CONF_GAS_RESISTANCE, CONF_HEATER, \
|
||||
CONF_HUMIDITY, CONF_ID, CONF_IIR_FILTER, CONF_NAME, CONF_OVERSAMPLING, CONF_PRESSURE, \
|
||||
CONF_TEMPERATURE, CONF_UPDATE_INTERVAL
|
||||
from esphomeyaml.cpp_generator import Pvariable, add
|
||||
from esphomeyaml.cpp_helpers import setup_component
|
||||
from esphomeyaml.cpp_types import Application, App
|
||||
from esphomeyaml.cpp_types import App, PollingComponent
|
||||
|
||||
DEPENDENCIES = ['i2c']
|
||||
|
||||
|
@ -38,7 +38,7 @@ BME680_OVERSAMPLING_SENSOR_SCHEMA = sensor.SENSOR_SCHEMA.extend({
|
|||
vol.Optional(CONF_OVERSAMPLING): cv.one_of(*OVERSAMPLING_OPTIONS, upper=True),
|
||||
})
|
||||
|
||||
MakeBME680Sensor = Application.struct('MakeBME680Sensor')
|
||||
BME680Component = sensor.sensor_ns.class_('BME680Component', PollingComponent, i2c.I2CDevice)
|
||||
BME680TemperatureSensor = sensor.sensor_ns.class_('BME680TemperatureSensor',
|
||||
sensor.EmptyPollingParentSensor)
|
||||
BME680PressureSensor = sensor.sensor_ns.class_('BME680PressureSensor',
|
||||
|
@ -49,7 +49,7 @@ BME680GasResistanceSensor = sensor.sensor_ns.class_('BME680GasResistanceSensor',
|
|||
sensor.EmptyPollingParentSensor)
|
||||
|
||||
PLATFORM_SCHEMA = sensor.PLATFORM_SCHEMA.extend({
|
||||
cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeBME680Sensor),
|
||||
cv.GenerateID(): cv.declare_variable_id(BME680Component),
|
||||
vol.Optional(CONF_ADDRESS, default=0x76): cv.i2c_address,
|
||||
vol.Required(CONF_TEMPERATURE): cv.nameable(BME680_OVERSAMPLING_SENSOR_SCHEMA.extend({
|
||||
cv.GenerateID(): cv.declare_variable_id(BME680TemperatureSensor),
|
||||
|
@ -80,8 +80,7 @@ def to_code(config):
|
|||
config[CONF_GAS_RESISTANCE][CONF_NAME],
|
||||
config[CONF_ADDRESS],
|
||||
config.get(CONF_UPDATE_INTERVAL))
|
||||
make = variable(config[CONF_MAKE_ID], rhs)
|
||||
bme680 = make.Pbme680
|
||||
bme680 = Pvariable(config[CONF_ID], rhs)
|
||||
if CONF_OVERSAMPLING in config[CONF_TEMPERATURE]:
|
||||
constant = OVERSAMPLING_OPTIONS[config[CONF_TEMPERATURE][CONF_OVERSAMPLING]]
|
||||
add(bme680.set_temperature_oversampling(constant))
|
||||
|
@ -101,14 +100,10 @@ def to_code(config):
|
|||
else:
|
||||
add(bme680.set_heater(conf[CONF_TEMPERATURE], conf[CONF_DURATION]))
|
||||
|
||||
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])
|
||||
sensor.setup_sensor(bme680.Pget_temperature_sensor(), config[CONF_TEMPERATURE])
|
||||
sensor.setup_sensor(bme680.Pget_pressure_sensor(), config[CONF_PRESSURE])
|
||||
sensor.setup_sensor(bme680.Pget_humidity_sensor(), config[CONF_HUMIDITY])
|
||||
sensor.setup_sensor(bme680.Pget_gas_resistance_sensor(), config[CONF_GAS_RESISTANCE])
|
||||
setup_component(bme680, config)
|
||||
|
||||
|
||||
|
|
|
@ -1,23 +1,23 @@
|
|||
import voluptuous as vol
|
||||
|
||||
from esphomeyaml.components import i2c, sensor
|
||||
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.cpp_generator import variable, add, HexIntLiteral
|
||||
from esphomeyaml.const import CONF_ADDRESS, CONF_ID, CONF_NAME, CONF_PRESSURE, CONF_TEMPERATURE, \
|
||||
CONF_UPDATE_INTERVAL
|
||||
from esphomeyaml.cpp_generator import HexIntLiteral, Pvariable, add
|
||||
from esphomeyaml.cpp_helpers import setup_component
|
||||
from esphomeyaml.cpp_types import Application, App
|
||||
from esphomeyaml.cpp_types import App, PollingComponent
|
||||
|
||||
DEPENDENCIES = ['i2c']
|
||||
|
||||
MakeBMP085Sensor = Application.struct('MakeBMP085Sensor')
|
||||
BMP085Component = sensor.sensor_ns.class_('BMP085Component', PollingComponent, i2c.I2CDevice)
|
||||
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),
|
||||
cv.GenerateID(): cv.declare_variable_id(BMP085Component),
|
||||
vol.Required(CONF_TEMPERATURE): cv.nameable(sensor.SENSOR_SCHEMA.extend({
|
||||
cv.GenerateID(): cv.declare_variable_id(BMP085TemperatureSensor),
|
||||
})),
|
||||
|
@ -33,15 +33,13 @@ def to_code(config):
|
|||
rhs = App.make_bmp085_sensor(config[CONF_TEMPERATURE][CONF_NAME],
|
||||
config[CONF_PRESSURE][CONF_NAME],
|
||||
config.get(CONF_UPDATE_INTERVAL))
|
||||
bmp = variable(config[CONF_MAKE_ID], rhs)
|
||||
bmp = Pvariable(config[CONF_ID], rhs)
|
||||
if CONF_ADDRESS in config:
|
||||
add(bmp.Pbmp.set_address(HexIntLiteral(config[CONF_ADDRESS])))
|
||||
add(bmp.set_address(HexIntLiteral(config[CONF_ADDRESS])))
|
||||
|
||||
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])
|
||||
setup_component(bmp.Pbmp, config)
|
||||
sensor.setup_sensor(bmp.Pget_temperature_sensor(), config[CONF_TEMPERATURE])
|
||||
sensor.setup_sensor(bmp.Pget_pressure_sensor(), config[CONF_PRESSURE])
|
||||
setup_component(bmp, config)
|
||||
|
||||
|
||||
BUILD_FLAGS = '-DUSE_BMP085_SENSOR'
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import voluptuous as vol
|
||||
|
||||
from esphomeyaml.components import sensor
|
||||
from esphomeyaml.components import i2c, sensor
|
||||
import esphomeyaml.config_validation as cv
|
||||
from esphomeyaml.const import CONF_ADDRESS, CONF_IIR_FILTER, CONF_MAKE_ID, \
|
||||
CONF_NAME, CONF_OVERSAMPLING, CONF_PRESSURE, CONF_TEMPERATURE, CONF_UPDATE_INTERVAL
|
||||
from esphomeyaml.cpp_generator import add, variable
|
||||
from esphomeyaml.const import CONF_ADDRESS, CONF_ID, CONF_IIR_FILTER, CONF_NAME, \
|
||||
CONF_OVERSAMPLING, CONF_PRESSURE, CONF_TEMPERATURE, CONF_UPDATE_INTERVAL
|
||||
from esphomeyaml.cpp_generator import Pvariable, add
|
||||
from esphomeyaml.cpp_helpers import setup_component
|
||||
from esphomeyaml.cpp_types import App, Application
|
||||
from esphomeyaml.cpp_types import App, PollingComponent
|
||||
|
||||
DEPENDENCIES = ['i2c']
|
||||
|
||||
|
@ -33,14 +33,14 @@ BMP280_OVERSAMPLING_SENSOR_SCHEMA = sensor.SENSOR_SCHEMA.extend({
|
|||
vol.Optional(CONF_OVERSAMPLING): cv.one_of(*OVERSAMPLING_OPTIONS, upper=True),
|
||||
})
|
||||
|
||||
MakeBMP280Sensor = Application.struct('MakeBMP280Sensor')
|
||||
BMP280Component = sensor.sensor_ns.class_('BMP280Component', PollingComponent, i2c.I2CDevice)
|
||||
BMP280TemperatureSensor = sensor.sensor_ns.class_('BMP280TemperatureSensor',
|
||||
sensor.EmptyPollingParentSensor)
|
||||
BMP280PressureSensor = sensor.sensor_ns.class_('BMP280PressureSensor',
|
||||
sensor.EmptyPollingParentSensor)
|
||||
|
||||
PLATFORM_SCHEMA = sensor.PLATFORM_SCHEMA.extend({
|
||||
cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeBMP280Sensor),
|
||||
cv.GenerateID(): cv.declare_variable_id(BMP280Component),
|
||||
vol.Optional(CONF_ADDRESS, default=0x77): cv.i2c_address,
|
||||
vol.Required(CONF_TEMPERATURE): cv.nameable(BMP280_OVERSAMPLING_SENSOR_SCHEMA.extend({
|
||||
cv.GenerateID(): cv.declare_variable_id(BMP280TemperatureSensor),
|
||||
|
@ -58,8 +58,7 @@ def to_code(config):
|
|||
config[CONF_PRESSURE][CONF_NAME],
|
||||
config[CONF_ADDRESS],
|
||||
config.get(CONF_UPDATE_INTERVAL))
|
||||
make = variable(config[CONF_MAKE_ID], rhs)
|
||||
bmp280 = make.Pbmp280
|
||||
bmp280 = Pvariable(config[CONF_ID], rhs)
|
||||
if CONF_OVERSAMPLING in config[CONF_TEMPERATURE]:
|
||||
constant = OVERSAMPLING_OPTIONS[config[CONF_TEMPERATURE][CONF_OVERSAMPLING]]
|
||||
add(bmp280.set_temperature_oversampling(constant))
|
||||
|
@ -70,10 +69,8 @@ def to_code(config):
|
|||
constant = IIR_FILTER_OPTIONS[config[CONF_IIR_FILTER]]
|
||||
add(bmp280.set_iir_filter(constant))
|
||||
|
||||
sensor.setup_sensor(bmp280.Pget_temperature_sensor(), make.Pmqtt_temperature,
|
||||
config[CONF_TEMPERATURE])
|
||||
sensor.setup_sensor(bmp280.Pget_pressure_sensor(), make.Pmqtt_pressure,
|
||||
config[CONF_PRESSURE])
|
||||
sensor.setup_sensor(bmp280.Pget_temperature_sensor(), config[CONF_TEMPERATURE])
|
||||
sensor.setup_sensor(bmp280.Pget_pressure_sensor(), config[CONF_PRESSURE])
|
||||
setup_component(bmp280, config)
|
||||
|
||||
|
||||
|
|
|
@ -2,11 +2,11 @@ import voluptuous as vol
|
|||
|
||||
from esphomeyaml.components import sensor
|
||||
import esphomeyaml.config_validation as cv
|
||||
from esphomeyaml.const import CONF_HUMIDITY, CONF_ID, CONF_MAKE_ID, CONF_MODEL, CONF_NAME, \
|
||||
from esphomeyaml.const import CONF_HUMIDITY, CONF_ID, CONF_MODEL, CONF_NAME, \
|
||||
CONF_PIN, CONF_TEMPERATURE, CONF_UPDATE_INTERVAL
|
||||
from esphomeyaml.cpp_generator import Pvariable, add, variable
|
||||
from esphomeyaml.cpp_generator import Pvariable, add
|
||||
from esphomeyaml.cpp_helpers import gpio_output_pin_expression, setup_component
|
||||
from esphomeyaml.cpp_types import App, Application, PollingComponent
|
||||
from esphomeyaml.cpp_types import App, PollingComponent
|
||||
from esphomeyaml.pins import gpio_input_pullup_pin_schema
|
||||
|
||||
DHTModel = sensor.sensor_ns.enum('DHTModel')
|
||||
|
@ -19,7 +19,6 @@ DHT_MODELS = {
|
|||
'SI7021': DHTModel.DHT_MODEL_SI7021,
|
||||
}
|
||||
|
||||
MakeDHTSensor = Application.struct('MakeDHTSensor')
|
||||
DHTComponent = sensor.sensor_ns.class_('DHTComponent', PollingComponent)
|
||||
DHTTemperatureSensor = sensor.sensor_ns.class_('DHTTemperatureSensor',
|
||||
sensor.EmptyPollingParentSensor)
|
||||
|
@ -27,7 +26,6 @@ DHTHumiditySensor = sensor.sensor_ns.class_('DHTHumiditySensor',
|
|||
sensor.EmptyPollingParentSensor)
|
||||
|
||||
PLATFORM_SCHEMA = sensor.PLATFORM_SCHEMA.extend({
|
||||
cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeDHTSensor),
|
||||
cv.GenerateID(): cv.declare_variable_id(DHTComponent),
|
||||
vol.Required(CONF_PIN): gpio_input_pullup_pin_schema,
|
||||
vol.Required(CONF_TEMPERATURE): cv.nameable(sensor.SENSOR_SCHEMA.extend({
|
||||
|
@ -47,18 +45,14 @@ def to_code(config):
|
|||
rhs = App.make_dht_sensor(config[CONF_TEMPERATURE][CONF_NAME],
|
||||
config[CONF_HUMIDITY][CONF_NAME],
|
||||
pin, config.get(CONF_UPDATE_INTERVAL))
|
||||
make = variable(config[CONF_MAKE_ID], rhs)
|
||||
dht = make.Pdht
|
||||
Pvariable(config[CONF_ID], dht)
|
||||
dht = Pvariable(config[CONF_ID], rhs)
|
||||
|
||||
if CONF_MODEL in config:
|
||||
constant = DHT_MODELS[config[CONF_MODEL]]
|
||||
add(dht.set_dht_model(constant))
|
||||
|
||||
sensor.setup_sensor(dht.Pget_temperature_sensor(),
|
||||
make.Pmqtt_temperature, config[CONF_TEMPERATURE])
|
||||
sensor.setup_sensor(dht.Pget_humidity_sensor(),
|
||||
make.Pmqtt_humidity, config[CONF_HUMIDITY])
|
||||
sensor.setup_sensor(dht.Pget_temperature_sensor(), config[CONF_TEMPERATURE])
|
||||
sensor.setup_sensor(dht.Pget_humidity_sensor(), config[CONF_HUMIDITY])
|
||||
setup_component(dht, config)
|
||||
|
||||
|
||||
|
|
|
@ -2,15 +2,14 @@ import voluptuous as vol
|
|||
|
||||
from esphomeyaml.components import i2c, sensor
|
||||
import esphomeyaml.config_validation as cv
|
||||
from esphomeyaml.const import CONF_HUMIDITY, CONF_ID, CONF_MAKE_ID, CONF_NAME, CONF_TEMPERATURE, \
|
||||
from esphomeyaml.const import CONF_HUMIDITY, CONF_ID, CONF_NAME, CONF_TEMPERATURE, \
|
||||
CONF_UPDATE_INTERVAL
|
||||
from esphomeyaml.cpp_generator import Pvariable, variable
|
||||
from esphomeyaml.cpp_generator import Pvariable
|
||||
from esphomeyaml.cpp_helpers import setup_component
|
||||
from esphomeyaml.cpp_types import App, Application, PollingComponent
|
||||
from esphomeyaml.cpp_types import App, PollingComponent
|
||||
|
||||
DEPENDENCIES = ['i2c']
|
||||
|
||||
MakeDHT12Sensor = Application.struct('MakeDHT12Sensor')
|
||||
DHT12Component = sensor.sensor_ns.class_('DHT12Component', PollingComponent, i2c.I2CDevice)
|
||||
DHT12TemperatureSensor = sensor.sensor_ns.class_('DHT12TemperatureSensor',
|
||||
sensor.EmptyPollingParentSensor)
|
||||
|
@ -18,7 +17,6 @@ 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),
|
||||
|
@ -34,14 +32,10 @@ def to_code(config):
|
|||
rhs = App.make_dht12_sensor(config[CONF_TEMPERATURE][CONF_NAME],
|
||||
config[CONF_HUMIDITY][CONF_NAME],
|
||||
config.get(CONF_UPDATE_INTERVAL))
|
||||
make = variable(config[CONF_MAKE_ID], rhs)
|
||||
dht = make.Pdht12
|
||||
Pvariable(config[CONF_ID], dht)
|
||||
dht = Pvariable(config[CONF_ID], rhs)
|
||||
|
||||
sensor.setup_sensor(dht.Pget_temperature_sensor(), make.Pmqtt_temperature,
|
||||
config[CONF_TEMPERATURE])
|
||||
sensor.setup_sensor(dht.Pget_humidity_sensor(), make.Pmqtt_humidity,
|
||||
config[CONF_HUMIDITY])
|
||||
sensor.setup_sensor(dht.Pget_temperature_sensor(), config[CONF_TEMPERATURE])
|
||||
sensor.setup_sensor(dht.Pget_humidity_sensor(), config[CONF_HUMIDITY])
|
||||
setup_component(dht, config)
|
||||
|
||||
|
||||
|
|
|
@ -3,17 +3,15 @@ import voluptuous as vol
|
|||
from esphomeyaml import pins
|
||||
from esphomeyaml.components import sensor
|
||||
import esphomeyaml.config_validation as cv
|
||||
from esphomeyaml.const import CONF_MAKE_ID, CONF_NAME, CONF_PIN, CONF_UPDATE_INTERVAL
|
||||
from esphomeyaml.cpp_generator import variable
|
||||
from esphomeyaml.const import CONF_ID, CONF_NAME, CONF_PIN, CONF_UPDATE_INTERVAL
|
||||
from esphomeyaml.cpp_generator import Pvariable
|
||||
from esphomeyaml.cpp_helpers import gpio_input_pin_expression, setup_component
|
||||
from esphomeyaml.cpp_types import App, Application
|
||||
from esphomeyaml.cpp_types import App
|
||||
|
||||
MakeDutyCycleSensor = Application.struct('MakeDutyCycleSensor')
|
||||
DutyCycleSensor = sensor.sensor_ns.class_('DutyCycleSensor', sensor.PollingSensorComponent)
|
||||
|
||||
PLATFORM_SCHEMA = cv.nameable(sensor.SENSOR_PLATFORM_SCHEMA.extend({
|
||||
cv.GenerateID(): cv.declare_variable_id(DutyCycleSensor),
|
||||
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.update_interval,
|
||||
}).extend(cv.COMPONENT_SCHEMA.schema))
|
||||
|
@ -24,9 +22,9 @@ def to_code(config):
|
|||
yield
|
||||
rhs = App.make_duty_cycle_sensor(config[CONF_NAME], pin,
|
||||
config.get(CONF_UPDATE_INTERVAL))
|
||||
make = variable(config[CONF_MAKE_ID], rhs)
|
||||
sensor.setup_sensor(make.Pduty, make.Pmqtt, config)
|
||||
setup_component(make.Pduty, config)
|
||||
duty = Pvariable(config[CONF_ID], rhs)
|
||||
sensor.setup_sensor(duty, config)
|
||||
setup_component(duty, config)
|
||||
|
||||
|
||||
BUILD_FLAGS = '-DUSE_DUTY_CYCLE_SENSOR'
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
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.cpp_generator import variable
|
||||
import esphomeyaml.config_validation as cv
|
||||
from esphomeyaml.const import CONF_ID, CONF_NAME, CONF_UPDATE_INTERVAL, ESP_PLATFORM_ESP32
|
||||
from esphomeyaml.cpp_generator import Pvariable
|
||||
from esphomeyaml.cpp_helpers import setup_component
|
||||
from esphomeyaml.cpp_types import Application, App
|
||||
from esphomeyaml.cpp_types import App, Application
|
||||
|
||||
ESP_PLATFORMS = [ESP_PLATFORM_ESP32]
|
||||
|
||||
|
@ -14,16 +14,15 @@ ESP32HallSensor = sensor.sensor_ns.class_('ESP32HallSensor', sensor.PollingSenso
|
|||
|
||||
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)
|
||||
hall = Pvariable(config[CONF_ID], rhs)
|
||||
sensor.setup_sensor(hall, config)
|
||||
setup_component(hall, config)
|
||||
|
||||
|
||||
BUILD_FLAGS = '-DUSE_ESP32_HALL_SENSOR'
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
import voluptuous as vol
|
||||
|
||||
from esphomeyaml.components import i2c, sensor
|
||||
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.cpp_generator import variable, Pvariable
|
||||
from esphomeyaml.const import CONF_HUMIDITY, CONF_ID, CONF_NAME, CONF_TEMPERATURE, \
|
||||
CONF_UPDATE_INTERVAL
|
||||
from esphomeyaml.cpp_generator import Pvariable
|
||||
from esphomeyaml.cpp_helpers import setup_component
|
||||
from esphomeyaml.cpp_types import Application, PollingComponent, App
|
||||
from esphomeyaml.cpp_types import App, PollingComponent
|
||||
|
||||
DEPENDENCIES = ['i2c']
|
||||
|
||||
MakeHDC1080Sensor = Application.struct('MakeHDC1080Sensor')
|
||||
HDC1080Component = sensor.sensor_ns.class_('HDC1080Component', PollingComponent, i2c.I2CDevice)
|
||||
HDC1080TemperatureSensor = sensor.sensor_ns.class_('HDC1080TemperatureSensor',
|
||||
sensor.EmptyPollingParentSensor)
|
||||
|
@ -18,7 +17,6 @@ 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),
|
||||
|
@ -34,15 +32,10 @@ def to_code(config):
|
|||
rhs = App.make_hdc1080_sensor(config[CONF_TEMPERATURE][CONF_NAME],
|
||||
config[CONF_HUMIDITY][CONF_NAME],
|
||||
config.get(CONF_UPDATE_INTERVAL))
|
||||
make = variable(config[CONF_MAKE_ID], rhs)
|
||||
hdc1080 = make.Phdc1080
|
||||
Pvariable(config[CONF_ID], hdc1080)
|
||||
hdc1080 = Pvariable(config[CONF_ID], rhs)
|
||||
|
||||
sensor.setup_sensor(hdc1080.Pget_temperature_sensor(),
|
||||
make.Pmqtt_temperature,
|
||||
config[CONF_TEMPERATURE])
|
||||
sensor.setup_sensor(hdc1080.Pget_humidity_sensor(), make.Pmqtt_humidity,
|
||||
config[CONF_HUMIDITY])
|
||||
sensor.setup_sensor(hdc1080.Pget_temperature_sensor(), config[CONF_TEMPERATURE])
|
||||
sensor.setup_sensor(hdc1080.Pget_humidity_sensor(), config[CONF_HUMIDITY])
|
||||
setup_component(hdc1080, config)
|
||||
|
||||
|
||||
|
|
|
@ -2,27 +2,24 @@ import voluptuous as vol
|
|||
|
||||
from esphomeyaml.components import sensor
|
||||
import esphomeyaml.config_validation as cv
|
||||
from esphomeyaml.const import CONF_ENTITY_ID, CONF_MAKE_ID, CONF_NAME
|
||||
from esphomeyaml.cpp_generator import variable
|
||||
from esphomeyaml.cpp_types import App, Application
|
||||
from esphomeyaml.const import CONF_ENTITY_ID, CONF_ID, CONF_NAME
|
||||
from esphomeyaml.cpp_generator import Pvariable
|
||||
from esphomeyaml.cpp_types import App
|
||||
|
||||
DEPENDENCIES = ['api']
|
||||
|
||||
MakeHomeassistantSensor = Application.struct('MakeHomeassistantSensor')
|
||||
HomeassistantSensor = sensor.sensor_ns.class_('HomeassistantSensor', sensor.Sensor)
|
||||
|
||||
PLATFORM_SCHEMA = cv.nameable(sensor.SENSOR_PLATFORM_SCHEMA.extend({
|
||||
cv.GenerateID(): cv.declare_variable_id(HomeassistantSensor),
|
||||
cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeHomeassistantSensor),
|
||||
vol.Required(CONF_ENTITY_ID): cv.entity_id,
|
||||
}))
|
||||
|
||||
|
||||
def to_code(config):
|
||||
rhs = App.make_homeassistant_sensor(config[CONF_NAME], config[CONF_ENTITY_ID])
|
||||
make = variable(config[CONF_MAKE_ID], rhs)
|
||||
subs = make.Psensor
|
||||
sensor.setup_sensor(subs, make.Pmqtt, config)
|
||||
subs = Pvariable(config[CONF_ID], rhs)
|
||||
sensor.setup_sensor(subs, config)
|
||||
|
||||
|
||||
BUILD_FLAGS = '-DUSE_HOMEASSISTANT_SENSOR'
|
||||
|
|
|
@ -2,11 +2,11 @@ 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.cpp_generator import variable, Pvariable
|
||||
from esphomeyaml.const import CONF_HUMIDITY, CONF_ID, CONF_NAME, CONF_TEMPERATURE, \
|
||||
CONF_UPDATE_INTERVAL
|
||||
from esphomeyaml.cpp_generator import Pvariable
|
||||
from esphomeyaml.cpp_helpers import setup_component
|
||||
from esphomeyaml.cpp_types import Application, PollingComponent, App
|
||||
from esphomeyaml.cpp_types import App, Application, PollingComponent
|
||||
|
||||
DEPENDENCIES = ['i2c']
|
||||
|
||||
|
@ -19,7 +19,6 @@ HTU21DHumiditySensor = sensor.sensor_ns.class_('HTU21DHumiditySensor',
|
|||
|
||||
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),
|
||||
})),
|
||||
|
@ -34,14 +33,10 @@ def to_code(config):
|
|||
rhs = App.make_htu21d_sensor(config[CONF_TEMPERATURE][CONF_NAME],
|
||||
config[CONF_HUMIDITY][CONF_NAME],
|
||||
config.get(CONF_UPDATE_INTERVAL))
|
||||
make = variable(config[CONF_MAKE_ID], rhs)
|
||||
htu21d = make.Phtu21d
|
||||
Pvariable(config[CONF_ID], htu21d)
|
||||
htu21d = Pvariable(config[CONF_ID], rhs)
|
||||
|
||||
sensor.setup_sensor(htu21d.Pget_temperature_sensor(), make.Pmqtt_temperature,
|
||||
config[CONF_TEMPERATURE])
|
||||
sensor.setup_sensor(htu21d.Pget_humidity_sensor(), make.Pmqtt_humidity,
|
||||
config[CONF_HUMIDITY])
|
||||
sensor.setup_sensor(htu21d.Pget_temperature_sensor(), config[CONF_TEMPERATURE])
|
||||
sensor.setup_sensor(htu21d.Pget_humidity_sensor(), config[CONF_HUMIDITY])
|
||||
setup_component(htu21d, config)
|
||||
|
||||
|
||||
|
|
|
@ -3,8 +3,8 @@ import voluptuous as vol
|
|||
from esphomeyaml import pins
|
||||
from esphomeyaml.components import sensor
|
||||
import esphomeyaml.config_validation as cv
|
||||
from esphomeyaml.const import CONF_CLK_PIN, CONF_GAIN, CONF_MAKE_ID, CONF_NAME, CONF_UPDATE_INTERVAL
|
||||
from esphomeyaml.cpp_generator import add, variable
|
||||
from esphomeyaml.const import CONF_CLK_PIN, CONF_GAIN, CONF_ID, CONF_NAME, CONF_UPDATE_INTERVAL
|
||||
from esphomeyaml.cpp_generator import Pvariable, add
|
||||
from esphomeyaml.cpp_helpers import gpio_input_pin_expression, setup_component
|
||||
from esphomeyaml.cpp_types import App, Application
|
||||
|
||||
|
@ -22,7 +22,6 @@ GAINS = {
|
|||
|
||||
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): pins.gpio_output_pin_schema,
|
||||
vol.Optional(CONF_GAIN): cv.one_of(*GAINS, int=True),
|
||||
|
@ -38,13 +37,12 @@ def to_code(config):
|
|||
|
||||
rhs = App.make_hx711_sensor(config[CONF_NAME], dout_pin, sck_pin,
|
||||
config.get(CONF_UPDATE_INTERVAL))
|
||||
make = variable(config[CONF_MAKE_ID], rhs)
|
||||
hx711 = make.Phx711
|
||||
hx711 = Pvariable(config[CONF_ID], rhs)
|
||||
|
||||
if CONF_GAIN in config:
|
||||
add(hx711.set_gain(GAINS[config[CONF_GAIN]]))
|
||||
|
||||
sensor.setup_sensor(hx711, make.Pmqtt, config)
|
||||
sensor.setup_sensor(hx711, config)
|
||||
setup_component(hx711, config)
|
||||
|
||||
|
||||
|
|
|
@ -1,22 +1,19 @@
|
|||
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
|
||||
import esphomeyaml.config_validation as cv
|
||||
from esphomeyaml.const import CONF_CS_PIN, CONF_ID, CONF_NAME, CONF_SPI_ID, CONF_UPDATE_INTERVAL
|
||||
from esphomeyaml.cpp_generator import Pvariable, get_variable
|
||||
from esphomeyaml.cpp_helpers import gpio_output_pin_expression, setup_component
|
||||
from esphomeyaml.cpp_generator import get_variable, variable
|
||||
from esphomeyaml.cpp_types import Application, App
|
||||
from esphomeyaml.cpp_types import App
|
||||
|
||||
MakeMAX31855Sensor = Application.struct('MakeMAX31855Sensor')
|
||||
MAX31855Sensor = sensor.sensor_ns.class_('MAX31855Sensor', sensor.PollingSensorComponent,
|
||||
spi.SPIDevice)
|
||||
|
||||
PLATFORM_SCHEMA = cv.nameable(sensor.SENSOR_PLATFORM_SCHEMA.extend({
|
||||
cv.GenerateID(): cv.declare_variable_id(MAX31855Sensor),
|
||||
cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeMAX31855Sensor),
|
||||
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,
|
||||
|
@ -30,9 +27,8 @@ def to_code(config):
|
|||
yield
|
||||
rhs = App.make_max31855_sensor(config[CONF_NAME], spi_, cs,
|
||||
config.get(CONF_UPDATE_INTERVAL))
|
||||
make = variable(config[CONF_MAKE_ID], rhs)
|
||||
max31855 = make.Pmax31855
|
||||
sensor.setup_sensor(max31855, make.Pmqtt, config)
|
||||
max31855 = Pvariable(config[CONF_ID], rhs)
|
||||
sensor.setup_sensor(max31855, config)
|
||||
setup_component(max31855, config)
|
||||
|
||||
|
||||
|
|
|
@ -4,19 +4,17 @@ from esphomeyaml import pins
|
|||
from esphomeyaml.components import sensor, spi
|
||||
from esphomeyaml.components.spi import SPIComponent
|
||||
import esphomeyaml.config_validation as cv
|
||||
from esphomeyaml.const import CONF_CS_PIN, CONF_MAKE_ID, CONF_NAME, CONF_SPI_ID, \
|
||||
from esphomeyaml.const import CONF_CS_PIN, CONF_ID, CONF_NAME, CONF_SPI_ID, \
|
||||
CONF_UPDATE_INTERVAL
|
||||
from esphomeyaml.cpp_generator import get_variable, variable
|
||||
from esphomeyaml.cpp_generator import Pvariable, get_variable
|
||||
from esphomeyaml.cpp_helpers import gpio_output_pin_expression, setup_component
|
||||
from esphomeyaml.cpp_types import App, Application
|
||||
from esphomeyaml.cpp_types import App
|
||||
|
||||
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,
|
||||
|
@ -30,9 +28,8 @@ def to_code(config):
|
|||
yield
|
||||
rhs = App.make_max6675_sensor(config[CONF_NAME], spi_, cs,
|
||||
config.get(CONF_UPDATE_INTERVAL))
|
||||
make = variable(config[CONF_MAKE_ID], rhs)
|
||||
max6675 = make.Pmax6675
|
||||
sensor.setup_sensor(max6675, make.Pmqtt, config)
|
||||
max6675 = Pvariable(config[CONF_ID], rhs)
|
||||
sensor.setup_sensor(max6675, config)
|
||||
setup_component(max6675, config)
|
||||
|
||||
|
||||
|
|
|
@ -3,15 +3,14 @@ import voluptuous as vol
|
|||
from esphomeyaml.components import sensor, uart
|
||||
from esphomeyaml.components.uart import UARTComponent
|
||||
import esphomeyaml.config_validation as cv
|
||||
from esphomeyaml.const import CONF_CO2, CONF_MAKE_ID, CONF_NAME, CONF_TEMPERATURE, CONF_UART_ID, \
|
||||
CONF_UPDATE_INTERVAL, CONF_ID
|
||||
from esphomeyaml.cpp_generator import get_variable, variable, Pvariable
|
||||
from esphomeyaml.const import CONF_CO2, CONF_ID, CONF_NAME, CONF_TEMPERATURE, CONF_UART_ID, \
|
||||
CONF_UPDATE_INTERVAL
|
||||
from esphomeyaml.cpp_generator import Pvariable, get_variable
|
||||
from esphomeyaml.cpp_helpers import setup_component
|
||||
from esphomeyaml.cpp_types import Application, PollingComponent, App
|
||||
from esphomeyaml.cpp_types import App, PollingComponent
|
||||
|
||||
DEPENDENCIES = ['uart']
|
||||
|
||||
MakeMHZ19Sensor = Application.struct('MakeMHZ19Sensor')
|
||||
MHZ19Component = sensor.sensor_ns.class_('MHZ19Component', PollingComponent, uart.UARTDevice)
|
||||
MHZ19TemperatureSensor = sensor.sensor_ns.class_('MHZ19TemperatureSensor',
|
||||
sensor.EmptyPollingParentSensor)
|
||||
|
@ -19,7 +18,6 @@ MHZ19CO2Sensor = sensor.sensor_ns.class_('MHZ19CO2Sensor', sensor.EmptyPollingPa
|
|||
|
||||
PLATFORM_SCHEMA = sensor.PLATFORM_SCHEMA.extend({
|
||||
cv.GenerateID(): cv.declare_variable_id(MHZ19Component),
|
||||
cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeMHZ19Sensor),
|
||||
cv.GenerateID(CONF_UART_ID): cv.use_variable_id(UARTComponent),
|
||||
vol.Required(CONF_CO2): cv.nameable(sensor.SENSOR_SCHEMA.extend({
|
||||
cv.GenerateID(): cv.declare_variable_id(MHZ19CO2Sensor),
|
||||
|
@ -36,10 +34,8 @@ def to_code(config):
|
|||
yield
|
||||
rhs = App.make_mhz19_sensor(uart_, config[CONF_CO2][CONF_NAME],
|
||||
config.get(CONF_UPDATE_INTERVAL))
|
||||
make = variable(config[CONF_MAKE_ID], rhs)
|
||||
mhz19 = make.Pmhz19
|
||||
Pvariable(config[CONF_ID], mhz19)
|
||||
sensor.setup_sensor(mhz19.Pget_co2_sensor(), make.Pmqtt, config[CONF_CO2])
|
||||
mhz19 = Pvariable(config[CONF_ID], rhs)
|
||||
sensor.setup_sensor(mhz19.Pget_co2_sensor(), config[CONF_CO2])
|
||||
|
||||
if CONF_TEMPERATURE in config:
|
||||
sensor.register_sensor(mhz19.Pmake_temperature_sensor(config[CONF_TEMPERATURE][CONF_NAME]),
|
||||
|
|
|
@ -2,19 +2,17 @@ import voluptuous as vol
|
|||
|
||||
from esphomeyaml.components import sensor
|
||||
import esphomeyaml.config_validation as cv
|
||||
from esphomeyaml.const import CONF_MAKE_ID, CONF_NAME, CONF_QOS, CONF_TOPIC
|
||||
from esphomeyaml.cpp_generator import add, variable
|
||||
from esphomeyaml.const import CONF_ID, CONF_NAME, CONF_QOS, CONF_TOPIC
|
||||
from esphomeyaml.cpp_generator import Pvariable, add
|
||||
from esphomeyaml.cpp_helpers import setup_component
|
||||
from esphomeyaml.cpp_types import App, Application, Component
|
||||
from esphomeyaml.cpp_types import App, Component
|
||||
|
||||
DEPENDENCIES = ['mqtt']
|
||||
|
||||
MakeMQTTSubscribeSensor = Application.struct('MakeMQTTSubscribeSensor')
|
||||
MQTTSubscribeSensor = sensor.sensor_ns.class_('MQTTSubscribeSensor', sensor.Sensor, Component)
|
||||
|
||||
PLATFORM_SCHEMA = cv.nameable(sensor.SENSOR_PLATFORM_SCHEMA.extend({
|
||||
cv.GenerateID(): cv.declare_variable_id(MQTTSubscribeSensor),
|
||||
cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeMQTTSubscribeSensor),
|
||||
vol.Required(CONF_TOPIC): cv.subscribe_topic,
|
||||
vol.Optional(CONF_QOS): cv.mqtt_qos,
|
||||
}).extend(cv.COMPONENT_SCHEMA.schema))
|
||||
|
@ -22,13 +20,12 @@ PLATFORM_SCHEMA = cv.nameable(sensor.SENSOR_PLATFORM_SCHEMA.extend({
|
|||
|
||||
def to_code(config):
|
||||
rhs = App.make_mqtt_subscribe_sensor(config[CONF_NAME], config[CONF_TOPIC])
|
||||
make = variable(config[CONF_MAKE_ID], rhs)
|
||||
subs = make.Psensor
|
||||
subs = Pvariable(config[CONF_ID], rhs)
|
||||
|
||||
if CONF_QOS in config:
|
||||
add(subs.set_qos(config[CONF_QOS]))
|
||||
|
||||
sensor.setup_sensor(subs, make.Pmqtt, config)
|
||||
sensor.setup_sensor(subs, config)
|
||||
setup_component(subs, config)
|
||||
|
||||
|
||||
|
|
|
@ -2,15 +2,14 @@ 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, \
|
||||
from esphomeyaml.const import CONF_ADDRESS, CONF_ID, CONF_NAME, CONF_PRESSURE, \
|
||||
CONF_TEMPERATURE, CONF_UPDATE_INTERVAL
|
||||
from esphomeyaml.cpp_generator import Pvariable, add, variable
|
||||
from esphomeyaml.cpp_generator import Pvariable, add
|
||||
from esphomeyaml.cpp_helpers import setup_component
|
||||
from esphomeyaml.cpp_types import App, Application, PollingComponent
|
||||
from esphomeyaml.cpp_types import App, PollingComponent
|
||||
|
||||
DEPENDENCIES = ['i2c']
|
||||
|
||||
MakeMS5611Sensor = Application.struct('MakeMS5611Sensor')
|
||||
MS5611Component = sensor.sensor_ns.class_('MS5611Component', PollingComponent, i2c.I2CDevice)
|
||||
MS5611TemperatureSensor = sensor.sensor_ns.class_('MS5611TemperatureSensor',
|
||||
sensor.EmptyPollingParentSensor)
|
||||
|
@ -19,7 +18,6 @@ MS5611PressureSensor = sensor.sensor_ns.class_('MS5611PressureSensor',
|
|||
|
||||
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(): cv.declare_variable_id(MS5611TemperatureSensor),
|
||||
|
@ -35,17 +33,13 @@ def to_code(config):
|
|||
rhs = App.make_ms5611_sensor(config[CONF_TEMPERATURE][CONF_NAME],
|
||||
config[CONF_PRESSURE][CONF_NAME],
|
||||
config.get(CONF_UPDATE_INTERVAL))
|
||||
make = variable(config[CONF_MAKE_ID], rhs)
|
||||
ms5611 = make.Pms5611
|
||||
Pvariable(config[CONF_ID], ms5611)
|
||||
ms5611 = Pvariable(config[CONF_ID], rhs)
|
||||
|
||||
if CONF_ADDRESS in config:
|
||||
add(ms5611.set_address(config[CONF_ADDRESS]))
|
||||
|
||||
sensor.setup_sensor(ms5611.Pget_temperature_sensor(), make.Pmqtt_temperature,
|
||||
config[CONF_TEMPERATURE])
|
||||
sensor.setup_sensor(ms5611.Pget_pressure_sensor(), make.Pmqtt_pressure,
|
||||
config[CONF_PRESSURE])
|
||||
sensor.setup_sensor(ms5611.Pget_temperature_sensor(), config[CONF_TEMPERATURE])
|
||||
sensor.setup_sensor(ms5611.Pget_pressure_sensor(), config[CONF_PRESSURE])
|
||||
setup_component(ms5611, config)
|
||||
|
||||
|
||||
|
|
|
@ -3,12 +3,12 @@ import voluptuous as vol
|
|||
from esphomeyaml import pins
|
||||
from esphomeyaml.components import sensor
|
||||
import esphomeyaml.config_validation as cv
|
||||
from esphomeyaml.const import CONF_COUNT_MODE, CONF_FALLING_EDGE, CONF_INTERNAL_FILTER, \
|
||||
CONF_MAKE_ID, CONF_NAME, CONF_PIN, CONF_RISING_EDGE, CONF_UPDATE_INTERVAL
|
||||
from esphomeyaml.const import CONF_COUNT_MODE, CONF_FALLING_EDGE, CONF_ID, CONF_INTERNAL_FILTER, \
|
||||
CONF_NAME, CONF_PIN, CONF_RISING_EDGE, CONF_UPDATE_INTERVAL
|
||||
from esphomeyaml.core import CORE
|
||||
from esphomeyaml.cpp_generator import add, variable
|
||||
from esphomeyaml.cpp_generator import Pvariable, add
|
||||
from esphomeyaml.cpp_helpers import gpio_input_pin_expression, setup_component
|
||||
from esphomeyaml.cpp_types import App, Application
|
||||
from esphomeyaml.cpp_types import App
|
||||
|
||||
PulseCounterCountMode = sensor.sensor_ns.enum('PulseCounterCountMode')
|
||||
COUNT_MODES = {
|
||||
|
@ -20,7 +20,6 @@ COUNT_MODES = {
|
|||
COUNT_MODE_SCHEMA = cv.one_of(*COUNT_MODES, upper=True)
|
||||
|
||||
PulseCounterBase = sensor.sensor_ns.class_('PulseCounterBase')
|
||||
MakePulseCounterSensor = Application.struct('MakePulseCounterSensor')
|
||||
PulseCounterSensorComponent = sensor.sensor_ns.class_('PulseCounterSensorComponent',
|
||||
sensor.PollingSensorComponent,
|
||||
PulseCounterBase)
|
||||
|
@ -41,7 +40,6 @@ def validate_internal_filter(value):
|
|||
|
||||
PLATFORM_SCHEMA = cv.nameable(sensor.SENSOR_PLATFORM_SCHEMA.extend({
|
||||
cv.GenerateID(): cv.declare_variable_id(PulseCounterSensorComponent),
|
||||
cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakePulseCounterSensor),
|
||||
vol.Required(CONF_PIN): pins.internal_gpio_input_pin_schema,
|
||||
vol.Optional(CONF_COUNT_MODE): vol.Schema({
|
||||
vol.Required(CONF_RISING_EDGE): COUNT_MODE_SCHEMA,
|
||||
|
@ -57,8 +55,7 @@ def to_code(config):
|
|||
yield
|
||||
rhs = App.make_pulse_counter_sensor(config[CONF_NAME], pin,
|
||||
config.get(CONF_UPDATE_INTERVAL))
|
||||
make = variable(config[CONF_MAKE_ID], rhs)
|
||||
pcnt = make.Ppcnt
|
||||
pcnt = Pvariable(config[CONF_ID], rhs)
|
||||
|
||||
if CONF_COUNT_MODE in config:
|
||||
rising_edge = COUNT_MODES[config[CONF_COUNT_MODE][CONF_RISING_EDGE]]
|
||||
|
@ -67,7 +64,7 @@ def to_code(config):
|
|||
if CONF_INTERNAL_FILTER in config:
|
||||
add(pcnt.set_filter_us(config[CONF_INTERNAL_FILTER]))
|
||||
|
||||
sensor.setup_sensor(pcnt, make.Pmqtt, config)
|
||||
sensor.setup_sensor(pcnt, config)
|
||||
setup_component(pcnt, config)
|
||||
|
||||
|
||||
|
|
|
@ -3,10 +3,10 @@ import voluptuous as vol
|
|||
from esphomeyaml import pins
|
||||
from esphomeyaml.components import sensor
|
||||
import esphomeyaml.config_validation as cv
|
||||
from esphomeyaml.const import CONF_MAKE_ID, CONF_NAME, CONF_RESOLUTION
|
||||
from esphomeyaml.cpp_generator import add, variable
|
||||
from esphomeyaml.const import CONF_ID, CONF_NAME, CONF_RESOLUTION
|
||||
from esphomeyaml.cpp_generator import Pvariable, add
|
||||
from esphomeyaml.cpp_helpers import gpio_input_pin_expression, setup_component
|
||||
from esphomeyaml.cpp_types import App, Application, Component
|
||||
from esphomeyaml.cpp_types import App, Component
|
||||
|
||||
RotaryEncoderResolution = sensor.sensor_ns.enum('RotaryEncoderResolution')
|
||||
RESOLUTIONS = {
|
||||
|
@ -19,12 +19,10 @@ 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,
|
||||
|
@ -38,11 +36,9 @@ def to_code(config):
|
|||
for pin_b in gpio_input_pin_expression(config[CONF_PIN_B]):
|
||||
yield
|
||||
rhs = App.make_rotary_encoder_sensor(config[CONF_NAME], pin_a, pin_b)
|
||||
make = variable(config[CONF_MAKE_ID], rhs)
|
||||
encoder = make.Protary_encoder
|
||||
encoder = Pvariable(config[CONF_ID], rhs)
|
||||
|
||||
if CONF_PIN_RESET in config:
|
||||
pin_i = None
|
||||
for pin_i in gpio_input_pin_expression(config[CONF_PIN_RESET]):
|
||||
yield
|
||||
add(encoder.set_reset_pin(pin_i))
|
||||
|
@ -50,7 +46,7 @@ def to_code(config):
|
|||
resolution = RESOLUTIONS[config[CONF_RESOLUTION]]
|
||||
add(encoder.set_resolution(resolution))
|
||||
|
||||
sensor.setup_sensor(encoder, make.Pmqtt, config)
|
||||
sensor.setup_sensor(encoder, config)
|
||||
setup_component(encoder, config)
|
||||
|
||||
|
||||
|
|
|
@ -2,15 +2,14 @@ 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_ID, CONF_MAKE_ID, CONF_NAME, \
|
||||
from esphomeyaml.const import CONF_ADDRESS, CONF_HUMIDITY, CONF_ID, CONF_NAME, \
|
||||
CONF_TEMPERATURE, CONF_UPDATE_INTERVAL
|
||||
from esphomeyaml.cpp_generator import Pvariable, variable
|
||||
from esphomeyaml.cpp_generator import Pvariable
|
||||
from esphomeyaml.cpp_helpers import setup_component
|
||||
from esphomeyaml.cpp_types import App, Application, PollingComponent
|
||||
from esphomeyaml.cpp_types import App, PollingComponent
|
||||
|
||||
DEPENDENCIES = ['i2c']
|
||||
|
||||
MakeSHT3XDSensor = Application.struct('MakeSHT3XDSensor')
|
||||
SHT3XDComponent = sensor.sensor_ns.class_('SHT3XDComponent', PollingComponent, i2c.I2CDevice)
|
||||
SHT3XDTemperatureSensor = sensor.sensor_ns.class_('SHT3XDTemperatureSensor',
|
||||
sensor.EmptyPollingParentSensor)
|
||||
|
@ -19,7 +18,6 @@ SHT3XDHumiditySensor = sensor.sensor_ns.class_('SHT3XDHumiditySensor',
|
|||
|
||||
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),
|
||||
})),
|
||||
|
@ -36,14 +34,10 @@ def to_code(config):
|
|||
config[CONF_HUMIDITY][CONF_NAME],
|
||||
config[CONF_ADDRESS],
|
||||
config.get(CONF_UPDATE_INTERVAL))
|
||||
make = variable(config[CONF_MAKE_ID], rhs)
|
||||
sht3xd = make.Psht3xd
|
||||
Pvariable(config[CONF_ID], sht3xd)
|
||||
sht3xd = Pvariable(config[CONF_ID], rhs)
|
||||
|
||||
sensor.setup_sensor(sht3xd.Pget_temperature_sensor(), make.Pmqtt_temperature,
|
||||
config[CONF_TEMPERATURE])
|
||||
sensor.setup_sensor(sht3xd.Pget_humidity_sensor(), make.Pmqtt_humidity,
|
||||
config[CONF_HUMIDITY])
|
||||
sensor.setup_sensor(sht3xd.Pget_temperature_sensor(), config[CONF_TEMPERATURE])
|
||||
sensor.setup_sensor(sht3xd.Pget_humidity_sensor(), config[CONF_HUMIDITY])
|
||||
setup_component(sht3xd, config)
|
||||
|
||||
|
||||
|
|
|
@ -2,17 +2,15 @@ import voluptuous as vol
|
|||
|
||||
from esphomeyaml.components import sensor
|
||||
import esphomeyaml.config_validation as cv
|
||||
from esphomeyaml.const import CONF_LAMBDA, CONF_MAKE_ID, CONF_NAME, CONF_UPDATE_INTERVAL
|
||||
from esphomeyaml.cpp_generator import add, process_lambda, variable
|
||||
from esphomeyaml.const import CONF_ID, CONF_LAMBDA, CONF_NAME, CONF_UPDATE_INTERVAL
|
||||
from esphomeyaml.cpp_generator import Pvariable, add, process_lambda
|
||||
from esphomeyaml.cpp_helpers import setup_component
|
||||
from esphomeyaml.cpp_types import App, Application, float_, optional
|
||||
from esphomeyaml.cpp_types import App, float_, optional
|
||||
|
||||
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))
|
||||
|
@ -20,10 +18,9 @@ PLATFORM_SCHEMA = cv.nameable(sensor.SENSOR_PLATFORM_SCHEMA.extend({
|
|||
|
||||
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_
|
||||
template = Pvariable(config[CONF_ID], rhs)
|
||||
|
||||
sensor.setup_sensor(template, make.Pmqtt, config)
|
||||
sensor.setup_sensor(template, config)
|
||||
setup_component(template, config)
|
||||
|
||||
for template_ in process_lambda(config[CONF_LAMBDA], [],
|
||||
|
|
|
@ -2,20 +2,18 @@ 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.cpp_generator import get_variable, variable
|
||||
from esphomeyaml.const import CONF_ID, CONF_NAME, CONF_TIME_ID
|
||||
from esphomeyaml.cpp_generator import Pvariable, get_variable
|
||||
from esphomeyaml.cpp_helpers import setup_component
|
||||
from esphomeyaml.cpp_types import Application, Component, App
|
||||
from esphomeyaml.cpp_types import App, Component
|
||||
|
||||
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))
|
||||
|
@ -27,10 +25,9 @@ def to_code(config):
|
|||
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
|
||||
total_energy = Pvariable(config[CONF_ID], rhs)
|
||||
|
||||
sensor.setup_sensor(total_energy, make.Pmqtt, config)
|
||||
sensor.setup_sensor(total_energy, config)
|
||||
setup_component(total_energy, config)
|
||||
|
||||
|
||||
|
|
|
@ -2,11 +2,11 @@ import voluptuous as vol
|
|||
|
||||
from esphomeyaml.components import i2c, sensor
|
||||
import esphomeyaml.config_validation as cv
|
||||
from esphomeyaml.const import CONF_ADDRESS, CONF_GAIN, CONF_INTEGRATION_TIME, CONF_MAKE_ID, \
|
||||
CONF_NAME, CONF_UPDATE_INTERVAL
|
||||
from esphomeyaml.cpp_generator import add, variable
|
||||
from esphomeyaml.const import CONF_ADDRESS, CONF_GAIN, CONF_ID, CONF_INTEGRATION_TIME, CONF_NAME, \
|
||||
CONF_UPDATE_INTERVAL
|
||||
from esphomeyaml.cpp_generator import Pvariable, add
|
||||
from esphomeyaml.cpp_helpers import setup_component
|
||||
from esphomeyaml.cpp_types import App, Application
|
||||
from esphomeyaml.cpp_types import App
|
||||
|
||||
DEPENDENCIES = ['i2c']
|
||||
|
||||
|
@ -33,13 +33,11 @@ def validate_integration_time(value):
|
|||
return value
|
||||
|
||||
|
||||
MakeTSL2561Sensor = Application.struct('MakeTSL2561Sensor')
|
||||
TSL2561Sensor = sensor.sensor_ns.class_('TSL2561Sensor', sensor.PollingSensorComponent,
|
||||
i2c.I2CDevice)
|
||||
|
||||
PLATFORM_SCHEMA = cv.nameable(sensor.SENSOR_PLATFORM_SCHEMA.extend({
|
||||
cv.GenerateID(): cv.declare_variable_id(TSL2561Sensor),
|
||||
cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeTSL2561Sensor),
|
||||
vol.Optional(CONF_ADDRESS, default=0x39): cv.i2c_address,
|
||||
vol.Optional(CONF_INTEGRATION_TIME): validate_integration_time,
|
||||
vol.Optional(CONF_GAIN): cv.one_of(*GAINS, upper=True),
|
||||
|
@ -51,8 +49,7 @@ PLATFORM_SCHEMA = cv.nameable(sensor.SENSOR_PLATFORM_SCHEMA.extend({
|
|||
def to_code(config):
|
||||
rhs = App.make_tsl2561_sensor(config[CONF_NAME], config[CONF_ADDRESS],
|
||||
config.get(CONF_UPDATE_INTERVAL))
|
||||
make_tsl = variable(config[CONF_MAKE_ID], rhs)
|
||||
tsl2561 = make_tsl.Ptsl2561
|
||||
tsl2561 = Pvariable(config[CONF_ID], rhs)
|
||||
|
||||
if CONF_INTEGRATION_TIME in config:
|
||||
add(tsl2561.set_integration_time(INTEGRATION_TIMES[config[CONF_INTEGRATION_TIME]]))
|
||||
|
@ -61,7 +58,7 @@ def to_code(config):
|
|||
if CONF_IS_CS_PACKAGE in config:
|
||||
add(tsl2561.set_is_cs_package(config[CONF_IS_CS_PACKAGE]))
|
||||
|
||||
sensor.setup_sensor(tsl2561, make_tsl.Pmqtt, config)
|
||||
sensor.setup_sensor(tsl2561, config)
|
||||
setup_component(tsl2561, config)
|
||||
|
||||
|
||||
|
|
|
@ -1,22 +1,20 @@
|
|||
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, \
|
||||
import esphomeyaml.config_validation as cv
|
||||
from esphomeyaml.const import CONF_ECHO_PIN, CONF_ID, CONF_NAME, CONF_TIMEOUT_METER, \
|
||||
CONF_TIMEOUT_TIME, CONF_TRIGGER_PIN, CONF_UPDATE_INTERVAL
|
||||
from esphomeyaml.cpp_generator import variable, add
|
||||
from esphomeyaml.cpp_helpers import gpio_output_pin_expression, gpio_input_pin_expression, \
|
||||
from esphomeyaml.cpp_generator import Pvariable, add
|
||||
from esphomeyaml.cpp_helpers import gpio_input_pin_expression, gpio_output_pin_expression, \
|
||||
setup_component
|
||||
from esphomeyaml.cpp_types import Application, App
|
||||
from esphomeyaml.cpp_types import App
|
||||
|
||||
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,
|
||||
|
@ -32,15 +30,14 @@ def to_code(config):
|
|||
yield
|
||||
rhs = App.make_ultrasonic_sensor(config[CONF_NAME], trigger, echo,
|
||||
config.get(CONF_UPDATE_INTERVAL))
|
||||
make = variable(config[CONF_MAKE_ID], rhs)
|
||||
ultrasonic = make.Pultrasonic
|
||||
ultrasonic = Pvariable(config[CONF_ID], rhs)
|
||||
|
||||
if CONF_TIMEOUT_TIME in 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]))
|
||||
|
||||
sensor.setup_sensor(ultrasonic, make.Pmqtt, config)
|
||||
sensor.setup_sensor(ultrasonic, config)
|
||||
setup_component(ultrasonic, config)
|
||||
|
||||
|
||||
|
|
|
@ -2,27 +2,24 @@ import voluptuous as vol
|
|||
|
||||
from esphomeyaml.components import sensor
|
||||
import esphomeyaml.config_validation as cv
|
||||
from esphomeyaml.const import CONF_MAKE_ID, CONF_NAME, CONF_UPDATE_INTERVAL
|
||||
from esphomeyaml.cpp_generator import variable
|
||||
from esphomeyaml.const import CONF_ID, CONF_NAME, CONF_UPDATE_INTERVAL
|
||||
from esphomeyaml.cpp_generator import Pvariable
|
||||
from esphomeyaml.cpp_helpers import setup_component
|
||||
from esphomeyaml.cpp_types import App, Application
|
||||
from esphomeyaml.cpp_types import App
|
||||
|
||||
MakeUptimeSensor = Application.struct('MakeUptimeSensor')
|
||||
UptimeSensor = sensor.sensor_ns.class_('UptimeSensor', sensor.PollingSensorComponent)
|
||||
|
||||
PLATFORM_SCHEMA = cv.nameable(sensor.SENSOR_PLATFORM_SCHEMA.extend({
|
||||
cv.GenerateID(): cv.declare_variable_id(UptimeSensor),
|
||||
cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeUptimeSensor),
|
||||
vol.Optional(CONF_UPDATE_INTERVAL): cv.update_interval,
|
||||
}).extend(cv.COMPONENT_SCHEMA.schema))
|
||||
|
||||
|
||||
def to_code(config):
|
||||
rhs = App.make_uptime_sensor(config[CONF_NAME], config.get(CONF_UPDATE_INTERVAL))
|
||||
make = variable(config[CONF_MAKE_ID], rhs)
|
||||
uptime = make.Puptime
|
||||
uptime = Pvariable(config[CONF_ID], rhs)
|
||||
|
||||
sensor.setup_sensor(uptime, make.Pmqtt, config)
|
||||
sensor.setup_sensor(uptime, config)
|
||||
setup_component(uptime, config)
|
||||
|
||||
|
||||
|
|
|
@ -2,27 +2,24 @@ import voluptuous as vol
|
|||
|
||||
from esphomeyaml.components import sensor
|
||||
import esphomeyaml.config_validation as cv
|
||||
from esphomeyaml.const import CONF_MAKE_ID, CONF_NAME, CONF_UPDATE_INTERVAL
|
||||
from esphomeyaml.cpp_generator import variable
|
||||
from esphomeyaml.const import CONF_ID, CONF_NAME, CONF_UPDATE_INTERVAL
|
||||
from esphomeyaml.cpp_generator import Pvariable
|
||||
from esphomeyaml.cpp_helpers import setup_component
|
||||
from esphomeyaml.cpp_types import App, Application
|
||||
from esphomeyaml.cpp_types import App
|
||||
|
||||
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
|
||||
wifi = Pvariable(config[CONF_ID], rhs)
|
||||
|
||||
sensor.setup_sensor(wifi, make.Pmqtt, config)
|
||||
sensor.setup_sensor(wifi, config)
|
||||
setup_component(wifi, config)
|
||||
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ from esphomeyaml.components.mqtt import setup_mqtt_component
|
|||
import esphomeyaml.config_validation as cv
|
||||
from esphomeyaml.const import CONF_ICON, CONF_ID, CONF_INVERTED, CONF_MQTT_ID, CONF_INTERNAL, \
|
||||
CONF_OPTIMISTIC
|
||||
from esphomeyaml.core import CORE
|
||||
from esphomeyaml.cpp_generator import add, Pvariable, get_variable
|
||||
from esphomeyaml.cpp_types import esphomelib_ns, Nameable, Action, App
|
||||
|
||||
|
@ -33,7 +34,7 @@ SWITCH_SCHEMA = cv.MQTT_COMMAND_COMPONENT_SCHEMA.extend({
|
|||
SWITCH_PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(SWITCH_SCHEMA.schema)
|
||||
|
||||
|
||||
def setup_switch_core_(switch_var, mqtt_var, config):
|
||||
def setup_switch_core_(switch_var, config):
|
||||
if CONF_INTERNAL in config:
|
||||
add(switch_var.set_internal(config[CONF_INTERNAL]))
|
||||
if CONF_ICON in config:
|
||||
|
@ -41,20 +42,19 @@ def setup_switch_core_(switch_var, mqtt_var, config):
|
|||
if CONF_INVERTED in config:
|
||||
add(switch_var.set_inverted(config[CONF_INVERTED]))
|
||||
|
||||
setup_mqtt_component(mqtt_var, config)
|
||||
setup_mqtt_component(switch_var.Pget_mqtt(), config)
|
||||
|
||||
|
||||
def setup_switch(switch_obj, mqtt_obj, config):
|
||||
switch_var = Pvariable(config[CONF_ID], switch_obj, has_side_effects=False)
|
||||
mqtt_var = Pvariable(config[CONF_MQTT_ID], mqtt_obj, has_side_effects=False)
|
||||
setup_switch_core_(switch_var, mqtt_var, config)
|
||||
def setup_switch(switch_obj, config):
|
||||
if not CORE.has_id(config[CONF_ID]):
|
||||
switch_obj = Pvariable(config[CONF_ID], switch_obj, has_side_effects=True)
|
||||
CORE.add_job(setup_switch_core_, switch_obj, config)
|
||||
|
||||
|
||||
def register_switch(var, config):
|
||||
switch_var = Pvariable(config[CONF_ID], var, has_side_effects=True)
|
||||
rhs = App.register_switch(switch_var)
|
||||
mqtt_var = Pvariable(config[CONF_MQTT_ID], rhs, has_side_effects=True)
|
||||
setup_switch_core_(switch_var, mqtt_var, config)
|
||||
add(App.register_switch(switch_var))
|
||||
CORE.add_job(setup_switch_core_, switch_var, config)
|
||||
|
||||
|
||||
BUILD_FLAGS = '-DUSE_SWITCH'
|
||||
|
|
|
@ -3,12 +3,11 @@ 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, CONF_RESTORE_MODE
|
||||
from esphomeyaml.cpp_generator import add, variable
|
||||
from esphomeyaml.const import CONF_ID, CONF_NAME, CONF_PIN, CONF_RESTORE_MODE
|
||||
from esphomeyaml.cpp_generator import Pvariable, add
|
||||
from esphomeyaml.cpp_helpers import gpio_output_pin_expression, setup_component
|
||||
from esphomeyaml.cpp_types import App, Application, Component
|
||||
from esphomeyaml.cpp_types import App, Component
|
||||
|
||||
MakeGPIOSwitch = Application.struct('MakeGPIOSwitch')
|
||||
GPIOSwitch = switch.switch_ns.class_('GPIOSwitch', switch.Switch, Component)
|
||||
GPIOSwitchRestoreMode = switch.switch_ns.enum('GPIOSwitchRestoreMode')
|
||||
|
||||
|
@ -21,7 +20,6 @@ RESTORE_MODES = {
|
|||
|
||||
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,
|
||||
vol.Optional(CONF_RESTORE_MODE): cv.one_of(*RESTORE_MODES, upper=True, space='_'),
|
||||
}).extend(cv.COMPONENT_SCHEMA.schema))
|
||||
|
@ -31,13 +29,12 @@ 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_
|
||||
gpio = Pvariable(config[CONF_ID], rhs)
|
||||
|
||||
if CONF_RESTORE_MODE in config:
|
||||
add(gpio.set_restore_mode(RESTORE_MODES[config[CONF_RESTORE_MODE]]))
|
||||
|
||||
switch.setup_switch(gpio, make.Pmqtt, config)
|
||||
switch.setup_switch(gpio, config)
|
||||
setup_component(gpio, config)
|
||||
|
||||
|
||||
|
|
|
@ -2,17 +2,15 @@ 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.cpp_generator import get_variable, variable
|
||||
from esphomeyaml.const import CONF_ID, CONF_NAME, CONF_OUTPUT
|
||||
from esphomeyaml.cpp_generator import Pvariable, get_variable
|
||||
from esphomeyaml.cpp_helpers import setup_component
|
||||
from esphomeyaml.cpp_types import App, Application, Component
|
||||
from esphomeyaml.cpp_types import App, Component
|
||||
|
||||
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))
|
||||
|
||||
|
@ -21,10 +19,9 @@ 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_ = Pvariable(config[CONF_ID], rhs)
|
||||
|
||||
switch.setup_switch(switch_, make.Pmqtt, config)
|
||||
switch.setup_switch(switch_, config)
|
||||
setup_component(switch, config)
|
||||
|
||||
|
||||
|
|
|
@ -2,24 +2,22 @@ import voluptuous as vol
|
|||
|
||||
from esphomeyaml.components import switch
|
||||
import esphomeyaml.config_validation as cv
|
||||
from esphomeyaml.const import CONF_INVERTED, CONF_MAKE_ID, CONF_NAME
|
||||
from esphomeyaml.cpp_generator import variable
|
||||
from esphomeyaml.cpp_types import App, Application
|
||||
from esphomeyaml.const import CONF_ID, CONF_INVERTED, CONF_NAME
|
||||
from esphomeyaml.cpp_generator import Pvariable
|
||||
from esphomeyaml.cpp_types import App
|
||||
|
||||
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)
|
||||
restart = Pvariable(config[CONF_ID], rhs)
|
||||
switch.setup_switch(restart, config)
|
||||
|
||||
|
||||
BUILD_FLAGS = '-DUSE_RESTART_SWITCH'
|
||||
|
|
|
@ -1,25 +1,23 @@
|
|||
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.cpp_generator import variable
|
||||
from esphomeyaml.cpp_types import Application, App
|
||||
import esphomeyaml.config_validation as cv
|
||||
from esphomeyaml.const import CONF_ID, CONF_INVERTED, CONF_NAME
|
||||
from esphomeyaml.cpp_generator import Pvariable
|
||||
from esphomeyaml.cpp_types import App
|
||||
|
||||
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)
|
||||
shutdown = Pvariable(config[CONF_ID], rhs)
|
||||
switch.setup_switch(shutdown, config)
|
||||
|
||||
|
||||
BUILD_FLAGS = '-DUSE_SHUTDOWN_SWITCH'
|
||||
|
|
|
@ -3,18 +3,16 @@ import voluptuous as vol
|
|||
from esphomeyaml import automation
|
||||
from esphomeyaml.components import switch
|
||||
import esphomeyaml.config_validation as cv
|
||||
from esphomeyaml.const import CONF_LAMBDA, CONF_MAKE_ID, CONF_NAME, CONF_OPTIMISTIC, \
|
||||
from esphomeyaml.const import CONF_ID, CONF_LAMBDA, CONF_NAME, CONF_OPTIMISTIC, \
|
||||
CONF_RESTORE_STATE, CONF_TURN_OFF_ACTION, CONF_TURN_ON_ACTION
|
||||
from esphomeyaml.cpp_generator import add, process_lambda, variable
|
||||
from esphomeyaml.cpp_generator import Pvariable, add, process_lambda
|
||||
from esphomeyaml.cpp_helpers import setup_component
|
||||
from esphomeyaml.cpp_types import App, Application, Component, NoArg, bool_, optional
|
||||
from esphomeyaml.cpp_types import App, Component, NoArg, bool_, optional
|
||||
|
||||
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),
|
||||
|
@ -25,10 +23,9 @@ PLATFORM_SCHEMA = cv.nameable(switch.SWITCH_PLATFORM_SCHEMA.extend({
|
|||
|
||||
def to_code(config):
|
||||
rhs = App.make_template_switch(config[CONF_NAME])
|
||||
make = variable(config[CONF_MAKE_ID], rhs)
|
||||
template = make.Ptemplate_
|
||||
template = Pvariable(config[CONF_ID], rhs)
|
||||
|
||||
switch.setup_switch(template, make.Pmqtt, config)
|
||||
switch.setup_switch(template, config)
|
||||
|
||||
if CONF_LAMBDA in config:
|
||||
for template_ in process_lambda(config[CONF_LAMBDA], [],
|
||||
|
|
|
@ -3,15 +3,14 @@ import voluptuous as vol
|
|||
from esphomeyaml.components import switch, uart
|
||||
from esphomeyaml.components.uart import UARTComponent
|
||||
import esphomeyaml.config_validation as cv
|
||||
from esphomeyaml.const import CONF_DATA, CONF_INVERTED, CONF_MAKE_ID, CONF_NAME, CONF_UART_ID
|
||||
from esphomeyaml.const import CONF_DATA, CONF_ID, CONF_INVERTED, CONF_NAME, CONF_UART_ID
|
||||
from esphomeyaml.core import HexInt
|
||||
from esphomeyaml.cpp_generator import ArrayInitializer, get_variable, variable
|
||||
from esphomeyaml.cpp_types import App, Application
|
||||
from esphomeyaml.cpp_generator import ArrayInitializer, Pvariable, get_variable
|
||||
from esphomeyaml.cpp_types import App
|
||||
from esphomeyaml.py_compat import text_type
|
||||
|
||||
DEPENDENCIES = ['uart']
|
||||
|
||||
MakeUARTSwitch = Application.struct('MakeUARTSwitch')
|
||||
UARTSwitch = switch.switch_ns.class_('UARTSwitch', switch.Switch, uart.UARTDevice)
|
||||
|
||||
|
||||
|
@ -27,7 +26,6 @@ def validate_data(value):
|
|||
|
||||
PLATFORM_SCHEMA = cv.nameable(switch.SWITCH_PLATFORM_SCHEMA.extend({
|
||||
cv.GenerateID(): cv.declare_variable_id(UARTSwitch),
|
||||
cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeUARTSwitch),
|
||||
cv.GenerateID(CONF_UART_ID): cv.use_variable_id(UARTComponent),
|
||||
vol.Required(CONF_DATA): validate_data,
|
||||
vol.Optional(CONF_INVERTED): cv.invalid("UART switches do not support inverted mode!"),
|
||||
|
@ -41,8 +39,8 @@ def to_code(config):
|
|||
if isinstance(data, str):
|
||||
data = [HexInt(ord(x)) for x in data]
|
||||
rhs = App.make_uart_switch(uart_, config[CONF_NAME], ArrayInitializer(*data, multiline=False))
|
||||
restart = variable(config[CONF_MAKE_ID], rhs)
|
||||
switch.setup_switch(restart.Puart, restart.Pmqtt, config)
|
||||
var = Pvariable(config[CONF_ID], rhs)
|
||||
switch.setup_switch(var, config)
|
||||
|
||||
|
||||
BUILD_FLAGS = '-DUSE_UART_SWITCH'
|
||||
|
|
|
@ -34,7 +34,7 @@ TEXT_SENSOR_SCHEMA = cv.MQTT_COMPONENT_SCHEMA.extend({
|
|||
TEXT_SENSOR_PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(TEXT_SENSOR_SCHEMA.schema)
|
||||
|
||||
|
||||
def setup_text_sensor_core_(text_sensor_var, mqtt_var, config):
|
||||
def setup_text_sensor_core_(text_sensor_var, config):
|
||||
if CONF_INTERNAL in config:
|
||||
add(text_sensor_var.set_internal(config[CONF_INTERNAL]))
|
||||
if CONF_ICON in config:
|
||||
|
@ -45,20 +45,19 @@ def setup_text_sensor_core_(text_sensor_var, mqtt_var, config):
|
|||
trigger = Pvariable(conf[CONF_TRIGGER_ID], rhs)
|
||||
automation.build_automation(trigger, std_string, conf)
|
||||
|
||||
setup_mqtt_component(mqtt_var, config)
|
||||
setup_mqtt_component(text_sensor_var.get_mqtt(), config)
|
||||
|
||||
|
||||
def setup_text_sensor(text_sensor_obj, mqtt_obj, config):
|
||||
sensor_var = Pvariable(config[CONF_ID], text_sensor_obj, has_side_effects=False)
|
||||
mqtt_var = Pvariable(config[CONF_MQTT_ID], mqtt_obj, has_side_effects=False)
|
||||
CORE.add_job(setup_text_sensor_core_, sensor_var, mqtt_var, config)
|
||||
def setup_text_sensor(text_sensor_obj, config):
|
||||
if not CORE.has_id(config[CONF_ID]):
|
||||
text_sensor_obj = Pvariable(config[CONF_ID], text_sensor_obj, has_side_effects=True)
|
||||
CORE.add_job(setup_text_sensor_core_, text_sensor_obj, config)
|
||||
|
||||
|
||||
def register_text_sensor(var, config):
|
||||
text_sensor_var = Pvariable(config[CONF_ID], var, has_side_effects=True)
|
||||
rhs = App.register_text_sensor(text_sensor_var)
|
||||
mqtt_var = Pvariable(config[CONF_MQTT_ID], rhs, has_side_effects=True)
|
||||
CORE.add_job(setup_text_sensor_core_, text_sensor_var, mqtt_var, config)
|
||||
add(App.register_text_sensor(text_sensor_var))
|
||||
CORE.add_job(setup_text_sensor_core_, text_sensor_var, config)
|
||||
|
||||
|
||||
BUILD_FLAGS = '-DUSE_TEXT_SENSOR'
|
||||
|
|
|
@ -2,28 +2,25 @@ import voluptuous as vol
|
|||
|
||||
from esphomeyaml.components import text_sensor
|
||||
import esphomeyaml.config_validation as cv
|
||||
from esphomeyaml.const import CONF_ENTITY_ID, CONF_MAKE_ID, CONF_NAME
|
||||
from esphomeyaml.cpp_generator import variable
|
||||
from esphomeyaml.cpp_types import App, Application, Component
|
||||
from esphomeyaml.const import CONF_ENTITY_ID, CONF_ID, CONF_NAME
|
||||
from esphomeyaml.cpp_generator import Pvariable
|
||||
from esphomeyaml.cpp_types import App, Component
|
||||
|
||||
DEPENDENCIES = ['api']
|
||||
|
||||
MakeHomeassistantTextSensor = Application.struct('MakeHomeassistantTextSensor')
|
||||
HomeassistantTextSensor = text_sensor.text_sensor_ns.class_('HomeassistantTextSensor',
|
||||
text_sensor.TextSensor, Component)
|
||||
|
||||
PLATFORM_SCHEMA = cv.nameable(text_sensor.TEXT_SENSOR_PLATFORM_SCHEMA.extend({
|
||||
cv.GenerateID(): cv.declare_variable_id(HomeassistantTextSensor),
|
||||
cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeHomeassistantTextSensor),
|
||||
vol.Required(CONF_ENTITY_ID): cv.entity_id,
|
||||
}))
|
||||
|
||||
|
||||
def to_code(config):
|
||||
rhs = App.make_homeassistant_text_sensor(config[CONF_NAME], config[CONF_ENTITY_ID])
|
||||
make = variable(config[CONF_MAKE_ID], rhs)
|
||||
sensor_ = make.Psensor
|
||||
text_sensor.setup_text_sensor(sensor_, make.Pmqtt, config)
|
||||
sensor_ = Pvariable(config[CONF_ID], rhs)
|
||||
text_sensor.setup_text_sensor(sensor_, config)
|
||||
|
||||
|
||||
BUILD_FLAGS = '-DUSE_HOMEASSISTANT_TEXT_SENSOR'
|
||||
|
|
|
@ -2,20 +2,18 @@ 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.cpp_generator import add, variable
|
||||
from esphomeyaml.const import CONF_ID, CONF_NAME, CONF_QOS, CONF_TOPIC
|
||||
from esphomeyaml.cpp_generator import Pvariable, add
|
||||
from esphomeyaml.cpp_helpers import setup_component
|
||||
from esphomeyaml.cpp_types import App, Application, Component
|
||||
from esphomeyaml.cpp_types import App, 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))
|
||||
|
@ -23,13 +21,12 @@ PLATFORM_SCHEMA = cv.nameable(text_sensor.TEXT_SENSOR_PLATFORM_SCHEMA.extend({
|
|||
|
||||
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
|
||||
sensor_ = Pvariable(config[CONF_ID], rhs)
|
||||
|
||||
if CONF_QOS in config:
|
||||
add(sensor_.set_qos(config[CONF_QOS]))
|
||||
|
||||
text_sensor.setup_text_sensor(sensor_, make.Pmqtt, config)
|
||||
text_sensor.setup_text_sensor(sensor_, config)
|
||||
setup_component(sensor_, config)
|
||||
|
||||
|
||||
|
|
|
@ -2,18 +2,16 @@ import voluptuous as vol
|
|||
|
||||
from esphomeyaml.components import text_sensor
|
||||
import esphomeyaml.config_validation as cv
|
||||
from esphomeyaml.const import CONF_LAMBDA, CONF_MAKE_ID, CONF_NAME, CONF_UPDATE_INTERVAL
|
||||
from esphomeyaml.cpp_generator import add, process_lambda, variable
|
||||
from esphomeyaml.const import CONF_ID, CONF_LAMBDA, CONF_NAME, CONF_UPDATE_INTERVAL
|
||||
from esphomeyaml.cpp_generator import Pvariable, add, process_lambda
|
||||
from esphomeyaml.cpp_helpers import setup_component
|
||||
from esphomeyaml.cpp_types import App, Application, PollingComponent, optional, std_string
|
||||
from esphomeyaml.cpp_types import App, PollingComponent, optional, std_string
|
||||
|
||||
MakeTemplateTextSensor = Application.struct('MakeTemplateTextSensor')
|
||||
TemplateTextSensor = text_sensor.text_sensor_ns.class_('TemplateTextSensor',
|
||||
text_sensor.TextSensor, PollingComponent)
|
||||
|
||||
PLATFORM_SCHEMA = cv.nameable(text_sensor.TEXT_SENSOR_PLATFORM_SCHEMA.extend({
|
||||
cv.GenerateID(): cv.declare_variable_id(TemplateTextSensor),
|
||||
cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeTemplateTextSensor),
|
||||
vol.Required(CONF_LAMBDA): cv.lambda_,
|
||||
vol.Optional(CONF_UPDATE_INTERVAL): cv.update_interval,
|
||||
}).extend(cv.COMPONENT_SCHEMA.schema))
|
||||
|
@ -21,9 +19,8 @@ PLATFORM_SCHEMA = cv.nameable(text_sensor.TEXT_SENSOR_PLATFORM_SCHEMA.extend({
|
|||
|
||||
def to_code(config):
|
||||
rhs = App.make_template_text_sensor(config[CONF_NAME], config.get(CONF_UPDATE_INTERVAL))
|
||||
make = variable(config[CONF_MAKE_ID], rhs)
|
||||
template = make.Ptemplate_
|
||||
text_sensor.setup_text_sensor(template, make.Pmqtt, config)
|
||||
template = Pvariable(config[CONF_ID], rhs)
|
||||
text_sensor.setup_text_sensor(template, config)
|
||||
setup_component(template, config)
|
||||
|
||||
for template_ in process_lambda(config[CONF_LAMBDA], [],
|
||||
|
|
|
@ -1,25 +1,23 @@
|
|||
from esphomeyaml.components import text_sensor
|
||||
import esphomeyaml.config_validation as cv
|
||||
from esphomeyaml.const import CONF_MAKE_ID, CONF_NAME
|
||||
from esphomeyaml.cpp_generator import variable
|
||||
from esphomeyaml.const import CONF_ID, CONF_NAME
|
||||
from esphomeyaml.cpp_generator import Pvariable
|
||||
from esphomeyaml.cpp_helpers import setup_component
|
||||
from esphomeyaml.cpp_types import App, Application, Component
|
||||
from esphomeyaml.cpp_types import App, 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)
|
||||
sens = Pvariable(config[CONF_ID], rhs)
|
||||
text_sensor.setup_text_sensor(sens, config)
|
||||
setup_component(sens, config)
|
||||
|
||||
|
||||
BUILD_FLAGS = '-DUSE_VERSION_TEXT_SENSOR'
|
||||
|
|
|
@ -425,9 +425,14 @@ class EsphomeyamlCore(object):
|
|||
yield None, None
|
||||
|
||||
def register_variable(self, id, obj):
|
||||
if id in self.variables:
|
||||
raise EsphomeyamlError("ID {} is already registered".format(id))
|
||||
_LOGGER.debug("Registered variable %s of type %s", id.id, id.type)
|
||||
self.variables[id] = obj
|
||||
|
||||
def has_id(self, id):
|
||||
return id in self.variables
|
||||
|
||||
|
||||
CORE = EsphomeyamlCore()
|
||||
|
||||
|
|
|
@ -343,6 +343,7 @@ def get_ini_content():
|
|||
flash_mode = CORE.config[CONF_ESPHOMEYAML][CONF_BOARD_FLASH_MODE]
|
||||
data['board_build.flash_mode'] = flash_mode
|
||||
|
||||
if not CORE.config[CONF_ESPHOMEYAML][CONF_USE_CUSTOM_CODE]:
|
||||
if CORE.is_esp8266:
|
||||
# On ESP8266, we can disable LDF
|
||||
data['lib_ldf_mode'] = 'off'
|
||||
|
@ -358,6 +359,7 @@ def get_ini_content():
|
|||
'FastLED',
|
||||
'NeoPixelBus',
|
||||
'ESP Async WebServer',
|
||||
'AsyncMqttClient',
|
||||
]
|
||||
ignore = []
|
||||
for x in REMOVABLE_LIBRARIES:
|
||||
|
|
|
@ -461,6 +461,17 @@ sensor:
|
|||
- platform: wifi_signal
|
||||
name: "WiFi Signal Sensor"
|
||||
update_interval: 15s
|
||||
- platform: mqtt_subscribe
|
||||
name: "MQTT Subscribe Sensor 1"
|
||||
topic: "mqtt/topic"
|
||||
id: the_sensor
|
||||
qos: 2
|
||||
on_value:
|
||||
- mqtt.publish_json:
|
||||
topic: the/topic
|
||||
payload: |-
|
||||
root["key"] = id(the_sensor).value;
|
||||
root["greeting"] = "Hello World";
|
||||
|
||||
|
||||
esp32_touch:
|
||||
|
@ -1072,3 +1083,9 @@ globals:
|
|||
type: std::string
|
||||
restore_value: no
|
||||
# initial_value: ""
|
||||
|
||||
text_sensor:
|
||||
- platform: mqtt_subscribe
|
||||
name: "MQTT Subscribe Text"
|
||||
topic: "the/topic"
|
||||
qos: 2
|
||||
|
|
|
@ -24,12 +24,6 @@ ethernet:
|
|||
hostname: helloworld
|
||||
domain: .local
|
||||
|
||||
mqtt:
|
||||
broker: '192.168.178.84'
|
||||
port: 1883
|
||||
username: 'debug'
|
||||
password: 'debug'
|
||||
|
||||
api:
|
||||
|
||||
i2c:
|
||||
|
@ -82,17 +76,6 @@ sensor:
|
|||
name: "Xiaomi MiJia Humidity"
|
||||
battery_level:
|
||||
name: "Xiaomi MiJia Battery Level"
|
||||
- platform: mqtt_subscribe
|
||||
name: "MQTT Subscribe Sensor 1"
|
||||
topic: "mqtt/topic"
|
||||
id: the_sensor
|
||||
qos: 2
|
||||
on_value:
|
||||
- mqtt.publish_json:
|
||||
topic: the/topic
|
||||
payload: |-
|
||||
root["key"] = id(the_sensor).value;
|
||||
root["greeting"] = "Hello World";
|
||||
- platform: pmsx003
|
||||
type: PMSX003
|
||||
pm_1_0:
|
||||
|
@ -204,10 +187,6 @@ text_sensor:
|
|||
variables:
|
||||
my_variable: |-
|
||||
return id(version_sensor).state;
|
||||
- platform: mqtt_subscribe
|
||||
name: "MQTT Subscribe Text"
|
||||
topic: "the/topic"
|
||||
qos: 2
|
||||
- platform: template
|
||||
name: "Template Text Sensor"
|
||||
lambda: |-
|
||||
|
|
Loading…
Reference in a new issue