ESPHome
2025.5.0
Loading...
Searching...
No Matches
esphome
components
demo
demo_light.h
Go to the documentation of this file.
1
#pragma once
2
3
#include "
esphome/core/component.h
"
4
#include "
esphome/components/light/light_output.h
"
5
6
namespace
esphome
{
7
namespace
demo {
8
9
enum 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
26
class
DemoLight
:
public
light::LightOutput
,
public
Component
{
27
public
:
28
void
set_type
(
DemoLightType
type
) {
type_
=
type
; }
29
light::LightTraits
get_traits
()
override
{
30
light::LightTraits
traits{};
31
switch
(
type_
) {
32
case
DemoLightType::TYPE_1
:
33
traits.set_supported_color_modes({
light::ColorMode::ON_OFF
});
34
break
;
35
case
DemoLightType::TYPE_2
:
36
traits.set_supported_color_modes({
light::ColorMode::BRIGHTNESS
});
37
break
;
38
case
DemoLightType::TYPE_3
:
39
traits.set_supported_color_modes({
light::ColorMode::RGB
});
40
break
;
41
case
DemoLightType::TYPE_4
:
42
traits.set_supported_color_modes({
light::ColorMode::RGB_WHITE
});
43
break
;
44
case
DemoLightType::TYPE_5
:
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
;
49
case
DemoLightType::TYPE_6
:
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
;
54
case
DemoLightType::TYPE_7
:
55
traits.set_supported_color_modes({
light::ColorMode::RGB
,
light::ColorMode::WHITE
});
56
break
;
57
}
58
return
traits;
59
}
60
void
write_state
(
light::LightState
*
state
)
override
{
61
// do nothing
62
}
63
64
DemoLightType
type_
;
65
};
66
67
}
// namespace demo
68
}
// namespace esphome
esphome::Component
Definition
component.h:70
esphome::demo::DemoLight
Definition
demo_light.h:26
esphome::demo::DemoLight::get_traits
light::LightTraits get_traits() override
Definition
demo_light.h:29
esphome::demo::DemoLight::write_state
void write_state(light::LightState *state) override
Definition
demo_light.h:60
esphome::demo::DemoLight::set_type
void set_type(DemoLightType type)
Definition
demo_light.h:28
esphome::demo::DemoLight::type_
DemoLightType type_
Definition
demo_light.h:64
esphome::light::LightOutput
Interface to write LightStates to hardware.
Definition
light_output.h:12
esphome::light::LightState
This class represents the communication layer between the front-end MQTT layer and the hardware outpu...
Definition
light_state.h:63
esphome::light::LightTraits
This class is used to represent the capabilities of a light.
Definition
light_traits.h:11
component.h
type
uint8_t type
Definition
e131_packet.cpp:21
state
bool state
Definition
fan.h:0
light_output.h
esphome::demo::DemoClimateType::TYPE_3
@ TYPE_3
esphome::demo::DemoClimateType::TYPE_2
@ TYPE_2
esphome::demo::DemoClimateType::TYPE_1
@ TYPE_1
esphome::demo::DemoLightType
DemoLightType
Definition
demo_light.h:9
esphome::demo::DemoLightType::TYPE_3
@ TYPE_3
esphome::demo::DemoLightType::TYPE_5
@ TYPE_5
esphome::demo::DemoLightType::TYPE_7
@ TYPE_7
esphome::demo::DemoLightType::TYPE_2
@ TYPE_2
esphome::demo::DemoLightType::TYPE_1
@ TYPE_1
esphome::demo::DemoLightType::TYPE_6
@ TYPE_6
esphome::demo::DemoLightType::TYPE_4
@ TYPE_4
esphome::demo::DemoCoverType::TYPE_4
@ TYPE_4
esphome::light::ColorMode::ON_OFF
@ ON_OFF
Only on/off control.
esphome::light::ColorMode::BRIGHTNESS
@ BRIGHTNESS
Dimmable light.
esphome::light::ColorMode::RGB_WHITE
@ RGB_WHITE
RGB color output and a separate white output.
esphome::light::ColorMode::RGB_COLOR_TEMPERATURE
@ RGB_COLOR_TEMPERATURE
RGB color output and a separate white output with controllable color temperature.
esphome::light::ColorMode::RGB
@ RGB
RGB color output.
esphome::light::ColorMode::WHITE
@ WHITE
White output only (use only if the light also has another color mode such as RGB).
esphome::light::ColorMode::COLD_WARM_WHITE
@ COLD_WARM_WHITE
Cold and warm white output with individually controllable brightness.
esphome
Providing packet encoding functions for exchanging data with a remote host.
Definition
a01nyub.cpp:7
Generated by
1.12.0