ESPHome 2026.6.0-dev
Loading...
Searching...
No Matches
demo_light.h
Go to the documentation of this file.
1#pragma once
2
5
6namespace esphome::demo {
7
8enum class DemoLightType {
9 // binary
10 TYPE_1,
11 // brightness
12 TYPE_2,
13 // RGB
14 TYPE_3,
15 // RGBW
16 TYPE_4,
17 // RGBWW
18 TYPE_5,
19 // CWWW
20 TYPE_6,
21 // RGBW + color_interlock
22 TYPE_7,
23};
24
25class DemoLight : public light::LightOutput, public Component {
26 public:
29 light::LightTraits traits{};
30 switch (type_) {
32 traits.set_supported_color_modes({light::ColorMode::ON_OFF});
33 break;
35 traits.set_supported_color_modes({light::ColorMode::BRIGHTNESS});
36 break;
38 traits.set_supported_color_modes({light::ColorMode::RGB});
39 break;
41 traits.set_supported_color_modes({light::ColorMode::RGB_WHITE});
42 break;
44 traits.set_supported_color_modes({light::ColorMode::RGB_COLOR_TEMPERATURE});
45 traits.set_min_mireds(153);
46 traits.set_max_mireds(500);
47 break;
49 traits.set_supported_color_modes({light::ColorMode::COLD_WARM_WHITE});
50 traits.set_min_mireds(153);
51 traits.set_max_mireds(500);
52 break;
54 traits.set_supported_color_modes({light::ColorMode::RGB, light::ColorMode::WHITE});
55 break;
56 }
57 return traits;
58 }
60 // do nothing
61 }
62
64};
65
66} // namespace esphome::demo
light::LightTraits get_traits() override
Definition demo_light.h:28
void write_state(light::LightState *state) override
Definition demo_light.h:59
void set_type(DemoLightType type)
Definition demo_light.h:27
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:93
This class is used to represent the capabilities of a light.
Definition light_traits.h:9
uint16_t type
bool state
Definition fan.h:2
@ 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.