esphome/esphome/components/output/automation.h
Otto Winter 8e75980ebd
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
2019-04-22 21:56:30 +02:00

43 lines
1 KiB
C++

#pragma once
#include "esphome/core/component.h"
#include "esphome/core/automation.h"
#include "esphome/components/output/binary_output.h"
#include "esphome/components/output/float_output.h"
namespace esphome {
namespace output {
template<typename... Ts> class TurnOffAction : public Action<Ts...> {
public:
TurnOffAction(BinaryOutput *output) : output_(output) {}
void play(Ts... x) override { this->output_->turn_off(); }
protected:
BinaryOutput *output_;
};
template<typename... Ts> class TurnOnAction : public Action<Ts...> {
public:
TurnOnAction(BinaryOutput *output) : output_(output) {}
void play(Ts... x) override { this->output_->turn_on(); }
protected:
BinaryOutput *output_;
};
template<typename... Ts> class SetLevelAction : public Action<Ts...> {
public:
SetLevelAction(FloatOutput *output) : output_(output) {}
TEMPLATABLE_VALUE(float, level)
void play(Ts... x) override { this->output_->set_level(this->level_.value(x...)); }
protected:
FloatOutput *output_;
};
} // namespace output
} // namespace esphome