mirror of
https://github.com/esphome/esphome.git
synced 2026-09-26 06:20:21 +00:00
28 lines
740 B
C++
28 lines
740 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::binary {
|
|
|
|
class BinaryLightOutput final : public light::LightOutput {
|
|
public:
|
|
void set_output(output::BinaryOutput *output) { output_ = output; }
|
|
light::LightTraits get_traits() override {
|
|
auto traits = light::LightTraits();
|
|
traits.set_supported_color_modes({light::ColorMode::ON_OFF});
|
|
return traits;
|
|
}
|
|
void write_state(light::LightState *state) override {
|
|
bool binary;
|
|
state->current_values_as_binary(&binary);
|
|
this->output_->set_state(binary);
|
|
}
|
|
|
|
protected:
|
|
output::BinaryOutput *output_;
|
|
};
|
|
|
|
} // namespace esphome::binary
|