ESPHome  2022.6.2
binary_light_output.h
Go to the documentation of this file.
1 #pragma once
2 
6 
7 namespace esphome {
8 namespace binary {
9 
11  public:
12  void set_output(output::BinaryOutput *output) { output_ = output; }
14  auto traits = light::LightTraits();
15  traits.set_supported_color_modes({light::ColorMode::ON_OFF});
16  return traits;
17  }
19  bool binary;
20  state->current_values_as_binary(&binary);
21  if (binary)
22  this->output_->turn_on();
23  else
24  this->output_->turn_off();
25  }
26 
27  protected:
29 };
30 
31 } // namespace binary
32 } // namespace esphome
This class represents the communication layer between the front-end MQTT layer and the hardware outpu...
Definition: light_state.h:32
virtual void turn_on()
Enable this binary output.
Definition: binary_output.h:43
Interface to write LightStates to hardware.
Definition: light_output.h:12
virtual void turn_off()
Disable this binary output.
Definition: binary_output.h:51
light::LightTraits get_traits() override
void current_values_as_binary(bool *binary)
The result of all the current_values_as_* methods have gamma correction applied.
void set_output(output::BinaryOutput *output)
Light can be turned on/off.
This class is used to represent the capabilities of a light.
Definition: light_traits.h:11
void write_state(light::LightState *state) override
Definition: a4988.cpp:4
bool state
Definition: fan.h:34