mirror of
https://github.com/Threnklyn/esphome-dev.git
synced 2026-05-19 20:53:26 +02:00
8e75980ebd
* 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
33 lines
789 B
C++
33 lines
789 B
C++
#pragma once
|
|
|
|
#include "esphome/core/component.h"
|
|
#include "esphome/components/output/binary_output.h"
|
|
#include "esphome/components/light/light_output.h"
|
|
|
|
namespace esphome {
|
|
namespace binary {
|
|
|
|
class BinaryLightOutput : public light::LightOutput {
|
|
public:
|
|
void set_output(output::BinaryOutput *output) { output_ = output; }
|
|
light::LightTraits get_traits() override {
|
|
auto traits = light::LightTraits();
|
|
traits.set_supports_brightness(false);
|
|
return traits;
|
|
}
|
|
void write_state(light::LightState *state) override {
|
|
bool binary;
|
|
state->current_values_as_binary(&binary);
|
|
if (binary)
|
|
this->output_->turn_on();
|
|
else
|
|
this->output_->turn_off();
|
|
}
|
|
|
|
protected:
|
|
output::BinaryOutput *output_;
|
|
};
|
|
|
|
} // namespace binary
|
|
} // namespace esphome
|