1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-05 19:33:47 +01:00

Cleanup dashboard JS (#491)

* Cleanup dashboard JS

* Add vscode

* Save start_mark/end_mark

* Updates

* Updates

* Remove need for cv.nameable

It's a bit hacky but removes so much bloat from integrations

* Add enum helper

* Document APIs, and Improvements

* Fixes

* Fixes

* Update PULL_REQUEST_TEMPLATE.md

* Updates

* Updates

* Updates
This commit is contained in:
Otto Winter
2019-04-22 21:56:30 +02:00
committed by GitHub
parent 6682c43dfa
commit 8e75980ebd
359 changed files with 4395 additions and 4223 deletions

View File

@@ -1,16 +1,16 @@
from esphome import automation
from esphome.automation import ACTION_REGISTRY, maybe_simple_id
import esphome.config_validation as cv
import esphome.codegen as cg
import esphome.config_validation as cv
from esphome import automation
from esphome.automation import maybe_simple_id
from esphome.const import CONF_ID
script_ns = cg.esphome_ns.namespace('script')
Script = script_ns.class_('Script', cg.Trigger.template())
ScriptExecuteAction = script_ns.class_('ScriptExecuteAction', cg.Action)
ScriptStopAction = script_ns.class_('ScriptStopAction', cg.Action)
Script = script_ns.class_('Script', automation.Trigger.template())
ScriptExecuteAction = script_ns.class_('ScriptExecuteAction', automation.Action)
ScriptStopAction = script_ns.class_('ScriptStopAction', automation.Action)
CONFIG_SCHEMA = automation.validate_automation({
cv.Required(CONF_ID): cv.declare_variable_id(Script),
cv.Required(CONF_ID): cv.declare_id(Script),
})
@@ -20,21 +20,17 @@ def to_code(config):
yield automation.build_automation(trigger, [], conf)
@ACTION_REGISTRY.register('script.execute', maybe_simple_id({
cv.Required(CONF_ID): cv.use_variable_id(Script),
@automation.register_action('script.execute', ScriptExecuteAction, maybe_simple_id({
cv.Required(CONF_ID): cv.use_id(Script),
}))
def script_execute_action_to_code(config, action_id, template_arg, args):
var = yield cg.get_variable(config[CONF_ID])
type = ScriptExecuteAction.template(template_arg)
rhs = type.new(var)
yield cg.Pvariable(action_id, rhs, type=type)
paren = yield cg.get_variable(config[CONF_ID])
yield cg.new_Pvariable(action_id, template_arg, paren)
@ACTION_REGISTRY.register('script.stop', maybe_simple_id({
cv.Required(CONF_ID): cv.use_variable_id(Script)
@automation.register_action('script.stop', ScriptStopAction, maybe_simple_id({
cv.Required(CONF_ID): cv.use_id(Script)
}))
def script_stop_action_to_code(config, action_id, template_arg, args):
var = yield cg.get_variable(config[CONF_ID])
type = ScriptStopAction.template(template_arg)
rhs = type.new(var)
yield cg.Pvariable(action_id, rhs, type=type)
paren = yield cg.get_variable(config[CONF_ID])
yield cg.new_Pvariable(action_id, template_arg, paren)

View File

@@ -14,10 +14,7 @@ template<typename... Ts> class ScriptExecuteAction : public Action<Ts...> {
public:
ScriptExecuteAction(Script *script) : script_(script) {}
void play(Ts... x) override {
this->script_->trigger();
this->play_next(x...);
}
void play(Ts... x) override { this->script_->trigger(); }
protected:
Script *script_;
@@ -27,10 +24,7 @@ template<typename... Ts> class ScriptStopAction : public Action<Ts...> {
public:
ScriptStopAction(Script *script) : script_(script) {}
void play(Ts... x) override {
this->script_->stop();
this->play_next(x...);
}
void play(Ts... x) override { this->script_->stop(); }
protected:
Script *script_;