1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-24 04:33:49 +01:00
* Add black

Update pre commit

Update pre commit

add empty line

* Format with black
This commit is contained in:
Guillermo Ruffino
2021-03-07 16:03:16 -03:00
committed by GitHub
parent 2b60b0f1fa
commit 69879920eb
398 changed files with 21624 additions and 12644 deletions

View File

@@ -2,27 +2,34 @@ import esphome.codegen as cg
import esphome.config_validation as cv
from esphome import automation
from esphome.components import binary_sensor, cover
from esphome.const import CONF_CLOSE_ACTION, CONF_CLOSE_DURATION, \
CONF_CLOSE_ENDSTOP, CONF_ID, CONF_OPEN_ACTION, CONF_OPEN_DURATION, \
CONF_OPEN_ENDSTOP, CONF_STOP_ACTION, CONF_MAX_DURATION
from esphome.const import (
CONF_CLOSE_ACTION,
CONF_CLOSE_DURATION,
CONF_CLOSE_ENDSTOP,
CONF_ID,
CONF_OPEN_ACTION,
CONF_OPEN_DURATION,
CONF_OPEN_ENDSTOP,
CONF_STOP_ACTION,
CONF_MAX_DURATION,
)
endstop_ns = cg.esphome_ns.namespace('endstop')
EndstopCover = endstop_ns.class_('EndstopCover', cover.Cover, cg.Component)
endstop_ns = cg.esphome_ns.namespace("endstop")
EndstopCover = endstop_ns.class_("EndstopCover", cover.Cover, cg.Component)
CONFIG_SCHEMA = cover.COVER_SCHEMA.extend({
cv.GenerateID(): cv.declare_id(EndstopCover),
cv.Required(CONF_STOP_ACTION): automation.validate_automation(single=True),
cv.Required(CONF_OPEN_ENDSTOP): cv.use_id(binary_sensor.BinarySensor),
cv.Required(CONF_OPEN_ACTION): automation.validate_automation(single=True),
cv.Required(CONF_OPEN_DURATION): cv.positive_time_period_milliseconds,
cv.Required(CONF_CLOSE_ACTION): automation.validate_automation(single=True),
cv.Required(CONF_CLOSE_ENDSTOP): cv.use_id(binary_sensor.BinarySensor),
cv.Required(CONF_CLOSE_DURATION): cv.positive_time_period_milliseconds,
cv.Optional(CONF_MAX_DURATION): cv.positive_time_period_milliseconds,
}).extend(cv.COMPONENT_SCHEMA)
CONFIG_SCHEMA = cover.COVER_SCHEMA.extend(
{
cv.GenerateID(): cv.declare_id(EndstopCover),
cv.Required(CONF_STOP_ACTION): automation.validate_automation(single=True),
cv.Required(CONF_OPEN_ENDSTOP): cv.use_id(binary_sensor.BinarySensor),
cv.Required(CONF_OPEN_ACTION): automation.validate_automation(single=True),
cv.Required(CONF_OPEN_DURATION): cv.positive_time_period_milliseconds,
cv.Required(CONF_CLOSE_ACTION): automation.validate_automation(single=True),
cv.Required(CONF_CLOSE_ENDSTOP): cv.use_id(binary_sensor.BinarySensor),
cv.Required(CONF_CLOSE_DURATION): cv.positive_time_period_milliseconds,
cv.Optional(CONF_MAX_DURATION): cv.positive_time_period_milliseconds,
}
).extend(cv.COMPONENT_SCHEMA)
def to_code(config):
@@ -30,17 +37,23 @@ def to_code(config):
yield cg.register_component(var, config)
yield cover.register_cover(var, config)
yield automation.build_automation(var.get_stop_trigger(), [], config[CONF_STOP_ACTION])
yield automation.build_automation(
var.get_stop_trigger(), [], config[CONF_STOP_ACTION]
)
bin = yield cg.get_variable(config[CONF_OPEN_ENDSTOP])
cg.add(var.set_open_endstop(bin))
cg.add(var.set_open_duration(config[CONF_OPEN_DURATION]))
yield automation.build_automation(var.get_open_trigger(), [], config[CONF_OPEN_ACTION])
yield automation.build_automation(
var.get_open_trigger(), [], config[CONF_OPEN_ACTION]
)
bin = yield cg.get_variable(config[CONF_CLOSE_ENDSTOP])
cg.add(var.set_close_endstop(bin))
cg.add(var.set_close_duration(config[CONF_CLOSE_DURATION]))
yield automation.build_automation(var.get_close_trigger(), [], config[CONF_CLOSE_ACTION])
yield automation.build_automation(
var.get_close_trigger(), [], config[CONF_CLOSE_ACTION]
)
if CONF_MAX_DURATION in config:
cg.add(var.set_max_duration(config[CONF_MAX_DURATION]))