ESPHome  2024.12.2
tuya_light.h
Go to the documentation of this file.
1 #pragma once
2 
6 
7 namespace esphome {
8 namespace tuya {
9 
11  RGB,
12  HSV,
14 };
15 
16 class TuyaLight : public Component, public light::LightOutput {
17  public:
18  void setup() override;
19  void dump_config() override;
20  void set_dimmer_id(uint8_t dimmer_id) { this->dimmer_id_ = dimmer_id; }
21  void set_min_value_datapoint_id(uint8_t min_value_datapoint_id) {
22  this->min_value_datapoint_id_ = min_value_datapoint_id;
23  }
24  void set_switch_id(uint8_t switch_id) { this->switch_id_ = switch_id; }
25  void set_color_id(uint8_t color_id) { this->color_id_ = color_id; }
26  void set_color_type(TuyaColorType color_type) { this->color_type_ = color_type; }
27  void set_color_temperature_id(uint8_t color_temperature_id) { this->color_temperature_id_ = color_temperature_id; }
28  void set_color_temperature_invert(bool color_temperature_invert) {
29  this->color_temperature_invert_ = color_temperature_invert;
30  }
31  void set_tuya_parent(Tuya *parent) { this->parent_ = parent; }
32  void set_min_value(uint32_t min_value) { min_value_ = min_value; }
33  void set_max_value(uint32_t max_value) { max_value_ = max_value; }
34  void set_color_temperature_max_value(uint32_t color_temperature_max_value) {
35  this->color_temperature_max_value_ = color_temperature_max_value;
36  }
37  void set_cold_white_temperature(float cold_white_temperature) {
38  this->cold_white_temperature_ = cold_white_temperature;
39  }
40  void set_warm_white_temperature(float warm_white_temperature) {
41  this->warm_white_temperature_ = warm_white_temperature;
42  }
43  void set_color_interlock(bool color_interlock) { color_interlock_ = color_interlock; }
44 
45  light::LightTraits get_traits() override;
46  void setup_state(light::LightState *state) override;
47  void write_state(light::LightState *state) override;
48 
49  protected:
50  void update_dimmer_(uint32_t value);
51  void update_switch_(uint32_t value);
52 
60  uint32_t min_value_ = 0;
61  uint32_t max_value_ = 255;
66  bool color_interlock_{false};
68 };
69 
70 } // namespace tuya
71 } // namespace esphome
void update_dimmer_(uint32_t value)
This class represents the communication layer between the front-end MQTT layer and the hardware outpu...
Definition: light_state.h:63
optional< uint8_t > min_value_datapoint_id_
Definition: tuya_light.h:55
optional< TuyaColorType > color_type_
Definition: tuya_light.h:58
Interface to write LightStates to hardware.
Definition: light_output.h:12
void set_color_temperature_invert(bool color_temperature_invert)
Definition: tuya_light.h:28
void set_warm_white_temperature(float warm_white_temperature)
Definition: tuya_light.h:40
light::LightTraits get_traits() override
Definition: tuya_light.cpp:113
void set_dimmer_id(uint8_t dimmer_id)
Definition: tuya_light.h:20
void set_min_value(uint32_t min_value)
Definition: tuya_light.h:32
uint32_t color_temperature_max_value_
Definition: tuya_light.h:62
optional< uint8_t > color_temperature_id_
Definition: tuya_light.h:59
void write_state(light::LightState *state) override
Definition: tuya_light.cpp:146
void set_min_value_datapoint_id(uint8_t min_value_datapoint_id)
Definition: tuya_light.h:21
optional< uint8_t > dimmer_id_
Definition: tuya_light.h:54
void setup_state(light::LightState *state) override
Definition: tuya_light.cpp:144
void set_tuya_parent(Tuya *parent)
Definition: tuya_light.h:31
void dump_config() override
Definition: tuya_light.cpp:100
optional< uint8_t > color_id_
Definition: tuya_light.h:57
void set_color_interlock(bool color_interlock)
Definition: tuya_light.h:43
void set_switch_id(uint8_t switch_id)
Definition: tuya_light.h:24
This class is used to represent the capabilities of a light.
Definition: light_traits.h:11
void set_max_value(uint32_t max_value)
Definition: tuya_light.h:33
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
void set_color_temperature_max_value(uint32_t color_temperature_max_value)
Definition: tuya_light.h:34
void set_cold_white_temperature(float cold_white_temperature)
Definition: tuya_light.h:37
void setup() override
Definition: tuya_light.cpp:10
void update_switch_(uint32_t value)
void set_color_type(TuyaColorType color_type)
Definition: tuya_light.h:26
void set_color_temperature_id(uint8_t color_temperature_id)
Definition: tuya_light.h:27
light::LightState * state_
Definition: tuya_light.h:67
optional< uint8_t > switch_id_
Definition: tuya_light.h:56
void set_color_id(uint8_t color_id)
Definition: tuya_light.h:25
bool state
Definition: fan.h:34