ESPHome 2025.5.0
Loading...
Searching...
No Matches
demo_light.h
Go to the documentation of this file.
1#pragma once
2
5
6namespace esphome {
7namespace demo {
8
9enum class DemoLightType {
10 // binary
11 TYPE_1,
12 // brightness
13 TYPE_2,
14 // RGB
15 TYPE_3,
16 // RGBW
17 TYPE_4,
18 // RGBWW
19 TYPE_5,
20 // CWWW
21 TYPE_6,
22 // RGBW + color_interlock
23 TYPE_7,
24};
25
26class DemoLight : public light::LightOutput, public Component {
27 public:
30 light::LightTraits traits{};
31 switch (type_) {
33 traits.set_supported_color_modes({light::ColorMode::ON_OFF});
34 break;
36 traits.set_supported_color_modes({light::ColorMode::BRIGHTNESS});
37 break;
39 traits.set_supported_color_modes({light::ColorMode::RGB});
40 break;
42 traits.set_supported_color_modes({light::ColorMode::RGB_WHITE});
43 break;
45 traits.set_supported_color_modes({light::ColorMode::RGB_COLOR_TEMPERATURE});
46 traits.set_min_mireds(153);
47 traits.set_max_mireds(500);
48 break;
50 traits.set_supported_color_modes({light::ColorMode::COLD_WARM_WHITE});
51 traits.set_min_mireds(153);
52 traits.set_max_mireds(500);
53 break;
55 traits.set_supported_color_modes({light::ColorMode::RGB, light::ColorMode::WHITE});
56 break;
57 }
58 return traits;
59 }
61 // do nothing
62 }
63
65};
66
67} // namespace demo
68} // namespace esphome
light::LightTraits get_traits() override
Definition demo_light.h:29
void write_state(light::LightState *state) override
Definition demo_light.h:60
void set_type(DemoLightType type)
Definition demo_light.h:28
Interface to write LightStates to hardware.
This class represents the communication layer between the front-end MQTT layer and the hardware outpu...
Definition light_state.h:63
This class is used to represent the capabilities of a light.
uint8_t type
bool state
Definition fan.h:0
@ ON_OFF
Only on/off control.
@ BRIGHTNESS
Dimmable light.
@ RGB_WHITE
RGB color output and a separate white output.
@ RGB_COLOR_TEMPERATURE
RGB color output and a separate white output with controllable color temperature.
@ RGB
RGB color output.
@ WHITE
White output only (use only if the light also has another color mode such as RGB).
@ COLD_WARM_WHITE
Cold and warm white output with individually controllable brightness.
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7