mirror of
https://github.com/esphome/esphome.git
synced 2024-11-22 06:58:11 +01:00
Merge branch 'dev' into rc
This commit is contained in:
commit
467ef9902f
9 changed files with 249 additions and 32 deletions
|
@ -1,3 +1,5 @@
|
||||||
|
import copy
|
||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from esphomeyaml import core
|
from esphomeyaml import core
|
||||||
|
@ -28,8 +30,9 @@ def validate_recursive_condition(value):
|
||||||
|
|
||||||
|
|
||||||
def validate_recursive_action(value):
|
def validate_recursive_action(value):
|
||||||
value = cv.ensure_list(value)
|
value = cv.ensure_list(value)[:]
|
||||||
for i, item in enumerate(value):
|
for i, item in enumerate(value):
|
||||||
|
item = copy.deepcopy(item)
|
||||||
if not isinstance(item, dict):
|
if not isinstance(item, dict):
|
||||||
raise vol.Invalid(u"Action must consist of key-value mapping! Got {}".format(item))
|
raise vol.Invalid(u"Action must consist of key-value mapping! Got {}".format(item))
|
||||||
key = next((x for x in item if x != CONF_ACTION_ID), None)
|
key = next((x for x in item if x != CONF_ACTION_ID), None)
|
||||||
|
|
|
@ -5,7 +5,7 @@ import esphomeyaml.config_validation as cv
|
||||||
from esphomeyaml.components.power_supply import PowerSupplyComponent
|
from esphomeyaml.components.power_supply import PowerSupplyComponent
|
||||||
from esphomeyaml.const import CONF_INVERTED, CONF_MAX_POWER, CONF_POWER_SUPPLY, CONF_ID, CONF_LEVEL
|
from esphomeyaml.const import CONF_INVERTED, CONF_MAX_POWER, CONF_POWER_SUPPLY, CONF_ID, CONF_LEVEL
|
||||||
from esphomeyaml.helpers import add, esphomelib_ns, get_variable, TemplateArguments, Pvariable, \
|
from esphomeyaml.helpers import add, esphomelib_ns, get_variable, TemplateArguments, Pvariable, \
|
||||||
templatable, bool_
|
templatable, float_, add_job
|
||||||
|
|
||||||
PLATFORM_SCHEMA = cv.PLATFORM_SCHEMA.extend({
|
PLATFORM_SCHEMA = cv.PLATFORM_SCHEMA.extend({
|
||||||
|
|
||||||
|
@ -43,37 +43,20 @@ def setup_output_platform_(obj, config, skip_power_supply=False):
|
||||||
|
|
||||||
|
|
||||||
def setup_output_platform(obj, config, skip_power_supply=False):
|
def setup_output_platform(obj, config, skip_power_supply=False):
|
||||||
for _ in setup_output_platform_(obj, config, skip_power_supply):
|
add_job(setup_output_platform_, obj, config, skip_power_supply)
|
||||||
yield
|
|
||||||
|
|
||||||
|
|
||||||
BUILD_FLAGS = '-DUSE_OUTPUT'
|
BUILD_FLAGS = '-DUSE_OUTPUT'
|
||||||
|
|
||||||
|
|
||||||
CONF_OUTPUT_TURN_ON = 'output.turn_on'
|
CONF_OUTPUT_TURN_ON = 'output.turn_on'
|
||||||
OUTPUT_TURN_OFF_ACTION = maybe_simple_id({
|
OUTPUT_TURN_ON_ACTION = maybe_simple_id({
|
||||||
vol.Required(CONF_ID): cv.use_variable_id(None),
|
vol.Required(CONF_ID): cv.use_variable_id(None),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
@ACTION_REGISTRY.register(CONF_OUTPUT_TURN_ON, OUTPUT_TURN_OFF_ACTION)
|
@ACTION_REGISTRY.register(CONF_OUTPUT_TURN_ON, OUTPUT_TURN_ON_ACTION)
|
||||||
def output_turn_on_to_code(config, action_id, arg_type):
|
def output_turn_on_to_code(config, action_id, arg_type):
|
||||||
template_arg = TemplateArguments(arg_type)
|
|
||||||
for var in get_variable(config[CONF_ID]):
|
|
||||||
yield None
|
|
||||||
rhs = var.make_turn_off_action(template_arg)
|
|
||||||
type = TurnOffAction.template(arg_type)
|
|
||||||
yield Pvariable(action_id, rhs, type=type)
|
|
||||||
|
|
||||||
|
|
||||||
CONF_OUTPUT_TURN_OFF = 'output.turn_off'
|
|
||||||
OUTPUT_TURN_ON_ACTION = maybe_simple_id({
|
|
||||||
vol.Required(CONF_ID): cv.use_variable_id(None)
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
@ACTION_REGISTRY.register(CONF_OUTPUT_TURN_OFF, OUTPUT_TURN_ON_ACTION)
|
|
||||||
def output_turn_off_to_code(config, action_id, arg_type):
|
|
||||||
template_arg = TemplateArguments(arg_type)
|
template_arg = TemplateArguments(arg_type)
|
||||||
for var in get_variable(config[CONF_ID]):
|
for var in get_variable(config[CONF_ID]):
|
||||||
yield None
|
yield None
|
||||||
|
@ -82,10 +65,26 @@ def output_turn_off_to_code(config, action_id, arg_type):
|
||||||
yield Pvariable(action_id, rhs, type=type)
|
yield Pvariable(action_id, rhs, type=type)
|
||||||
|
|
||||||
|
|
||||||
|
CONF_OUTPUT_TURN_OFF = 'output.turn_off'
|
||||||
|
OUTPUT_TURN_OFF_ACTION = maybe_simple_id({
|
||||||
|
vol.Required(CONF_ID): cv.use_variable_id(None)
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
@ACTION_REGISTRY.register(CONF_OUTPUT_TURN_OFF, OUTPUT_TURN_OFF_ACTION)
|
||||||
|
def output_turn_off_to_code(config, action_id, arg_type):
|
||||||
|
template_arg = TemplateArguments(arg_type)
|
||||||
|
for var in get_variable(config[CONF_ID]):
|
||||||
|
yield None
|
||||||
|
rhs = var.make_turn_off_action(template_arg)
|
||||||
|
type = TurnOffAction.template(arg_type)
|
||||||
|
yield Pvariable(action_id, rhs, type=type)
|
||||||
|
|
||||||
|
|
||||||
CONF_OUTPUT_SET_LEVEL = 'output.set_level'
|
CONF_OUTPUT_SET_LEVEL = 'output.set_level'
|
||||||
OUTPUT_SET_LEVEL_ACTION = vol.Schema({
|
OUTPUT_SET_LEVEL_ACTION = vol.Schema({
|
||||||
vol.Required(CONF_ID): cv.use_variable_id(None),
|
vol.Required(CONF_ID): cv.use_variable_id(None),
|
||||||
vol.Required(CONF_LEVEL): cv.percentage,
|
vol.Required(CONF_LEVEL): cv.templatable(cv.percentage),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
@ -97,7 +96,7 @@ def output_set_level_to_code(config, action_id, arg_type):
|
||||||
rhs = var.make_set_level_action(template_arg)
|
rhs = var.make_set_level_action(template_arg)
|
||||||
type = SetLevelAction.template(arg_type)
|
type = SetLevelAction.template(arg_type)
|
||||||
action = Pvariable(action_id, rhs, type=type)
|
action = Pvariable(action_id, rhs, type=type)
|
||||||
for template_ in templatable(config[CONF_LEVEL], arg_type, bool_):
|
for template_ in templatable(config[CONF_LEVEL], arg_type, float_):
|
||||||
yield None
|
yield None
|
||||||
add(action.set_level(template_))
|
add(action.set_level(template_))
|
||||||
yield action
|
yield action
|
||||||
|
|
|
@ -7,7 +7,8 @@ from esphomeyaml.const import CONF_ABOVE, CONF_ACCURACY_DECIMALS, CONF_ALPHA, CO
|
||||||
CONF_FILTER_NAN, CONF_FILTER_OUT, CONF_HEARTBEAT, CONF_ICON, CONF_ID, CONF_INTERNAL, \
|
CONF_FILTER_NAN, CONF_FILTER_OUT, CONF_HEARTBEAT, CONF_ICON, CONF_ID, CONF_INTERNAL, \
|
||||||
CONF_LAMBDA, CONF_MQTT_ID, CONF_MULTIPLY, CONF_OFFSET, CONF_ON_RAW_VALUE, CONF_ON_VALUE, \
|
CONF_LAMBDA, CONF_MQTT_ID, CONF_MULTIPLY, CONF_OFFSET, CONF_ON_RAW_VALUE, CONF_ON_VALUE, \
|
||||||
CONF_ON_VALUE_RANGE, CONF_OR, CONF_SEND_EVERY, CONF_SLIDING_WINDOW_MOVING_AVERAGE, \
|
CONF_ON_VALUE_RANGE, CONF_OR, CONF_SEND_EVERY, CONF_SLIDING_WINDOW_MOVING_AVERAGE, \
|
||||||
CONF_THROTTLE, CONF_TRIGGER_ID, CONF_UNIQUE, CONF_UNIT_OF_MEASUREMENT, CONF_WINDOW_SIZE
|
CONF_THROTTLE, CONF_TRIGGER_ID, CONF_UNIQUE, CONF_UNIT_OF_MEASUREMENT, CONF_WINDOW_SIZE, \
|
||||||
|
CONF_SEND_FIRST_AT
|
||||||
from esphomeyaml.helpers import App, ArrayInitializer, Pvariable, add, add_job, esphomelib_ns, \
|
from esphomeyaml.helpers import App, ArrayInitializer, Pvariable, add, add_job, esphomelib_ns, \
|
||||||
float_, process_lambda, setup_mqtt_component, templatable
|
float_, process_lambda, setup_mqtt_component, templatable
|
||||||
|
|
||||||
|
@ -20,6 +21,15 @@ def validate_recursive_filter(value):
|
||||||
return FILTERS_SCHEMA(value)
|
return FILTERS_SCHEMA(value)
|
||||||
|
|
||||||
|
|
||||||
|
def validate_send_first_at(value):
|
||||||
|
send_first_at = value.get(CONF_SEND_FIRST_AT)
|
||||||
|
send_every = value[CONF_SEND_EVERY]
|
||||||
|
if send_first_at is not None and send_first_at > send_every:
|
||||||
|
raise vol.Invalid("send_first_at must be smaller than or equal to send_every! {} <= {}"
|
||||||
|
"".format(send_first_at, send_every))
|
||||||
|
return value
|
||||||
|
|
||||||
|
|
||||||
FILTER_KEYS = [CONF_OFFSET, CONF_MULTIPLY, CONF_FILTER_OUT, CONF_FILTER_NAN,
|
FILTER_KEYS = [CONF_OFFSET, CONF_MULTIPLY, CONF_FILTER_OUT, CONF_FILTER_NAN,
|
||||||
CONF_SLIDING_WINDOW_MOVING_AVERAGE, CONF_EXPONENTIAL_MOVING_AVERAGE, CONF_LAMBDA,
|
CONF_SLIDING_WINDOW_MOVING_AVERAGE, CONF_EXPONENTIAL_MOVING_AVERAGE, CONF_LAMBDA,
|
||||||
CONF_THROTTLE, CONF_DELTA, CONF_UNIQUE, CONF_HEARTBEAT, CONF_DEBOUNCE, CONF_OR]
|
CONF_THROTTLE, CONF_DELTA, CONF_UNIQUE, CONF_HEARTBEAT, CONF_DEBOUNCE, CONF_OR]
|
||||||
|
@ -29,10 +39,11 @@ FILTERS_SCHEMA = vol.All(cv.ensure_list, [vol.All({
|
||||||
vol.Optional(CONF_MULTIPLY): vol.Coerce(float),
|
vol.Optional(CONF_MULTIPLY): vol.Coerce(float),
|
||||||
vol.Optional(CONF_FILTER_OUT): vol.Coerce(float),
|
vol.Optional(CONF_FILTER_OUT): vol.Coerce(float),
|
||||||
vol.Optional(CONF_FILTER_NAN): None,
|
vol.Optional(CONF_FILTER_NAN): None,
|
||||||
vol.Optional(CONF_SLIDING_WINDOW_MOVING_AVERAGE): vol.Schema({
|
vol.Optional(CONF_SLIDING_WINDOW_MOVING_AVERAGE): vol.All(vol.Schema({
|
||||||
vol.Required(CONF_WINDOW_SIZE): cv.positive_not_null_int,
|
vol.Required(CONF_WINDOW_SIZE): cv.positive_not_null_int,
|
||||||
vol.Required(CONF_SEND_EVERY): cv.positive_not_null_int,
|
vol.Required(CONF_SEND_EVERY): cv.positive_not_null_int,
|
||||||
}),
|
vol.Optional(CONF_SEND_FIRST_AT): cv.positive_not_null_int,
|
||||||
|
}), validate_send_first_at),
|
||||||
vol.Optional(CONF_EXPONENTIAL_MOVING_AVERAGE): vol.Schema({
|
vol.Optional(CONF_EXPONENTIAL_MOVING_AVERAGE): vol.Schema({
|
||||||
vol.Required(CONF_ALPHA): cv.positive_float,
|
vol.Required(CONF_ALPHA): cv.positive_float,
|
||||||
vol.Required(CONF_SEND_EVERY): cv.positive_not_null_int,
|
vol.Required(CONF_SEND_EVERY): cv.positive_not_null_int,
|
||||||
|
@ -103,7 +114,8 @@ def setup_filter(config):
|
||||||
yield FilterOutNANFilter.new()
|
yield FilterOutNANFilter.new()
|
||||||
elif CONF_SLIDING_WINDOW_MOVING_AVERAGE in config:
|
elif CONF_SLIDING_WINDOW_MOVING_AVERAGE in config:
|
||||||
conf = config[CONF_SLIDING_WINDOW_MOVING_AVERAGE]
|
conf = config[CONF_SLIDING_WINDOW_MOVING_AVERAGE]
|
||||||
yield SlidingWindowMovingAverageFilter.new(conf[CONF_WINDOW_SIZE], conf[CONF_SEND_EVERY])
|
yield SlidingWindowMovingAverageFilter.new(conf[CONF_WINDOW_SIZE], conf[CONF_SEND_EVERY],
|
||||||
|
conf.get(CONF_SEND_FIRST_AT))
|
||||||
elif CONF_EXPONENTIAL_MOVING_AVERAGE in config:
|
elif CONF_EXPONENTIAL_MOVING_AVERAGE in config:
|
||||||
conf = config[CONF_EXPONENTIAL_MOVING_AVERAGE]
|
conf = config[CONF_EXPONENTIAL_MOVING_AVERAGE]
|
||||||
yield ExponentialMovingAverageFilter.new(conf[CONF_ALPHA], conf[CONF_SEND_EVERY])
|
yield ExponentialMovingAverageFilter.new(conf[CONF_ALPHA], conf[CONF_SEND_EVERY])
|
||||||
|
|
126
esphomeyaml/components/stepper/__init__.py
Normal file
126
esphomeyaml/components/stepper/__init__.py
Normal file
|
@ -0,0 +1,126 @@
|
||||||
|
import voluptuous as vol
|
||||||
|
|
||||||
|
from esphomeyaml.automation import ACTION_REGISTRY
|
||||||
|
import esphomeyaml.config_validation as cv
|
||||||
|
from esphomeyaml.const import CONF_ACCELERATION, CONF_DECELERATION, CONF_ID, CONF_MAX_SPEED, \
|
||||||
|
CONF_POSITION, CONF_TARGET
|
||||||
|
from esphomeyaml.helpers import Pvariable, TemplateArguments, add, add_job, esphomelib_ns, \
|
||||||
|
get_variable, int32, templatable
|
||||||
|
|
||||||
|
PLATFORM_SCHEMA = cv.PLATFORM_SCHEMA.extend({
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
# pylint: disable=invalid-name
|
||||||
|
stepper_ns = esphomelib_ns.namespace('stepper')
|
||||||
|
Stepper = stepper_ns.Stepper
|
||||||
|
|
||||||
|
SetTargetAction = stepper_ns.SetTargetAction
|
||||||
|
ReportPositionAction = stepper_ns.ReportPositionAction
|
||||||
|
|
||||||
|
|
||||||
|
def validate_acceleration(value):
|
||||||
|
value = cv.string(value)
|
||||||
|
for suffix in ('steps/s^2', 'steps/s*s', 'steps/s/s', 'steps/ss', 'steps/(s*s)'):
|
||||||
|
if value.endswith(suffix):
|
||||||
|
value = value[:-len(suffix)]
|
||||||
|
|
||||||
|
if value == 'inf':
|
||||||
|
return 1e6
|
||||||
|
|
||||||
|
try:
|
||||||
|
value = float(value)
|
||||||
|
except ValueError:
|
||||||
|
raise vol.Invalid("Expected acceleration as floating point number, got {}".format(value))
|
||||||
|
|
||||||
|
if value <= 0:
|
||||||
|
raise vol.Invalid("Acceleration must be larger than 0 steps/s^2!")
|
||||||
|
|
||||||
|
return value
|
||||||
|
|
||||||
|
|
||||||
|
def validate_speed(value):
|
||||||
|
value = cv.string(value)
|
||||||
|
for suffix in ('steps/s', 'steps/s'):
|
||||||
|
if value.endswith(suffix):
|
||||||
|
value = value[:-len(suffix)]
|
||||||
|
|
||||||
|
if value == 'inf':
|
||||||
|
return 1e6
|
||||||
|
|
||||||
|
try:
|
||||||
|
value = float(value)
|
||||||
|
except ValueError:
|
||||||
|
raise vol.Invalid("Expected speed as floating point number, got {}".format(value))
|
||||||
|
|
||||||
|
if value <= 0:
|
||||||
|
raise vol.Invalid("Speed must be larger than 0 steps/s!")
|
||||||
|
|
||||||
|
return value
|
||||||
|
|
||||||
|
|
||||||
|
STEPPER_SCHEMA = vol.Schema({
|
||||||
|
cv.GenerateID(): cv.declare_variable_id(Stepper),
|
||||||
|
vol.Required(CONF_MAX_SPEED): validate_speed,
|
||||||
|
vol.Optional(CONF_ACCELERATION): validate_acceleration,
|
||||||
|
vol.Optional(CONF_DECELERATION): validate_acceleration,
|
||||||
|
})
|
||||||
|
|
||||||
|
STEPPER_PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(STEPPER_SCHEMA.schema)
|
||||||
|
|
||||||
|
|
||||||
|
def setup_stepper_core_(stepper_var, config):
|
||||||
|
if CONF_ACCELERATION in config:
|
||||||
|
add(stepper_var.set_acceleration(config[CONF_ACCELERATION]))
|
||||||
|
if CONF_DECELERATION in config:
|
||||||
|
add(stepper_var.set_deceleration(config[CONF_DECELERATION]))
|
||||||
|
if CONF_MAX_SPEED in config:
|
||||||
|
add(stepper_var.set_max_speed(config[CONF_MAX_SPEED]))
|
||||||
|
|
||||||
|
|
||||||
|
def setup_stepper(stepper_var, config):
|
||||||
|
add_job(setup_stepper_core_, stepper_var, config)
|
||||||
|
|
||||||
|
|
||||||
|
BUILD_FLAGS = '-DUSE_STEPPER'
|
||||||
|
|
||||||
|
CONF_STEPPER_SET_TARGET = 'stepper.set_target'
|
||||||
|
STEPPER_SET_TARGET_ACTION_SCHEMA = vol.Schema({
|
||||||
|
vol.Required(CONF_ID): cv.use_variable_id(None),
|
||||||
|
vol.Required(CONF_TARGET): cv.templatable(cv.int_),
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
@ACTION_REGISTRY.register(CONF_STEPPER_SET_TARGET, STEPPER_SET_TARGET_ACTION_SCHEMA)
|
||||||
|
def stepper_set_target_to_code(config, action_id, arg_type):
|
||||||
|
template_arg = TemplateArguments(arg_type)
|
||||||
|
for var in get_variable(config[CONF_ID]):
|
||||||
|
yield None
|
||||||
|
rhs = var.make_set_target_action(template_arg)
|
||||||
|
type = SetTargetAction.template(arg_type)
|
||||||
|
action = Pvariable(action_id, rhs, type=type)
|
||||||
|
for template_ in templatable(config[CONF_TARGET], arg_type, int32):
|
||||||
|
yield None
|
||||||
|
add(action.set_target(template_))
|
||||||
|
yield action
|
||||||
|
|
||||||
|
|
||||||
|
CONF_STEPPER_REPORT_POSITION = 'stepper.report_position'
|
||||||
|
STEPPER_REPORT_POSITION_ACTION_SCHEMA = vol.Schema({
|
||||||
|
vol.Required(CONF_ID): cv.use_variable_id(None),
|
||||||
|
vol.Required(CONF_POSITION): cv.templatable(cv.int_),
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
@ACTION_REGISTRY.register(CONF_STEPPER_REPORT_POSITION, STEPPER_REPORT_POSITION_ACTION_SCHEMA)
|
||||||
|
def stepper_report_position_to_code(config, action_id, arg_type):
|
||||||
|
template_arg = TemplateArguments(arg_type)
|
||||||
|
for var in get_variable(config[CONF_ID]):
|
||||||
|
yield None
|
||||||
|
rhs = var.make_report_position_action(template_arg)
|
||||||
|
type = ReportPositionAction.template(arg_type)
|
||||||
|
action = Pvariable(action_id, rhs, type=type)
|
||||||
|
for template_ in templatable(config[CONF_POSITION], arg_type, int32):
|
||||||
|
yield None
|
||||||
|
add(action.set_target(template_))
|
||||||
|
yield action
|
35
esphomeyaml/components/stepper/a4988.py
Normal file
35
esphomeyaml/components/stepper/a4988.py
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
import voluptuous as vol
|
||||||
|
|
||||||
|
from esphomeyaml import pins
|
||||||
|
from esphomeyaml.components import stepper
|
||||||
|
import esphomeyaml.config_validation as cv
|
||||||
|
from esphomeyaml.const import CONF_DIR_PIN, CONF_ID, CONF_SLEEP_PIN, CONF_STEP_PIN
|
||||||
|
from esphomeyaml.helpers import App, Pvariable, add, gpio_output_pin_expression
|
||||||
|
|
||||||
|
A4988 = stepper.stepper_ns.A4988
|
||||||
|
|
||||||
|
PLATFORM_SCHEMA = stepper.STEPPER_PLATFORM_SCHEMA.extend({
|
||||||
|
vol.Required(CONF_ID): cv.declare_variable_id(A4988),
|
||||||
|
vol.Required(CONF_STEP_PIN): pins.gpio_output_pin_schema,
|
||||||
|
vol.Required(CONF_DIR_PIN): pins.gpio_output_pin_schema,
|
||||||
|
vol.Optional(CONF_SLEEP_PIN): pins.gpio_output_pin_schema,
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
def to_code(config):
|
||||||
|
for step_pin in gpio_output_pin_expression(config[CONF_STEP_PIN]):
|
||||||
|
yield
|
||||||
|
for dir_pin in gpio_output_pin_expression(config[CONF_DIR_PIN]):
|
||||||
|
yield
|
||||||
|
rhs = App.make_a4988(step_pin, dir_pin)
|
||||||
|
a4988 = Pvariable(config[CONF_ID], rhs)
|
||||||
|
|
||||||
|
if CONF_SLEEP_PIN in config:
|
||||||
|
for sleep_pin in gpio_output_pin_expression(config[CONF_SLEEP_PIN]):
|
||||||
|
yield
|
||||||
|
add(a4988.set_sleep_pin(sleep_pin))
|
||||||
|
|
||||||
|
stepper.setup_stepper(a4988, config)
|
||||||
|
|
||||||
|
|
||||||
|
BUILD_FLAGS = '-DUSE_A4988'
|
|
@ -1,11 +1,11 @@
|
||||||
"""Constants used by esphomeyaml."""
|
"""Constants used by esphomeyaml."""
|
||||||
|
|
||||||
MAJOR_VERSION = 1
|
MAJOR_VERSION = 1
|
||||||
MINOR_VERSION = 9
|
MINOR_VERSION = 10
|
||||||
PATCH_VERSION = '0b1'
|
PATCH_VERSION = '0-dev'
|
||||||
__short_version__ = '{}.{}'.format(MAJOR_VERSION, MINOR_VERSION)
|
__short_version__ = '{}.{}'.format(MAJOR_VERSION, MINOR_VERSION)
|
||||||
__version__ = '{}.{}'.format(__short_version__, PATCH_VERSION)
|
__version__ = '{}.{}'.format(__short_version__, PATCH_VERSION)
|
||||||
ESPHOMELIB_VERSION = '1.9.0b1'
|
ESPHOMELIB_VERSION = 'dev'
|
||||||
|
|
||||||
ESP_PLATFORM_ESP32 = 'ESP32'
|
ESP_PLATFORM_ESP32 = 'ESP32'
|
||||||
ESP_PLATFORM_ESP8266 = 'ESP8266'
|
ESP_PLATFORM_ESP8266 = 'ESP8266'
|
||||||
|
@ -350,6 +350,15 @@ CONF_ARGS = 'args'
|
||||||
CONF_FORMAT = 'format'
|
CONF_FORMAT = 'format'
|
||||||
CONF_COLOR_CORRECT = 'color_correct'
|
CONF_COLOR_CORRECT = 'color_correct'
|
||||||
CONF_ON_JSON_MESSAGE = 'on_json_message'
|
CONF_ON_JSON_MESSAGE = 'on_json_message'
|
||||||
|
CONF_ACCELERATION = 'acceleration'
|
||||||
|
CONF_DECELERATION = 'deceleration'
|
||||||
|
CONF_MAX_SPEED = 'max_speed'
|
||||||
|
CONF_TARGET = 'target'
|
||||||
|
CONF_POSITION = 'position'
|
||||||
|
CONF_STEP_PIN = 'step_pin'
|
||||||
|
CONF_DIR_PIN = 'dir_pin'
|
||||||
|
CONF_SLEEP_PIN = 'sleep_pin'
|
||||||
|
CONF_SEND_FIRST_AT = 'send_first_at'
|
||||||
|
|
||||||
ALLOWED_NAME_CHARS = u'abcdefghijklmnopqrstuvwxyz0123456789_'
|
ALLOWED_NAME_CHARS = u'abcdefghijklmnopqrstuvwxyz0123456789_'
|
||||||
ARDUINO_VERSION_ESP32_DEV = 'https://github.com/platformio/platform-espressif32.git#feature/stage'
|
ARDUINO_VERSION_ESP32_DEV = 'https://github.com/platformio/platform-espressif32.git#feature/stage'
|
||||||
|
|
|
@ -46,6 +46,8 @@ def validate_board(value):
|
||||||
def validate_simple_esphomelib_version(value):
|
def validate_simple_esphomelib_version(value):
|
||||||
value = cv.string_strict(value)
|
value = cv.string_strict(value)
|
||||||
if value.upper() == 'LATEST':
|
if value.upper() == 'LATEST':
|
||||||
|
if ESPHOMELIB_VERSION == 'dev':
|
||||||
|
return validate_simple_esphomelib_version('dev')
|
||||||
return {
|
return {
|
||||||
CONF_REPOSITORY: LIBRARY_URI_REPO,
|
CONF_REPOSITORY: LIBRARY_URI_REPO,
|
||||||
CONF_TAG: 'v' + ESPHOMELIB_VERSION,
|
CONF_TAG: 'v' + ESPHOMELIB_VERSION,
|
||||||
|
@ -53,7 +55,7 @@ def validate_simple_esphomelib_version(value):
|
||||||
elif value.upper() == 'DEV':
|
elif value.upper() == 'DEV':
|
||||||
return {
|
return {
|
||||||
CONF_REPOSITORY: LIBRARY_URI_REPO,
|
CONF_REPOSITORY: LIBRARY_URI_REPO,
|
||||||
CONF_BRANCH: 'master'
|
CONF_BRANCH: 'dev'
|
||||||
}
|
}
|
||||||
elif VERSION_REGEX.match(value) is not None:
|
elif VERSION_REGEX.match(value) is not None:
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -565,6 +565,7 @@ std_string = std_ns.string
|
||||||
uint8 = global_ns.namespace('uint8_t')
|
uint8 = global_ns.namespace('uint8_t')
|
||||||
uint16 = global_ns.namespace('uint16_t')
|
uint16 = global_ns.namespace('uint16_t')
|
||||||
uint32 = global_ns.namespace('uint32_t')
|
uint32 = global_ns.namespace('uint32_t')
|
||||||
|
int32 = global_ns.namespace('int32_t')
|
||||||
const_char_p = global_ns.namespace('const char *')
|
const_char_p = global_ns.namespace('const char *')
|
||||||
NAN = global_ns.namespace('NAN')
|
NAN = global_ns.namespace('NAN')
|
||||||
esphomelib_ns = global_ns # using namespace esphomelib;
|
esphomelib_ns = global_ns # using namespace esphomelib;
|
||||||
|
|
|
@ -165,6 +165,7 @@ sensor:
|
||||||
- sliding_window_moving_average:
|
- sliding_window_moving_average:
|
||||||
window_size: 15
|
window_size: 15
|
||||||
send_every: 15
|
send_every: 15
|
||||||
|
send_first_at: 15
|
||||||
- exponential_moving_average:
|
- exponential_moving_average:
|
||||||
alpha: 0.1
|
alpha: 0.1
|
||||||
send_every: 15
|
send_every: 15
|
||||||
|
@ -797,6 +798,12 @@ switch:
|
||||||
optimistic: True
|
optimistic: True
|
||||||
turn_on_action:
|
turn_on_action:
|
||||||
- switch.turn_on: living_room_lights_on
|
- switch.turn_on: living_room_lights_on
|
||||||
|
- output.set_level:
|
||||||
|
id: gpio_19
|
||||||
|
level: 50%
|
||||||
|
- output.set_level:
|
||||||
|
id: gpio_19
|
||||||
|
level: !lambda 'return 0.5;'
|
||||||
turn_off_action:
|
turn_off_action:
|
||||||
- switch.turn_on: living_room_lights_off
|
- switch.turn_on: living_room_lights_off
|
||||||
- platform: restart
|
- platform: restart
|
||||||
|
@ -831,6 +838,19 @@ switch:
|
||||||
- platform: uart
|
- platform: uart
|
||||||
name: "UART Bytes Output"
|
name: "UART Bytes Output"
|
||||||
data: [0xDE, 0xAD, 0xBE, 0xEF]
|
data: [0xDE, 0xAD, 0xBE, 0xEF]
|
||||||
|
- platform: template
|
||||||
|
optimistic: true
|
||||||
|
name: Stepper Switch
|
||||||
|
turn_on_action:
|
||||||
|
- stepper.set_target:
|
||||||
|
id: my_stepper
|
||||||
|
target: !lambda |-
|
||||||
|
static int32_t i = 0;
|
||||||
|
i += 1000;
|
||||||
|
if (i > 5000) {
|
||||||
|
i = -5000;
|
||||||
|
}
|
||||||
|
return i;
|
||||||
|
|
||||||
fan:
|
fan:
|
||||||
- platform: binary
|
- platform: binary
|
||||||
|
@ -941,3 +961,13 @@ pcf8574:
|
||||||
- id: 'pcf8574_hub'
|
- id: 'pcf8574_hub'
|
||||||
address: 0x21
|
address: 0x21
|
||||||
pcf8575: False
|
pcf8575: False
|
||||||
|
|
||||||
|
stepper:
|
||||||
|
- platform: a4988
|
||||||
|
id: my_stepper
|
||||||
|
step_pin: GPIO23
|
||||||
|
dir_pin: GPIO24
|
||||||
|
sleep_pin: GPIO25
|
||||||
|
max_speed: 250 steps/s
|
||||||
|
acceleration: 100 steps/s^2
|
||||||
|
deceleration: 200 steps/s^2
|
||||||
|
|
Loading…
Reference in a new issue