* 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
+51 -27
View File
@@ -4,28 +4,33 @@ from esphome import automation
from esphome.components.output import FloatOutput
from esphome.const import CONF_ID, CONF_OUTPUT, CONF_TRIGGER_ID
CODEOWNERS = ['@glmnet']
CONF_RTTTL = 'rtttl'
CONF_ON_FINISHED_PLAYBACK = 'on_finished_playback'
CODEOWNERS = ["@glmnet"]
CONF_RTTTL = "rtttl"
CONF_ON_FINISHED_PLAYBACK = "on_finished_playback"
rtttl_ns = cg.esphome_ns.namespace('rtttl')
rtttl_ns = cg.esphome_ns.namespace("rtttl")
Rtttl = rtttl_ns .class_('Rtttl', cg.Component)
PlayAction = rtttl_ns.class_('PlayAction', automation.Action)
StopAction = rtttl_ns.class_('StopAction', automation.Action)
FinishedPlaybackTrigger = rtttl_ns.class_('FinishedPlaybackTrigger',
automation.Trigger.template())
IsPlayingCondition = rtttl_ns.class_('IsPlayingCondition', automation.Condition)
Rtttl = rtttl_ns.class_("Rtttl", cg.Component)
PlayAction = rtttl_ns.class_("PlayAction", automation.Action)
StopAction = rtttl_ns.class_("StopAction", automation.Action)
FinishedPlaybackTrigger = rtttl_ns.class_(
"FinishedPlaybackTrigger", automation.Trigger.template()
)
IsPlayingCondition = rtttl_ns.class_("IsPlayingCondition", automation.Condition)
MULTI_CONF = True
CONFIG_SCHEMA = cv.Schema({
cv.GenerateID(CONF_ID): cv.declare_id(Rtttl),
cv.Required(CONF_OUTPUT): cv.use_id(FloatOutput),
cv.Optional(CONF_ON_FINISHED_PLAYBACK): automation.validate_automation({
cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id(FinishedPlaybackTrigger),
}),
}).extend(cv.COMPONENT_SCHEMA)
CONFIG_SCHEMA = cv.Schema(
{
cv.GenerateID(CONF_ID): cv.declare_id(Rtttl),
cv.Required(CONF_OUTPUT): cv.use_id(FloatOutput),
cv.Optional(CONF_ON_FINISHED_PLAYBACK): automation.validate_automation(
{
cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id(FinishedPlaybackTrigger),
}
),
}
).extend(cv.COMPONENT_SCHEMA)
def to_code(config):
@@ -40,10 +45,17 @@ def to_code(config):
yield automation.build_automation(trigger, [], conf)
@automation.register_action('rtttl.play', PlayAction, cv.maybe_simple_value({
cv.GenerateID(CONF_ID): cv.use_id(Rtttl),
cv.Required(CONF_RTTTL): cv.templatable(cv.string)
}, key=CONF_RTTTL))
@automation.register_action(
"rtttl.play",
PlayAction,
cv.maybe_simple_value(
{
cv.GenerateID(CONF_ID): cv.use_id(Rtttl),
cv.Required(CONF_RTTTL): cv.templatable(cv.string),
},
key=CONF_RTTTL,
),
)
def rtttl_play_to_code(config, action_id, template_arg, args):
paren = yield cg.get_variable(config[CONF_ID])
var = cg.new_Pvariable(action_id, template_arg, paren)
@@ -52,18 +64,30 @@ def rtttl_play_to_code(config, action_id, template_arg, args):
yield var
@automation.register_action('rtttl.stop', StopAction, cv.Schema({
cv.GenerateID(): cv.use_id(Rtttl),
}))
@automation.register_action(
"rtttl.stop",
StopAction,
cv.Schema(
{
cv.GenerateID(): cv.use_id(Rtttl),
}
),
)
def rtttl_stop_to_code(config, action_id, template_arg, args):
var = cg.new_Pvariable(action_id, template_arg)
yield cg.register_parented(var, config[CONF_ID])
yield var
@automation.register_condition('rtttl.is_playing', IsPlayingCondition, cv.Schema({
cv.GenerateID(): cv.use_id(Rtttl),
}))
@automation.register_condition(
"rtttl.is_playing",
IsPlayingCondition,
cv.Schema(
{
cv.GenerateID(): cv.use_id(Rtttl),
}
),
)
def rtttl_is_playing_to_code(config, condition_id, template_arg, args):
var = cg.new_Pvariable(condition_id, template_arg)
yield cg.register_parented(var, config[CONF_ID])