ESPHome 2026.1.5
Loading...
Searching...
No Matches
tuya_light.h
Go to the documentation of this file.
1#pragma once
2
6
7namespace esphome {
8namespace tuya {
9
11
12class TuyaLight : public Component, public light::LightOutput {
13 public:
14 void setup() override;
15 void dump_config() override;
16 void set_dimmer_id(uint8_t dimmer_id) { this->dimmer_id_ = dimmer_id; }
17 void set_min_value_datapoint_id(uint8_t min_value_datapoint_id) {
18 this->min_value_datapoint_id_ = min_value_datapoint_id;
19 }
20 void set_switch_id(uint8_t switch_id) { this->switch_id_ = switch_id; }
21 void set_color_id(uint8_t color_id) { this->color_id_ = color_id; }
22 void set_color_type(TuyaColorType color_type) { this->color_type_ = color_type; }
23 void set_color_temperature_id(uint8_t color_temperature_id) { this->color_temperature_id_ = color_temperature_id; }
24 void set_color_temperature_invert(bool color_temperature_invert) {
25 this->color_temperature_invert_ = color_temperature_invert;
26 }
27 void set_color_type_lowercase(bool color_type_lowercase) { this->color_type_lowercase_ = color_type_lowercase; }
28 void set_tuya_parent(Tuya *parent) { this->parent_ = parent; }
29 void set_min_value(uint32_t min_value) { min_value_ = min_value; }
30 void set_max_value(uint32_t max_value) { max_value_ = max_value; }
31 void set_color_temperature_max_value(uint32_t color_temperature_max_value) {
32 this->color_temperature_max_value_ = color_temperature_max_value;
33 }
34 void set_cold_white_temperature(float cold_white_temperature) {
35 this->cold_white_temperature_ = cold_white_temperature;
36 }
37 void set_warm_white_temperature(float warm_white_temperature) {
38 this->warm_white_temperature_ = warm_white_temperature;
39 }
40 void set_color_interlock(bool color_interlock) { color_interlock_ = color_interlock; }
41
43 void setup_state(light::LightState *state) override;
44 void write_state(light::LightState *state) override;
45
46 protected:
47 void update_dimmer_(uint32_t value);
48 void update_switch_(uint32_t value);
49
57 uint32_t min_value_ = 0;
58 uint32_t max_value_ = 255;
64 bool color_interlock_{false};
66};
67
68} // namespace tuya
69} // namespace esphome
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:91
This class is used to represent the capabilities of a light.
void set_dimmer_id(uint8_t dimmer_id)
Definition tuya_light.h:16
void setup() override
optional< uint8_t > min_value_datapoint_id_
Definition tuya_light.h:52
void setup_state(light::LightState *state) override
void dump_config() override
void set_min_value(uint32_t min_value)
Definition tuya_light.h:29
void set_switch_id(uint8_t switch_id)
Definition tuya_light.h:20
light::LightTraits get_traits() override
void set_min_value_datapoint_id(uint8_t min_value_datapoint_id)
Definition tuya_light.h:17
void set_color_temperature_id(uint8_t color_temperature_id)
Definition tuya_light.h:23
void set_warm_white_temperature(float warm_white_temperature)
Definition tuya_light.h:37
void set_color_temperature_invert(bool color_temperature_invert)
Definition tuya_light.h:24
optional< TuyaColorType > color_type_
Definition tuya_light.h:55
void set_tuya_parent(Tuya *parent)
Definition tuya_light.h:28
void set_color_type_lowercase(bool color_type_lowercase)
Definition tuya_light.h:27
void update_dimmer_(uint32_t value)
void update_switch_(uint32_t value)
void set_color_temperature_max_value(uint32_t color_temperature_max_value)
Definition tuya_light.h:31
void set_color_interlock(bool color_interlock)
Definition tuya_light.h:40
optional< uint8_t > switch_id_
Definition tuya_light.h:53
optional< uint8_t > color_temperature_id_
Definition tuya_light.h:56
void set_max_value(uint32_t max_value)
Definition tuya_light.h:30
void write_state(light::LightState *state) override
optional< uint8_t > dimmer_id_
Definition tuya_light.h:51
optional< uint8_t > color_id_
Definition tuya_light.h:54
uint32_t color_temperature_max_value_
Definition tuya_light.h:59
light::LightState * state_
Definition tuya_light.h:65
void set_color_type(TuyaColorType color_type)
Definition tuya_light.h:22
void set_cold_white_temperature(float cold_white_temperature)
Definition tuya_light.h:34
void set_color_id(uint8_t color_id)
Definition tuya_light.h:21
bool state
Definition fan.h:0
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7