mirror of
https://github.com/esphome/esphome.git
synced 2024-11-25 16:38:16 +01:00
Further changes
This commit is contained in:
parent
2fc78a1b33
commit
5c39f73fda
42 changed files with 276 additions and 54 deletions
|
@ -8,7 +8,7 @@ from esphomeyaml.const import CONF_ABOVE, CONF_ACTION_ID, CONF_AND, CONF_AUTOMAT
|
||||||
CONF_EFFECT, CONF_ELSE, CONF_FLASH_LENGTH, CONF_GREEN, CONF_ID, CONF_IF, CONF_LAMBDA, \
|
CONF_EFFECT, CONF_ELSE, CONF_FLASH_LENGTH, CONF_GREEN, CONF_ID, CONF_IF, CONF_LAMBDA, \
|
||||||
CONF_LEVEL, CONF_OR, CONF_OSCILLATING, CONF_PAYLOAD, CONF_QOS, CONF_RANGE, CONF_RED, \
|
CONF_LEVEL, CONF_OR, CONF_OSCILLATING, CONF_PAYLOAD, CONF_QOS, CONF_RANGE, CONF_RED, \
|
||||||
CONF_RETAIN, CONF_SPEED, CONF_THEN, CONF_TOPIC, CONF_TRANSITION_LENGTH, CONF_TRIGGER_ID, \
|
CONF_RETAIN, CONF_SPEED, CONF_THEN, CONF_TOPIC, CONF_TRANSITION_LENGTH, CONF_TRIGGER_ID, \
|
||||||
CONF_WHITE
|
CONF_WHITE, CONF_COLOR_TEMPERATURE
|
||||||
from esphomeyaml.core import ESPHomeYAMLError
|
from esphomeyaml.core import ESPHomeYAMLError
|
||||||
from esphomeyaml.helpers import App, ArrayInitializer, Pvariable, TemplateArguments, add, add_job, \
|
from esphomeyaml.helpers import App, ArrayInitializer, Pvariable, TemplateArguments, add, add_job, \
|
||||||
bool_, esphomelib_ns, float_, get_variable, process_lambda, std_string, templatable, uint32, \
|
bool_, esphomelib_ns, float_, get_variable, process_lambda, std_string, templatable, uint32, \
|
||||||
|
@ -87,6 +87,7 @@ ACTIONS_SCHEMA = vol.All(cv.ensure_list, [vol.All({
|
||||||
vol.Optional(CONF_GREEN): cv.templatable(cv.percentage),
|
vol.Optional(CONF_GREEN): cv.templatable(cv.percentage),
|
||||||
vol.Optional(CONF_BLUE): cv.templatable(cv.percentage),
|
vol.Optional(CONF_BLUE): cv.templatable(cv.percentage),
|
||||||
vol.Optional(CONF_WHITE): cv.templatable(cv.percentage),
|
vol.Optional(CONF_WHITE): cv.templatable(cv.percentage),
|
||||||
|
vol.Optional(CONF_COLOR_TEMPERATURE): cv.templatable(cv.positive_float),
|
||||||
vol.Optional(CONF_EFFECT): cv.templatable(cv.string),
|
vol.Optional(CONF_EFFECT): cv.templatable(cv.string),
|
||||||
}),
|
}),
|
||||||
vol.Optional(CONF_SWITCH_TOGGLE): maybe_simple_id({
|
vol.Optional(CONF_SWITCH_TOGGLE): maybe_simple_id({
|
||||||
|
@ -256,13 +257,11 @@ def build_action(full_config, arg_type):
|
||||||
rhs = App.register_component(DelayAction.new(template_arg))
|
rhs = App.register_component(DelayAction.new(template_arg))
|
||||||
type = DelayAction.template(template_arg)
|
type = DelayAction.template(template_arg)
|
||||||
action = Pvariable(action_id, rhs, type=type)
|
action = Pvariable(action_id, rhs, type=type)
|
||||||
template_ = None
|
|
||||||
for template_ in templatable(config, arg_type, uint32):
|
for template_ in templatable(config, arg_type, uint32):
|
||||||
yield
|
yield
|
||||||
add(action.set_delay(template_))
|
add(action.set_delay(template_))
|
||||||
yield action
|
yield action
|
||||||
elif key == CONF_LAMBDA:
|
elif key == CONF_LAMBDA:
|
||||||
lambda_ = None
|
|
||||||
for lambda_ in process_lambda(config, [(arg_type, 'x')]):
|
for lambda_ in process_lambda(config, [(arg_type, 'x')]):
|
||||||
yield None
|
yield None
|
||||||
rhs = LambdaAction.new(template_arg, lambda_)
|
rhs = LambdaAction.new(template_arg, lambda_)
|
||||||
|
@ -272,22 +271,18 @@ def build_action(full_config, arg_type):
|
||||||
rhs = App.Pget_mqtt_client().Pmake_publish_action(template_arg)
|
rhs = App.Pget_mqtt_client().Pmake_publish_action(template_arg)
|
||||||
type = mqtt.MQTTPublishAction.template(template_arg)
|
type = mqtt.MQTTPublishAction.template(template_arg)
|
||||||
action = Pvariable(action_id, rhs, type=type)
|
action = Pvariable(action_id, rhs, type=type)
|
||||||
template_ = None
|
|
||||||
for template_ in templatable(config[CONF_TOPIC], arg_type, std_string):
|
for template_ in templatable(config[CONF_TOPIC], arg_type, std_string):
|
||||||
yield None
|
yield None
|
||||||
add(action.set_topic(template_))
|
add(action.set_topic(template_))
|
||||||
|
|
||||||
template_ = None
|
|
||||||
for template_ in templatable(config[CONF_PAYLOAD], arg_type, std_string):
|
for template_ in templatable(config[CONF_PAYLOAD], arg_type, std_string):
|
||||||
yield None
|
yield None
|
||||||
add(action.set_payload(template_))
|
add(action.set_payload(template_))
|
||||||
if CONF_QOS in config:
|
if CONF_QOS in config:
|
||||||
template_ = None
|
|
||||||
for template_ in templatable(config[CONF_QOS], arg_type, uint8):
|
for template_ in templatable(config[CONF_QOS], arg_type, uint8):
|
||||||
yield
|
yield
|
||||||
add(action.set_qos(template_))
|
add(action.set_qos(template_))
|
||||||
if CONF_RETAIN in config:
|
if CONF_RETAIN in config:
|
||||||
template_ = None
|
|
||||||
for template_ in templatable(config[CONF_RETAIN], arg_type, bool_):
|
for template_ in templatable(config[CONF_RETAIN], arg_type, bool_):
|
||||||
yield None
|
yield None
|
||||||
add(action.set_retain(template_))
|
add(action.set_retain(template_))
|
||||||
|
@ -299,7 +294,6 @@ def build_action(full_config, arg_type):
|
||||||
type = light.ToggleAction.template(template_arg)
|
type = light.ToggleAction.template(template_arg)
|
||||||
action = Pvariable(action_id, rhs, type=type)
|
action = Pvariable(action_id, rhs, type=type)
|
||||||
if CONF_TRANSITION_LENGTH in config:
|
if CONF_TRANSITION_LENGTH in config:
|
||||||
template_ = None
|
|
||||||
for template_ in templatable(config[CONF_TRANSITION_LENGTH], arg_type, uint32):
|
for template_ in templatable(config[CONF_TRANSITION_LENGTH], arg_type, uint32):
|
||||||
yield None
|
yield None
|
||||||
add(action.set_transition_length(template_))
|
add(action.set_transition_length(template_))
|
||||||
|
@ -311,7 +305,6 @@ def build_action(full_config, arg_type):
|
||||||
type = light.TurnOffAction.template(template_arg)
|
type = light.TurnOffAction.template(template_arg)
|
||||||
action = Pvariable(action_id, rhs, type=type)
|
action = Pvariable(action_id, rhs, type=type)
|
||||||
if CONF_TRANSITION_LENGTH in config:
|
if CONF_TRANSITION_LENGTH in config:
|
||||||
template_ = None
|
|
||||||
for template_ in templatable(config[CONF_TRANSITION_LENGTH], arg_type, uint32):
|
for template_ in templatable(config[CONF_TRANSITION_LENGTH], arg_type, uint32):
|
||||||
yield None
|
yield None
|
||||||
add(action.set_transition_length(template_))
|
add(action.set_transition_length(template_))
|
||||||
|
@ -323,42 +316,38 @@ def build_action(full_config, arg_type):
|
||||||
type = light.TurnOnAction.template(template_arg)
|
type = light.TurnOnAction.template(template_arg)
|
||||||
action = Pvariable(action_id, rhs, type=type)
|
action = Pvariable(action_id, rhs, type=type)
|
||||||
if CONF_TRANSITION_LENGTH in config:
|
if CONF_TRANSITION_LENGTH in config:
|
||||||
template_ = None
|
|
||||||
for template_ in templatable(config[CONF_TRANSITION_LENGTH], arg_type, uint32):
|
for template_ in templatable(config[CONF_TRANSITION_LENGTH], arg_type, uint32):
|
||||||
yield None
|
yield None
|
||||||
add(action.set_transition_length(template_))
|
add(action.set_transition_length(template_))
|
||||||
if CONF_FLASH_LENGTH in config:
|
if CONF_FLASH_LENGTH in config:
|
||||||
template_ = None
|
|
||||||
for template_ in templatable(config[CONF_FLASH_LENGTH], arg_type, uint32):
|
for template_ in templatable(config[CONF_FLASH_LENGTH], arg_type, uint32):
|
||||||
yield None
|
yield None
|
||||||
add(action.set_flash_length(template_))
|
add(action.set_flash_length(template_))
|
||||||
if CONF_BRIGHTNESS in config:
|
if CONF_BRIGHTNESS in config:
|
||||||
template_ = None
|
|
||||||
for template_ in templatable(config[CONF_BRIGHTNESS], arg_type, float_):
|
for template_ in templatable(config[CONF_BRIGHTNESS], arg_type, float_):
|
||||||
yield None
|
yield None
|
||||||
add(action.set_brightness(template_))
|
add(action.set_brightness(template_))
|
||||||
if CONF_RED in config:
|
if CONF_RED in config:
|
||||||
template_ = None
|
|
||||||
for template_ in templatable(config[CONF_RED], arg_type, float_):
|
for template_ in templatable(config[CONF_RED], arg_type, float_):
|
||||||
yield None
|
yield None
|
||||||
add(action.set_red(template_))
|
add(action.set_red(template_))
|
||||||
if CONF_GREEN in config:
|
if CONF_GREEN in config:
|
||||||
template_ = None
|
|
||||||
for template_ in templatable(config[CONF_GREEN], arg_type, float_):
|
for template_ in templatable(config[CONF_GREEN], arg_type, float_):
|
||||||
yield None
|
yield None
|
||||||
add(action.set_green(template_))
|
add(action.set_green(template_))
|
||||||
if CONF_BLUE in config:
|
if CONF_BLUE in config:
|
||||||
template_ = None
|
|
||||||
for template_ in templatable(config[CONF_BLUE], arg_type, float_):
|
for template_ in templatable(config[CONF_BLUE], arg_type, float_):
|
||||||
yield None
|
yield None
|
||||||
add(action.set_blue(template_))
|
add(action.set_blue(template_))
|
||||||
if CONF_WHITE in config:
|
if CONF_WHITE in config:
|
||||||
template_ = None
|
|
||||||
for template_ in templatable(config[CONF_WHITE], arg_type, float_):
|
for template_ in templatable(config[CONF_WHITE], arg_type, float_):
|
||||||
yield None
|
yield None
|
||||||
add(action.set_white(template_))
|
add(action.set_white(template_))
|
||||||
|
if CONF_COLOR_TEMPERATURE in config:
|
||||||
|
for template_ in templatable(config[CONF_COLOR_TEMPERATURE], arg_type, float_):
|
||||||
|
yield None
|
||||||
|
add(action.set_color_temperature(template_))
|
||||||
if CONF_EFFECT in config:
|
if CONF_EFFECT in config:
|
||||||
template_ = None
|
|
||||||
for template_ in templatable(config[CONF_EFFECT], arg_type, std_string):
|
for template_ in templatable(config[CONF_EFFECT], arg_type, std_string):
|
||||||
yield None
|
yield None
|
||||||
add(action.set_effect(template_))
|
add(action.set_effect(template_))
|
||||||
|
@ -418,12 +407,10 @@ def build_action(full_config, arg_type):
|
||||||
type = fan.TurnOnAction.template(arg_type)
|
type = fan.TurnOnAction.template(arg_type)
|
||||||
action = Pvariable(action_id, rhs, type=type)
|
action = Pvariable(action_id, rhs, type=type)
|
||||||
if CONF_OSCILLATING in config:
|
if CONF_OSCILLATING in config:
|
||||||
template_ = None
|
|
||||||
for template_ in templatable(config[CONF_OSCILLATING], arg_type, bool_):
|
for template_ in templatable(config[CONF_OSCILLATING], arg_type, bool_):
|
||||||
yield None
|
yield None
|
||||||
add(action.set_oscillating(template_))
|
add(action.set_oscillating(template_))
|
||||||
if CONF_SPEED in config:
|
if CONF_SPEED in config:
|
||||||
template_ = None
|
|
||||||
for template_ in templatable(config[CONF_SPEED], arg_type, fan.FanSpeed):
|
for template_ in templatable(config[CONF_SPEED], arg_type, fan.FanSpeed):
|
||||||
yield None
|
yield None
|
||||||
add(action.set_speed(template_))
|
add(action.set_speed(template_))
|
||||||
|
@ -446,7 +433,6 @@ def build_action(full_config, arg_type):
|
||||||
rhs = var.make_set_level_action(template_arg)
|
rhs = var.make_set_level_action(template_arg)
|
||||||
type = output.SetLevelAction.template(arg_type)
|
type = output.SetLevelAction.template(arg_type)
|
||||||
action = Pvariable(action_id, rhs, type=type)
|
action = Pvariable(action_id, rhs, type=type)
|
||||||
template_ = None
|
|
||||||
for template_ in templatable(config[CONF_LEVEL], arg_type, bool_):
|
for template_ in templatable(config[CONF_LEVEL], arg_type, bool_):
|
||||||
yield None
|
yield None
|
||||||
add(action.set_level(template_))
|
add(action.set_level(template_))
|
||||||
|
|
26
esphomeyaml/components/binary_sensor/nextion.py
Normal file
26
esphomeyaml/components/binary_sensor/nextion.py
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
import voluptuous as vol
|
||||||
|
|
||||||
|
import esphomeyaml.config_validation as cv
|
||||||
|
from esphomeyaml.components import binary_sensor
|
||||||
|
from esphomeyaml.components.display.nextion import Nextion
|
||||||
|
from esphomeyaml.const import CONF_COMPONENT_ID, CONF_NAME, CONF_PAGE_ID
|
||||||
|
from esphomeyaml.helpers import get_variable
|
||||||
|
|
||||||
|
DEPENDENCIES = ['display']
|
||||||
|
|
||||||
|
CONF_NEXTION_ID = 'nextion_id'
|
||||||
|
|
||||||
|
PLATFORM_SCHEMA = cv.nameable(binary_sensor.BINARY_SENSOR_PLATFORM_SCHEMA.extend({
|
||||||
|
vol.Required(CONF_PAGE_ID): cv.uint8_t,
|
||||||
|
vol.Required(CONF_COMPONENT_ID): cv.uint8_t,
|
||||||
|
cv.GenerateID(CONF_NEXTION_ID): cv.use_variable_id(Nextion)
|
||||||
|
}))
|
||||||
|
|
||||||
|
|
||||||
|
def to_code(config):
|
||||||
|
hub = None
|
||||||
|
for hub in get_variable(config[CONF_NEXTION_ID]):
|
||||||
|
yield
|
||||||
|
rhs = hub.make_touch_component(config[CONF_NAME], config[CONF_PAGE_ID],
|
||||||
|
config[CONF_COMPONENT_ID])
|
||||||
|
binary_sensor.register_binary_sensor(rhs, config)
|
|
@ -11,7 +11,7 @@ DallasComponent = sensor.sensor_ns.DallasComponent
|
||||||
CONFIG_SCHEMA = vol.All(cv.ensure_list, [vol.Schema({
|
CONFIG_SCHEMA = vol.All(cv.ensure_list, [vol.Schema({
|
||||||
cv.GenerateID(): cv.declare_variable_id(DallasComponent),
|
cv.GenerateID(): cv.declare_variable_id(DallasComponent),
|
||||||
vol.Required(CONF_PIN): pins.input_output_pin,
|
vol.Required(CONF_PIN): pins.input_output_pin,
|
||||||
vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds,
|
vol.Optional(CONF_UPDATE_INTERVAL): cv.update_interval,
|
||||||
})])
|
})])
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ def validate_rotation(value):
|
||||||
|
|
||||||
|
|
||||||
BASIC_DISPLAY_PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
BASIC_DISPLAY_PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||||
vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds,
|
vol.Optional(CONF_UPDATE_INTERVAL): cv.update_interval,
|
||||||
vol.Optional(CONF_LAMBDA): cv.lambda_,
|
vol.Optional(CONF_LAMBDA): cv.lambda_,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,8 @@ import voluptuous as vol
|
||||||
import esphomeyaml.config_validation as cv
|
import esphomeyaml.config_validation as cv
|
||||||
from esphomeyaml import pins
|
from esphomeyaml import pins
|
||||||
from esphomeyaml.components import display
|
from esphomeyaml.components import display
|
||||||
from esphomeyaml.const import CONF_DIMENSIONS, CONF_ENABLE_PIN, CONF_ID, CONF_LAMBDA, CONF_DATA_PINS, \
|
from esphomeyaml.const import CONF_DATA_PINS, CONF_DIMENSIONS, CONF_ENABLE_PIN, CONF_ID, \
|
||||||
CONF_RS_PIN, CONF_RW_PIN
|
CONF_LAMBDA, CONF_RS_PIN, CONF_RW_PIN
|
||||||
from esphomeyaml.helpers import App, Pvariable, add, gpio_output_pin_expression, process_lambda
|
from esphomeyaml.helpers import App, Pvariable, add, gpio_output_pin_expression, process_lambda
|
||||||
|
|
||||||
GPIOLCDDisplay = display.display_ns.GPIOLCDDisplay
|
GPIOLCDDisplay = display.display_ns.GPIOLCDDisplay
|
||||||
|
|
32
esphomeyaml/components/display/nextion.py
Normal file
32
esphomeyaml/components/display/nextion.py
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
import esphomeyaml.config_validation as cv
|
||||||
|
from esphomeyaml.components import display
|
||||||
|
from esphomeyaml.components.uart import UARTComponent
|
||||||
|
from esphomeyaml.const import CONF_ID, CONF_LAMBDA, CONF_UART_ID
|
||||||
|
from esphomeyaml.helpers import App, Pvariable, add, get_variable, process_lambda
|
||||||
|
|
||||||
|
DEPENDENCIES = ['uart']
|
||||||
|
|
||||||
|
Nextion = display.display_ns.Nextion
|
||||||
|
NextionRef = Nextion.operator('ref')
|
||||||
|
|
||||||
|
PLATFORM_SCHEMA = display.BASIC_DISPLAY_PLATFORM_SCHEMA.extend({
|
||||||
|
cv.GenerateID(): cv.declare_variable_id(Nextion),
|
||||||
|
cv.GenerateID(CONF_UART_ID): cv.use_variable_id(UARTComponent),
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
def to_code(config):
|
||||||
|
for uart in get_variable(config[CONF_UART_ID]):
|
||||||
|
yield
|
||||||
|
rhs = App.make_nextion(uart)
|
||||||
|
nextion = Pvariable(config[CONF_ID], rhs)
|
||||||
|
|
||||||
|
if CONF_LAMBDA in config:
|
||||||
|
for lambda_ in process_lambda(config[CONF_LAMBDA], [(NextionRef, 'it')]):
|
||||||
|
yield
|
||||||
|
add(nextion.set_writer(lambda_))
|
||||||
|
|
||||||
|
display.setup_display(nextion, config)
|
||||||
|
|
||||||
|
|
||||||
|
BUILD_FLAGS = '-DUSE_NEXTION'
|
34
esphomeyaml/components/light/cwww.py
Normal file
34
esphomeyaml/components/light/cwww.py
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
import voluptuous as vol
|
||||||
|
|
||||||
|
import esphomeyaml.config_validation as cv
|
||||||
|
from esphomeyaml.components import light
|
||||||
|
from esphomeyaml.components.light.rgbww import validate_cold_white_colder, \
|
||||||
|
validate_color_temperature
|
||||||
|
from esphomeyaml.const import CONF_COLD_WHITE, CONF_COLD_WHITE_COLOR_TEMPERATURE, \
|
||||||
|
CONF_DEFAULT_TRANSITION_LENGTH, CONF_EFFECTS, CONF_GAMMA_CORRECT, CONF_MAKE_ID, \
|
||||||
|
CONF_NAME, CONF_WARM_WHITE, CONF_WARM_WHITE_COLOR_TEMPERATURE
|
||||||
|
from esphomeyaml.helpers import App, get_variable, variable
|
||||||
|
|
||||||
|
PLATFORM_SCHEMA = cv.nameable(light.LIGHT_PLATFORM_SCHEMA.extend({
|
||||||
|
cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(light.MakeLight),
|
||||||
|
vol.Required(CONF_COLD_WHITE): cv.use_variable_id(None),
|
||||||
|
vol.Required(CONF_WARM_WHITE): cv.use_variable_id(None),
|
||||||
|
vol.Required(CONF_COLD_WHITE_COLOR_TEMPERATURE): validate_color_temperature,
|
||||||
|
vol.Required(CONF_WARM_WHITE_COLOR_TEMPERATURE): validate_color_temperature,
|
||||||
|
|
||||||
|
vol.Optional(CONF_GAMMA_CORRECT): cv.positive_float,
|
||||||
|
vol.Optional(CONF_DEFAULT_TRANSITION_LENGTH): cv.positive_time_period_milliseconds,
|
||||||
|
vol.Optional(CONF_EFFECTS): light.validate_effects(light.RGB_EFFECTS),
|
||||||
|
}), validate_cold_white_colder)
|
||||||
|
|
||||||
|
|
||||||
|
def to_code(config):
|
||||||
|
for cold_white in get_variable(config[CONF_COLD_WHITE]):
|
||||||
|
yield
|
||||||
|
for warm_white in get_variable(config[CONF_WARM_WHITE]):
|
||||||
|
yield
|
||||||
|
rhs = App.make_cwww_light(config[CONF_NAME], config[CONF_COLD_WHITE_COLOR_TEMPERATURE],
|
||||||
|
config[CONF_WARM_WHITE_COLOR_TEMPERATURE],
|
||||||
|
cold_white, warm_white)
|
||||||
|
light_struct = variable(config[CONF_MAKE_ID], rhs)
|
||||||
|
light.setup_light(light_struct.Pstate, light_struct.Pmqtt, config)
|
62
esphomeyaml/components/light/rgbww.py
Normal file
62
esphomeyaml/components/light/rgbww.py
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
import voluptuous as vol
|
||||||
|
|
||||||
|
import esphomeyaml.config_validation as cv
|
||||||
|
from esphomeyaml.components import light
|
||||||
|
from esphomeyaml.const import CONF_BLUE, CONF_COLD_WHITE, CONF_COLD_WHITE_COLOR_TEMPERATURE, \
|
||||||
|
CONF_DEFAULT_TRANSITION_LENGTH, CONF_EFFECTS, CONF_GAMMA_CORRECT, CONF_GREEN, CONF_MAKE_ID, \
|
||||||
|
CONF_NAME, CONF_RED, CONF_WARM_WHITE, CONF_WARM_WHITE_COLOR_TEMPERATURE
|
||||||
|
from esphomeyaml.helpers import App, get_variable, variable
|
||||||
|
|
||||||
|
|
||||||
|
def validate_color_temperature(value):
|
||||||
|
try:
|
||||||
|
val = cv.float_with_unit('Color Temperature', 'mireds')(value)
|
||||||
|
except vol.Invalid:
|
||||||
|
val = 1000000.0 / cv.float_with_unit('Color Temperature', 'K')(value)
|
||||||
|
if val < 0:
|
||||||
|
raise vol.Invalid("Color temperature cannot be negative")
|
||||||
|
return val
|
||||||
|
|
||||||
|
|
||||||
|
def validate_cold_white_colder(value):
|
||||||
|
cw = value[CONF_COLD_WHITE_COLOR_TEMPERATURE]
|
||||||
|
ww = value[CONF_WARM_WHITE_COLOR_TEMPERATURE]
|
||||||
|
if cw > ww:
|
||||||
|
raise vol.Invalid("Cold white color temperature cannot be higher than warm white")
|
||||||
|
if cw == ww:
|
||||||
|
raise vol.Invalid("Cold white color temperature cannot be the same as warm white")
|
||||||
|
return value
|
||||||
|
|
||||||
|
|
||||||
|
PLATFORM_SCHEMA = cv.nameable(light.LIGHT_PLATFORM_SCHEMA.extend({
|
||||||
|
cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(light.MakeLight),
|
||||||
|
vol.Required(CONF_RED): cv.use_variable_id(None),
|
||||||
|
vol.Required(CONF_GREEN): cv.use_variable_id(None),
|
||||||
|
vol.Required(CONF_BLUE): cv.use_variable_id(None),
|
||||||
|
vol.Required(CONF_COLD_WHITE): cv.use_variable_id(None),
|
||||||
|
vol.Required(CONF_WARM_WHITE): cv.use_variable_id(None),
|
||||||
|
vol.Required(CONF_COLD_WHITE_COLOR_TEMPERATURE): validate_color_temperature,
|
||||||
|
vol.Required(CONF_WARM_WHITE_COLOR_TEMPERATURE): validate_color_temperature,
|
||||||
|
|
||||||
|
vol.Optional(CONF_GAMMA_CORRECT): cv.positive_float,
|
||||||
|
vol.Optional(CONF_DEFAULT_TRANSITION_LENGTH): cv.positive_time_period_milliseconds,
|
||||||
|
vol.Optional(CONF_EFFECTS): light.validate_effects(light.RGB_EFFECTS),
|
||||||
|
}), validate_cold_white_colder)
|
||||||
|
|
||||||
|
|
||||||
|
def to_code(config):
|
||||||
|
for red in get_variable(config[CONF_RED]):
|
||||||
|
yield
|
||||||
|
for green in get_variable(config[CONF_GREEN]):
|
||||||
|
yield
|
||||||
|
for blue in get_variable(config[CONF_BLUE]):
|
||||||
|
yield
|
||||||
|
for cold_white in get_variable(config[CONF_COLD_WHITE]):
|
||||||
|
yield
|
||||||
|
for warm_white in get_variable(config[CONF_WARM_WHITE]):
|
||||||
|
yield
|
||||||
|
rhs = App.make_rgbww_light(config[CONF_NAME], config[CONF_COLD_WHITE_COLOR_TEMPERATURE],
|
||||||
|
config[CONF_WARM_WHITE_COLOR_TEMPERATURE],
|
||||||
|
red, green, blue, cold_white, warm_white)
|
||||||
|
light_struct = variable(config[CONF_MAKE_ID], rhs)
|
||||||
|
light.setup_light(light_struct.Pstate, light_struct.Pmqtt, config)
|
|
@ -15,7 +15,7 @@ CONFIG_SCHEMA = vol.All(cv.ensure_list, [vol.Schema({
|
||||||
cv.GenerateID(): cv.declare_variable_id(PN532Component),
|
cv.GenerateID(): cv.declare_variable_id(PN532Component),
|
||||||
cv.GenerateID(CONF_SPI_ID): cv.use_variable_id(SPIComponent),
|
cv.GenerateID(CONF_SPI_ID): cv.use_variable_id(SPIComponent),
|
||||||
vol.Required(CONF_CS_PIN): pins.gpio_output_pin_schema,
|
vol.Required(CONF_CS_PIN): pins.gpio_output_pin_schema,
|
||||||
vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds,
|
vol.Optional(CONF_UPDATE_INTERVAL): cv.update_interval,
|
||||||
})])
|
})])
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ PLATFORM_SCHEMA = cv.nameable(sensor.SENSOR_PLATFORM_SCHEMA.extend({
|
||||||
cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeADCSensor),
|
cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeADCSensor),
|
||||||
vol.Required(CONF_PIN): validate_adc_pin,
|
vol.Required(CONF_PIN): validate_adc_pin,
|
||||||
vol.Optional(CONF_ATTENUATION): vol.All(cv.only_on_esp32, cv.one_of(*ATTENUATION_MODES)),
|
vol.Optional(CONF_ATTENUATION): vol.All(cv.only_on_esp32, cv.one_of(*ATTENUATION_MODES)),
|
||||||
vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds,
|
vol.Optional(CONF_UPDATE_INTERVAL): cv.update_interval,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ PLATFORM_SCHEMA = cv.nameable(sensor.SENSOR_PLATFORM_SCHEMA.extend({
|
||||||
vol.Required(CONF_MULTIPLEXER): validate_mux,
|
vol.Required(CONF_MULTIPLEXER): validate_mux,
|
||||||
vol.Required(CONF_GAIN): validate_gain,
|
vol.Required(CONF_GAIN): validate_gain,
|
||||||
cv.GenerateID(CONF_ADS1115_ID): cv.use_variable_id(ADS1115Component),
|
cv.GenerateID(CONF_ADS1115_ID): cv.use_variable_id(ADS1115Component),
|
||||||
vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds,
|
vol.Optional(CONF_UPDATE_INTERVAL): cv.update_interval,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ PLATFORM_SCHEMA = cv.nameable(sensor.SENSOR_PLATFORM_SCHEMA.extend({
|
||||||
cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeBH1750Sensor),
|
cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeBH1750Sensor),
|
||||||
vol.Optional(CONF_ADDRESS, default=0x23): cv.i2c_address,
|
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_RESOLUTION): vol.All(cv.positive_float, cv.one_of(*BH1750_RESOLUTIONS)),
|
||||||
vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds,
|
vol.Optional(CONF_UPDATE_INTERVAL): cv.update_interval,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ PLATFORM_SCHEMA = sensor.PLATFORM_SCHEMA.extend({
|
||||||
vol.Required(CONF_PRESSURE): cv.nameable(BME280_OVERSAMPLING_SENSOR_SCHEMA),
|
vol.Required(CONF_PRESSURE): cv.nameable(BME280_OVERSAMPLING_SENSOR_SCHEMA),
|
||||||
vol.Required(CONF_HUMIDITY): cv.nameable(BME280_OVERSAMPLING_SENSOR_SCHEMA),
|
vol.Required(CONF_HUMIDITY): cv.nameable(BME280_OVERSAMPLING_SENSOR_SCHEMA),
|
||||||
vol.Optional(CONF_IIR_FILTER): vol.All(vol.Upper, cv.one_of(*IIR_FILTER_OPTIONS)),
|
vol.Optional(CONF_IIR_FILTER): vol.All(vol.Upper, cv.one_of(*IIR_FILTER_OPTIONS)),
|
||||||
vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds,
|
vol.Optional(CONF_UPDATE_INTERVAL): cv.update_interval,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ PLATFORM_SCHEMA = sensor.PLATFORM_SCHEMA.extend({
|
||||||
vol.Optional(CONF_DURATION, default='150ms'): vol.All(
|
vol.Optional(CONF_DURATION, default='150ms'): vol.All(
|
||||||
cv.positive_time_period_milliseconds, vol.Range(max=core.TimePeriod(milliseconds=4032)))
|
cv.positive_time_period_milliseconds, vol.Range(max=core.TimePeriod(milliseconds=4032)))
|
||||||
}, cv.has_at_least_one_key(CONF_TEMPERATURE, CONF_DURATION)))),
|
}, cv.has_at_least_one_key(CONF_TEMPERATURE, CONF_DURATION)))),
|
||||||
vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds,
|
vol.Optional(CONF_UPDATE_INTERVAL): cv.update_interval,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ PLATFORM_SCHEMA = sensor.PLATFORM_SCHEMA.extend({
|
||||||
vol.Required(CONF_TEMPERATURE): cv.nameable(sensor.SENSOR_SCHEMA),
|
vol.Required(CONF_TEMPERATURE): cv.nameable(sensor.SENSOR_SCHEMA),
|
||||||
vol.Required(CONF_PRESSURE): cv.nameable(sensor.SENSOR_SCHEMA),
|
vol.Required(CONF_PRESSURE): cv.nameable(sensor.SENSOR_SCHEMA),
|
||||||
vol.Optional(CONF_ADDRESS): cv.i2c_address,
|
vol.Optional(CONF_ADDRESS): cv.i2c_address,
|
||||||
vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds,
|
vol.Optional(CONF_UPDATE_INTERVAL): cv.update_interval,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ PLATFORM_SCHEMA = sensor.PLATFORM_SCHEMA.extend({
|
||||||
vol.Required(CONF_TEMPERATURE): cv.nameable(BMP280_OVERSAMPLING_SENSOR_SCHEMA),
|
vol.Required(CONF_TEMPERATURE): cv.nameable(BMP280_OVERSAMPLING_SENSOR_SCHEMA),
|
||||||
vol.Required(CONF_PRESSURE): cv.nameable(BMP280_OVERSAMPLING_SENSOR_SCHEMA),
|
vol.Required(CONF_PRESSURE): cv.nameable(BMP280_OVERSAMPLING_SENSOR_SCHEMA),
|
||||||
vol.Optional(CONF_IIR_FILTER): vol.All(vol.Upper, cv.one_of(*IIR_FILTER_OPTIONS)),
|
vol.Optional(CONF_IIR_FILTER): vol.All(vol.Upper, cv.one_of(*IIR_FILTER_OPTIONS)),
|
||||||
vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds,
|
vol.Optional(CONF_UPDATE_INTERVAL): cv.update_interval,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ PLATFORM_SCHEMA = sensor.PLATFORM_SCHEMA.extend({
|
||||||
vol.Required(CONF_TEMPERATURE): cv.nameable(sensor.SENSOR_SCHEMA),
|
vol.Required(CONF_TEMPERATURE): cv.nameable(sensor.SENSOR_SCHEMA),
|
||||||
vol.Required(CONF_HUMIDITY): cv.nameable(sensor.SENSOR_SCHEMA),
|
vol.Required(CONF_HUMIDITY): cv.nameable(sensor.SENSOR_SCHEMA),
|
||||||
vol.Optional(CONF_MODEL): vol.All(vol.Upper, cv.one_of(*DHT_MODELS)),
|
vol.Optional(CONF_MODEL): vol.All(vol.Upper, cv.one_of(*DHT_MODELS)),
|
||||||
vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds,
|
vol.Optional(CONF_UPDATE_INTERVAL): cv.update_interval,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ PLATFORM_SCHEMA = sensor.PLATFORM_SCHEMA.extend({
|
||||||
cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeDHT12Sensor),
|
cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeDHT12Sensor),
|
||||||
vol.Required(CONF_TEMPERATURE): cv.nameable(sensor.SENSOR_SCHEMA),
|
vol.Required(CONF_TEMPERATURE): cv.nameable(sensor.SENSOR_SCHEMA),
|
||||||
vol.Required(CONF_HUMIDITY): cv.nameable(sensor.SENSOR_SCHEMA),
|
vol.Required(CONF_HUMIDITY): cv.nameable(sensor.SENSOR_SCHEMA),
|
||||||
vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds,
|
vol.Optional(CONF_UPDATE_INTERVAL): cv.update_interval,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ MakeDutyCycleSensor = Application.MakeDutyCycleSensor
|
||||||
PLATFORM_SCHEMA = cv.nameable(sensor.SENSOR_PLATFORM_SCHEMA.extend({
|
PLATFORM_SCHEMA = cv.nameable(sensor.SENSOR_PLATFORM_SCHEMA.extend({
|
||||||
cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeDutyCycleSensor),
|
cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeDutyCycleSensor),
|
||||||
vol.Required(CONF_PIN): pins.internal_gpio_input_pin_schema,
|
vol.Required(CONF_PIN): pins.internal_gpio_input_pin_schema,
|
||||||
vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds,
|
vol.Optional(CONF_UPDATE_INTERVAL): cv.update_interval,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ MakeESP32HallSensor = Application.MakeESP32HallSensor
|
||||||
|
|
||||||
PLATFORM_SCHEMA = cv.nameable(sensor.SENSOR_PLATFORM_SCHEMA.extend({
|
PLATFORM_SCHEMA = cv.nameable(sensor.SENSOR_PLATFORM_SCHEMA.extend({
|
||||||
cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeESP32HallSensor),
|
cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeESP32HallSensor),
|
||||||
vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds,
|
vol.Optional(CONF_UPDATE_INTERVAL): cv.update_interval,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ PLATFORM_SCHEMA = sensor.PLATFORM_SCHEMA.extend({
|
||||||
cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeHDC1080Sensor),
|
cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeHDC1080Sensor),
|
||||||
vol.Required(CONF_TEMPERATURE): cv.nameable(sensor.SENSOR_SCHEMA),
|
vol.Required(CONF_TEMPERATURE): cv.nameable(sensor.SENSOR_SCHEMA),
|
||||||
vol.Required(CONF_HUMIDITY): cv.nameable(sensor.SENSOR_SCHEMA),
|
vol.Required(CONF_HUMIDITY): cv.nameable(sensor.SENSOR_SCHEMA),
|
||||||
vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds,
|
vol.Optional(CONF_UPDATE_INTERVAL): cv.update_interval,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
57
esphomeyaml/components/sensor/hlw8012.py
Normal file
57
esphomeyaml/components/sensor/hlw8012.py
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
import voluptuous as vol
|
||||||
|
|
||||||
|
import esphomeyaml.config_validation as cv
|
||||||
|
from esphomeyaml import pins
|
||||||
|
from esphomeyaml.components import sensor
|
||||||
|
from esphomeyaml.const import CONF_CF1_PIN, CONF_CF_PIN, CONF_CHANGE_MODE_EVERY, CONF_CURRENT, \
|
||||||
|
CONF_CURRENT_RESISTOR, CONF_ID, CONF_NAME, CONF_POWER, CONF_SEL_PIN, CONF_UPDATE_INTERVAL, \
|
||||||
|
CONF_VOLTAGE, CONF_VOLTAGE_DIVIDER
|
||||||
|
from esphomeyaml.helpers import App, Pvariable, add, gpio_output_pin_expression
|
||||||
|
|
||||||
|
HLW8012Component = sensor.sensor_ns.HLW8012Component
|
||||||
|
HLW8012VoltageSensor = sensor.sensor_ns.HLW8012VoltageSensor
|
||||||
|
HLW8012CurrentSensor = sensor.sensor_ns.HLW8012CurrentSensor
|
||||||
|
HLW8012PowerSensor = sensor.sensor_ns.HLW8012PowerSensor
|
||||||
|
|
||||||
|
PLATFORM_SCHEMA = vol.All(sensor.PLATFORM_SCHEMA.extend({
|
||||||
|
cv.GenerateID(): cv.declare_variable_id(HLW8012Component),
|
||||||
|
vol.Required(CONF_SEL_PIN): pins.gpio_output_pin_schema,
|
||||||
|
vol.Required(CONF_CF_PIN): pins.input_pin,
|
||||||
|
vol.Required(CONF_CF1_PIN): pins.input_pin,
|
||||||
|
|
||||||
|
vol.Optional(CONF_VOLTAGE): cv.nameable(sensor.SENSOR_SCHEMA),
|
||||||
|
vol.Optional(CONF_CURRENT): cv.nameable(sensor.SENSOR_SCHEMA),
|
||||||
|
vol.Optional(CONF_POWER): cv.nameable(sensor.SENSOR_SCHEMA),
|
||||||
|
|
||||||
|
vol.Optional(CONF_CURRENT_RESISTOR): cv.resistance,
|
||||||
|
vol.Optional(CONF_VOLTAGE_DIVIDER): cv.positive_float,
|
||||||
|
vol.Optional(CONF_CHANGE_MODE_EVERY): vol.All(cv.uint32_t, vol.Range(min=1)),
|
||||||
|
vol.Optional(CONF_UPDATE_INTERVAL): cv.update_interval,
|
||||||
|
}), cv.has_at_least_one_key(CONF_VOLTAGE, CONF_CURRENT, CONF_POWER))
|
||||||
|
|
||||||
|
|
||||||
|
def to_code(config):
|
||||||
|
sel = None
|
||||||
|
for sel in gpio_output_pin_expression(config[CONF_SEL_PIN]):
|
||||||
|
yield
|
||||||
|
|
||||||
|
rhs = App.make_hlw8012(sel, config[CONF_CF_PIN], config[CONF_CF1_PIN],
|
||||||
|
config.get(CONF_UPDATE_INTERVAL))
|
||||||
|
hlw = Pvariable(config[CONF_ID], rhs)
|
||||||
|
|
||||||
|
if CONF_VOLTAGE in config:
|
||||||
|
conf = config[CONF_VOLTAGE]
|
||||||
|
sensor.register_sensor(hlw.make_voltage_sensor(conf[CONF_NAME]), conf)
|
||||||
|
if CONF_CURRENT in config:
|
||||||
|
conf = config[CONF_VOLTAGE]
|
||||||
|
sensor.register_sensor(hlw.make_current_sensor(conf[CONF_NAME]), conf)
|
||||||
|
if CONF_POWER in config:
|
||||||
|
conf = config[CONF_VOLTAGE]
|
||||||
|
sensor.register_sensor(hlw.make_power_sensor(conf[CONF_NAME]), conf)
|
||||||
|
if CONF_CURRENT_RESISTOR in config:
|
||||||
|
add(hlw.set_current_resistor(config[CONF_CURRENT_RESISTOR]))
|
||||||
|
if CONF_CHANGE_MODE_EVERY in config:
|
||||||
|
add(hlw.set_change_mode_every(config[CONF_CHANGE_MODE_EVERY]))
|
||||||
|
|
||||||
|
|
||||||
|
BUILD_FLAGS = '-DUSE_HLW8012'
|
|
@ -43,7 +43,7 @@ PLATFORM_SCHEMA = vol.All(sensor.PLATFORM_SCHEMA.extend({
|
||||||
vol.Optional(CONF_FIELD_STRENGTH_Y): cv.nameable(sensor.SENSOR_SCHEMA),
|
vol.Optional(CONF_FIELD_STRENGTH_Y): cv.nameable(sensor.SENSOR_SCHEMA),
|
||||||
vol.Optional(CONF_FIELD_STRENGTH_Z): cv.nameable(sensor.SENSOR_SCHEMA),
|
vol.Optional(CONF_FIELD_STRENGTH_Z): cv.nameable(sensor.SENSOR_SCHEMA),
|
||||||
vol.Optional(CONF_HEADING): cv.nameable(sensor.SENSOR_SCHEMA),
|
vol.Optional(CONF_HEADING): cv.nameable(sensor.SENSOR_SCHEMA),
|
||||||
vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds,
|
vol.Optional(CONF_UPDATE_INTERVAL): cv.update_interval,
|
||||||
vol.Optional(CONF_RANGE): validate_range,
|
vol.Optional(CONF_RANGE): validate_range,
|
||||||
}), cv.has_at_least_one_key(CONF_FIELD_STRENGTH_X, CONF_FIELD_STRENGTH_Y, CONF_FIELD_STRENGTH_Z,
|
}), cv.has_at_least_one_key(CONF_FIELD_STRENGTH_X, CONF_FIELD_STRENGTH_Y, CONF_FIELD_STRENGTH_Z,
|
||||||
CONF_HEADING))
|
CONF_HEADING))
|
||||||
|
|
|
@ -14,7 +14,7 @@ PLATFORM_SCHEMA = sensor.PLATFORM_SCHEMA.extend({
|
||||||
cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeHTU21DSensor),
|
cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeHTU21DSensor),
|
||||||
vol.Required(CONF_TEMPERATURE): cv.nameable(sensor.SENSOR_SCHEMA),
|
vol.Required(CONF_TEMPERATURE): cv.nameable(sensor.SENSOR_SCHEMA),
|
||||||
vol.Required(CONF_HUMIDITY): cv.nameable(sensor.SENSOR_SCHEMA),
|
vol.Required(CONF_HUMIDITY): cv.nameable(sensor.SENSOR_SCHEMA),
|
||||||
vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds,
|
vol.Optional(CONF_UPDATE_INTERVAL): cv.update_interval,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ PLATFORM_SCHEMA = cv.nameable(sensor.SENSOR_PLATFORM_SCHEMA.extend({
|
||||||
vol.Required(CONF_DOUT_PIN): pins.gpio_input_pin_schema,
|
vol.Required(CONF_DOUT_PIN): pins.gpio_input_pin_schema,
|
||||||
vol.Required(CONF_CLK_PIN): pins.gpio_output_pin_schema,
|
vol.Required(CONF_CLK_PIN): pins.gpio_output_pin_schema,
|
||||||
vol.Optional(CONF_GAIN): vol.All(cv.int_, cv.one_of(*GAINS)),
|
vol.Optional(CONF_GAIN): vol.All(cv.int_, cv.one_of(*GAINS)),
|
||||||
vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds,
|
vol.Optional(CONF_UPDATE_INTERVAL): cv.update_interval,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ PLATFORM_SCHEMA = vol.All(sensor.PLATFORM_SCHEMA.extend({
|
||||||
vol.Range(min=0.0, max=32.0)),
|
vol.Range(min=0.0, max=32.0)),
|
||||||
vol.Optional(CONF_MAX_VOLTAGE, default=32.0): vol.All(cv.voltage, vol.Range(min=0.0, max=32.0)),
|
vol.Optional(CONF_MAX_VOLTAGE, default=32.0): vol.All(cv.voltage, vol.Range(min=0.0, max=32.0)),
|
||||||
vol.Optional(CONF_MAX_CURRENT, default=3.2): vol.All(cv.current, vol.Range(min=0.0)),
|
vol.Optional(CONF_MAX_CURRENT, default=3.2): vol.All(cv.current, vol.Range(min=0.0)),
|
||||||
vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds,
|
vol.Optional(CONF_UPDATE_INTERVAL): cv.update_interval,
|
||||||
}), cv.has_at_least_one_key(CONF_BUS_VOLTAGE, CONF_SHUNT_VOLTAGE, CONF_CURRENT,
|
}), cv.has_at_least_one_key(CONF_BUS_VOLTAGE, CONF_SHUNT_VOLTAGE, CONF_CURRENT,
|
||||||
CONF_POWER))
|
CONF_POWER))
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ PLATFORM_SCHEMA = sensor.PLATFORM_SCHEMA.extend({
|
||||||
vol.Optional(CONF_CHANNEL_1): INA3221_CHANNEL_SCHEMA,
|
vol.Optional(CONF_CHANNEL_1): INA3221_CHANNEL_SCHEMA,
|
||||||
vol.Optional(CONF_CHANNEL_2): INA3221_CHANNEL_SCHEMA,
|
vol.Optional(CONF_CHANNEL_2): INA3221_CHANNEL_SCHEMA,
|
||||||
vol.Optional(CONF_CHANNEL_3): INA3221_CHANNEL_SCHEMA,
|
vol.Optional(CONF_CHANNEL_3): INA3221_CHANNEL_SCHEMA,
|
||||||
vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds,
|
vol.Optional(CONF_UPDATE_INTERVAL): cv.update_interval,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ PLATFORM_SCHEMA = cv.nameable(sensor.SENSOR_PLATFORM_SCHEMA.extend({
|
||||||
cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeMAX6675Sensor),
|
cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeMAX6675Sensor),
|
||||||
cv.GenerateID(CONF_SPI_ID): cv.use_variable_id(SPIComponent),
|
cv.GenerateID(CONF_SPI_ID): cv.use_variable_id(SPIComponent),
|
||||||
vol.Required(CONF_CS_PIN): pins.gpio_output_pin_schema,
|
vol.Required(CONF_CS_PIN): pins.gpio_output_pin_schema,
|
||||||
vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds,
|
vol.Optional(CONF_UPDATE_INTERVAL): cv.update_interval,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ PLATFORM_SCHEMA = sensor.PLATFORM_SCHEMA.extend({
|
||||||
cv.GenerateID(CONF_UART_ID): cv.use_variable_id(UARTComponent),
|
cv.GenerateID(CONF_UART_ID): cv.use_variable_id(UARTComponent),
|
||||||
vol.Required(CONF_CO2): cv.nameable(sensor.SENSOR_SCHEMA),
|
vol.Required(CONF_CO2): cv.nameable(sensor.SENSOR_SCHEMA),
|
||||||
vol.Optional(CONF_TEMPERATURE): cv.nameable(sensor.SENSOR_SCHEMA),
|
vol.Optional(CONF_TEMPERATURE): cv.nameable(sensor.SENSOR_SCHEMA),
|
||||||
vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds,
|
vol.Optional(CONF_UPDATE_INTERVAL): cv.update_interval,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ PLATFORM_SCHEMA = vol.All(sensor.PLATFORM_SCHEMA.extend({
|
||||||
vol.Optional(CONF_GYRO_Y): cv.nameable(sensor.SENSOR_SCHEMA),
|
vol.Optional(CONF_GYRO_Y): cv.nameable(sensor.SENSOR_SCHEMA),
|
||||||
vol.Optional(CONF_GYRO_Z): cv.nameable(sensor.SENSOR_SCHEMA),
|
vol.Optional(CONF_GYRO_Z): cv.nameable(sensor.SENSOR_SCHEMA),
|
||||||
vol.Optional(CONF_TEMPERATURE): cv.nameable(sensor.SENSOR_SCHEMA),
|
vol.Optional(CONF_TEMPERATURE): cv.nameable(sensor.SENSOR_SCHEMA),
|
||||||
vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds,
|
vol.Optional(CONF_UPDATE_INTERVAL): cv.update_interval,
|
||||||
}), cv.has_at_least_one_key(CONF_ACCEL_X, CONF_ACCEL_Y, CONF_ACCEL_Z,
|
}), cv.has_at_least_one_key(CONF_ACCEL_X, CONF_ACCEL_Y, CONF_ACCEL_Z,
|
||||||
CONF_GYRO_X, CONF_GYRO_Y, CONF_GYRO_Z))
|
CONF_GYRO_X, CONF_GYRO_Y, CONF_GYRO_Z))
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ PLATFORM_SCHEMA = sensor.PLATFORM_SCHEMA.extend({
|
||||||
vol.Optional(CONF_ADDRESS): cv.i2c_address,
|
vol.Optional(CONF_ADDRESS): cv.i2c_address,
|
||||||
vol.Required(CONF_TEMPERATURE): cv.nameable(sensor.SENSOR_SCHEMA),
|
vol.Required(CONF_TEMPERATURE): cv.nameable(sensor.SENSOR_SCHEMA),
|
||||||
vol.Required(CONF_PRESSURE): cv.nameable(sensor.SENSOR_SCHEMA),
|
vol.Required(CONF_PRESSURE): cv.nameable(sensor.SENSOR_SCHEMA),
|
||||||
vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds,
|
vol.Optional(CONF_UPDATE_INTERVAL): cv.update_interval,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ PLATFORM_SCHEMA = cv.nameable(sensor.SENSOR_PLATFORM_SCHEMA.extend({
|
||||||
vol.Required(CONF_FALLING_EDGE): COUNT_MODE_SCHEMA,
|
vol.Required(CONF_FALLING_EDGE): COUNT_MODE_SCHEMA,
|
||||||
}),
|
}),
|
||||||
vol.Optional(CONF_INTERNAL_FILTER): validate_internal_filter,
|
vol.Optional(CONF_INTERNAL_FILTER): validate_internal_filter,
|
||||||
vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds,
|
vol.Optional(CONF_UPDATE_INTERVAL): cv.update_interval,
|
||||||
|
|
||||||
vol.Optional(CONF_PULL_MODE): cv.invalid("The pull_mode option has been removed in 1.7.0, "
|
vol.Optional(CONF_PULL_MODE): cv.invalid("The pull_mode option has been removed in 1.7.0, "
|
||||||
"please use the pin mode schema now.")
|
"please use the pin mode schema now.")
|
||||||
|
|
|
@ -15,7 +15,7 @@ PLATFORM_SCHEMA = sensor.PLATFORM_SCHEMA.extend({
|
||||||
vol.Required(CONF_TEMPERATURE): cv.nameable(sensor.SENSOR_SCHEMA),
|
vol.Required(CONF_TEMPERATURE): cv.nameable(sensor.SENSOR_SCHEMA),
|
||||||
vol.Required(CONF_HUMIDITY): cv.nameable(sensor.SENSOR_SCHEMA),
|
vol.Required(CONF_HUMIDITY): cv.nameable(sensor.SENSOR_SCHEMA),
|
||||||
vol.Optional(CONF_ADDRESS, default=0x44): cv.i2c_address,
|
vol.Optional(CONF_ADDRESS, default=0x44): cv.i2c_address,
|
||||||
vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds,
|
vol.Optional(CONF_UPDATE_INTERVAL): cv.update_interval,
|
||||||
|
|
||||||
vol.Optional(CONF_ACCURACY): cv.invalid("The accuracy option has been removed and now "
|
vol.Optional(CONF_ACCURACY): cv.invalid("The accuracy option has been removed and now "
|
||||||
"defaults to HIGH."),
|
"defaults to HIGH."),
|
||||||
|
|
|
@ -43,7 +43,7 @@ PLATFORM_SCHEMA = vol.All(sensor.PLATFORM_SCHEMA.extend({
|
||||||
vol.Optional(CONF_COLOR_TEMPERATURE): cv.nameable(sensor.SENSOR_SCHEMA),
|
vol.Optional(CONF_COLOR_TEMPERATURE): cv.nameable(sensor.SENSOR_SCHEMA),
|
||||||
vol.Optional(CONF_INTEGRATION_TIME): cv.one_of(*TCS34725_INTEGRATION_TIMES),
|
vol.Optional(CONF_INTEGRATION_TIME): cv.one_of(*TCS34725_INTEGRATION_TIMES),
|
||||||
vol.Optional(CONF_GAIN): vol.All(vol.Upper, cv.one_of(*TCS34725_GAINS)),
|
vol.Optional(CONF_GAIN): vol.All(vol.Upper, cv.one_of(*TCS34725_GAINS)),
|
||||||
vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds,
|
vol.Optional(CONF_UPDATE_INTERVAL): cv.update_interval,
|
||||||
}), cv.has_at_least_one_key(CONF_RED_CHANNEL, CONF_GREEN_CHANNEL, CONF_BLUE_CHANNEL,
|
}), cv.has_at_least_one_key(CONF_RED_CHANNEL, CONF_GREEN_CHANNEL, CONF_BLUE_CHANNEL,
|
||||||
CONF_CLEAR_CHANNEL, CONF_ILLUMINANCE, CONF_COLOR_TEMPERATURE))
|
CONF_CLEAR_CHANNEL, CONF_ILLUMINANCE, CONF_COLOR_TEMPERATURE))
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ MakeTemplateSensor = Application.MakeTemplateSensor
|
||||||
PLATFORM_SCHEMA = cv.nameable(sensor.SENSOR_PLATFORM_SCHEMA.extend({
|
PLATFORM_SCHEMA = cv.nameable(sensor.SENSOR_PLATFORM_SCHEMA.extend({
|
||||||
cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeTemplateSensor),
|
cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeTemplateSensor),
|
||||||
vol.Required(CONF_LAMBDA): cv.lambda_,
|
vol.Required(CONF_LAMBDA): cv.lambda_,
|
||||||
vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds,
|
vol.Optional(CONF_UPDATE_INTERVAL): cv.update_interval,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ PLATFORM_SCHEMA = cv.nameable(sensor.SENSOR_PLATFORM_SCHEMA.extend({
|
||||||
vol.Optional(CONF_INTEGRATION_TIME): validate_integration_time,
|
vol.Optional(CONF_INTEGRATION_TIME): validate_integration_time,
|
||||||
vol.Optional(CONF_GAIN): vol.All(vol.Upper, cv.one_of(*GAINS)),
|
vol.Optional(CONF_GAIN): vol.All(vol.Upper, cv.one_of(*GAINS)),
|
||||||
vol.Optional(CONF_IS_CS_PACKAGE): cv.boolean,
|
vol.Optional(CONF_IS_CS_PACKAGE): cv.boolean,
|
||||||
vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds,
|
vol.Optional(CONF_UPDATE_INTERVAL): cv.update_interval,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ PLATFORM_SCHEMA = cv.nameable(sensor.SENSOR_PLATFORM_SCHEMA.extend({
|
||||||
vol.Required(CONF_ECHO_PIN): pins.internal_gpio_input_pin_schema,
|
vol.Required(CONF_ECHO_PIN): pins.internal_gpio_input_pin_schema,
|
||||||
vol.Exclusive(CONF_TIMEOUT_METER, 'timeout'): cv.positive_float,
|
vol.Exclusive(CONF_TIMEOUT_METER, 'timeout'): cv.positive_float,
|
||||||
vol.Exclusive(CONF_TIMEOUT_TIME, 'timeout'): cv.positive_time_period_microseconds,
|
vol.Exclusive(CONF_TIMEOUT_TIME, 'timeout'): cv.positive_time_period_microseconds,
|
||||||
vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds,
|
vol.Optional(CONF_UPDATE_INTERVAL): cv.update_interval,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ MakeUptimeSensor = Application.MakeUptimeSensor
|
||||||
|
|
||||||
PLATFORM_SCHEMA = cv.nameable(sensor.SENSOR_PLATFORM_SCHEMA.extend({
|
PLATFORM_SCHEMA = cv.nameable(sensor.SENSOR_PLATFORM_SCHEMA.extend({
|
||||||
cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeUptimeSensor),
|
cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeUptimeSensor),
|
||||||
vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds,
|
vol.Optional(CONF_UPDATE_INTERVAL): cv.update_interval,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ MakeWiFiSignalSensor = Application.MakeWiFiSignalSensor
|
||||||
|
|
||||||
PLATFORM_SCHEMA = cv.nameable(sensor.SENSOR_PLATFORM_SCHEMA.extend({
|
PLATFORM_SCHEMA = cv.nameable(sensor.SENSOR_PLATFORM_SCHEMA.extend({
|
||||||
cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeWiFiSignalSensor),
|
cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeWiFiSignalSensor),
|
||||||
vol.Optional(CONF_UPDATE_INTERVAL): cv.positive_time_period_milliseconds,
|
vol.Optional(CONF_UPDATE_INTERVAL): cv.update_interval,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -328,6 +328,12 @@ def time_period_in_seconds_(value):
|
||||||
return TimePeriodSeconds(**value.as_dict())
|
return TimePeriodSeconds(**value.as_dict())
|
||||||
|
|
||||||
|
|
||||||
|
def update_interval(value):
|
||||||
|
if value == 'never':
|
||||||
|
return 4294967295 # uint32_t max
|
||||||
|
return positive_time_period_milliseconds(value)
|
||||||
|
|
||||||
|
|
||||||
time_period = vol.Any(time_period_str_unit, time_period_str_colon, time_period_dict)
|
time_period = vol.Any(time_period_str_unit, time_period_str_colon, time_period_dict)
|
||||||
positive_time_period = vol.All(time_period, vol.Range(min=TimePeriod()))
|
positive_time_period = vol.All(time_period, vol.Range(min=TimePeriod()))
|
||||||
positive_time_period_milliseconds = vol.All(positive_time_period, time_period_in_milliseconds_)
|
positive_time_period_milliseconds = vol.All(positive_time_period, time_period_in_milliseconds_)
|
||||||
|
|
|
@ -309,6 +309,19 @@ CONF_EXTERNAL_VCC = 'external_vcc'
|
||||||
CONF_TIMEZONE = 'timezone'
|
CONF_TIMEZONE = 'timezone'
|
||||||
CONF_SERVERS = 'servers'
|
CONF_SERVERS = 'servers'
|
||||||
CONF_HEATER = 'heater'
|
CONF_HEATER = 'heater'
|
||||||
|
CONF_VOLTAGE = 'voltage'
|
||||||
|
CONF_CURRENT_RESISTOR = 'current_resistor'
|
||||||
|
CONF_VOLTAGE_DIVIDER = 'voltage_divider'
|
||||||
|
CONF_SEL_PIN = 'sel_pin'
|
||||||
|
CONF_CF_PIN = 'cf_pin'
|
||||||
|
CONF_CF1_PIN = 'cf1_pin'
|
||||||
|
CONF_CHANGE_MODE_EVERY = 'change_mode_every'
|
||||||
|
CONF_PAGE_ID = 'page_id'
|
||||||
|
CONF_COMPONENT_ID = 'component_id'
|
||||||
|
CONF_COLD_WHITE = 'cold_white'
|
||||||
|
CONF_WARM_WHITE = 'warm_white'
|
||||||
|
CONF_COLD_WHITE_COLOR_TEMPERATURE = 'cold_white_color_temperature'
|
||||||
|
CONF_WARM_WHITE_COLOR_TEMPERATURE = 'warm_white_color_temperature'
|
||||||
|
|
||||||
ESP32_BOARDS = [
|
ESP32_BOARDS = [
|
||||||
'featheresp32', 'node32s', 'espea32', 'firebeetle32', 'esp32doit-devkit-v1',
|
'featheresp32', 'node32s', 'espea32', 'firebeetle32', 'esp32doit-devkit-v1',
|
||||||
|
|
|
@ -273,6 +273,12 @@ class IntLiteral(Literal):
|
||||||
self.i = i
|
self.i = i
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
if self.i > 4294967295:
|
||||||
|
return u'{}ULL'.format(self.i)
|
||||||
|
if self.i > 2147483647:
|
||||||
|
return u'{}UL'.format(self.i)
|
||||||
|
if self.i < -2147483648:
|
||||||
|
return u'{}LL'.format(self.i)
|
||||||
return unicode(self.i)
|
return unicode(self.i)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue