ESPHome  2022.12.8
tuya_light.h
Go to the documentation of this file.
1 #pragma once
2 
6 
7 namespace esphome {
8 namespace tuya {
9 
10 class TuyaLight : public Component, public light::LightOutput {
11  public:
12  void setup() override;
13  void dump_config() override;
14  void set_dimmer_id(uint8_t dimmer_id) { this->dimmer_id_ = dimmer_id; }
15  void set_min_value_datapoint_id(uint8_t min_value_datapoint_id) {
16  this->min_value_datapoint_id_ = min_value_datapoint_id;
17  }
18  void set_switch_id(uint8_t switch_id) { this->switch_id_ = switch_id; }
19  void set_rgb_id(uint8_t rgb_id) { this->rgb_id_ = rgb_id; }
20  void set_hsv_id(uint8_t hsv_id) { this->hsv_id_ = hsv_id; }
21  void set_color_temperature_id(uint8_t color_temperature_id) { this->color_temperature_id_ = color_temperature_id; }
22  void set_color_temperature_invert(bool color_temperature_invert) {
23  this->color_temperature_invert_ = color_temperature_invert;
24  }
25  void set_tuya_parent(Tuya *parent) { this->parent_ = parent; }
26  void set_min_value(uint32_t min_value) { min_value_ = min_value; }
27  void set_max_value(uint32_t max_value) { max_value_ = max_value; }
28  void set_color_temperature_max_value(uint32_t color_temperature_max_value) {
29  this->color_temperature_max_value_ = color_temperature_max_value;
30  }
31  void set_cold_white_temperature(float cold_white_temperature) {
32  this->cold_white_temperature_ = cold_white_temperature;
33  }
34  void set_warm_white_temperature(float warm_white_temperature) {
35  this->warm_white_temperature_ = warm_white_temperature;
36  }
37  void set_color_interlock(bool color_interlock) { color_interlock_ = color_interlock; }
38 
39  light::LightTraits get_traits() override;
40  void setup_state(light::LightState *state) override;
41  void write_state(light::LightState *state) override;
42 
43  protected:
44  void update_dimmer_(uint32_t value);
45  void update_switch_(uint32_t value);
46 
54  uint32_t min_value_ = 0;
55  uint32_t max_value_ = 255;
60  bool color_interlock_{false};
62 };
63 
64 } // namespace tuya
65 } // 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:34
optional< uint8_t > min_value_datapoint_id_
Definition: tuya_light.h:49
Interface to write LightStates to hardware.
Definition: light_output.h:12
void set_color_temperature_invert(bool color_temperature_invert)
Definition: tuya_light.h:22
void set_warm_white_temperature(float warm_white_temperature)
Definition: tuya_light.h:34
optional< uint8_t > hsv_id_
Definition: tuya_light.h:52
light::LightTraits get_traits() override
Definition: tuya_light.cpp:108
void set_dimmer_id(uint8_t dimmer_id)
Definition: tuya_light.h:14
void set_min_value(uint32_t min_value)
Definition: tuya_light.h:26
uint32_t color_temperature_max_value_
Definition: tuya_light.h:56
optional< uint8_t > color_temperature_id_
Definition: tuya_light.h:53
void write_state(light::LightState *state) override
Definition: tuya_light.cpp:141
void set_rgb_id(uint8_t rgb_id)
Definition: tuya_light.h:19
void set_min_value_datapoint_id(uint8_t min_value_datapoint_id)
Definition: tuya_light.h:15
optional< uint8_t > dimmer_id_
Definition: tuya_light.h:48
void set_hsv_id(uint8_t hsv_id)
Definition: tuya_light.h:20
void setup_state(light::LightState *state) override
Definition: tuya_light.cpp:139
void set_tuya_parent(Tuya *parent)
Definition: tuya_light.h:25
void dump_config() override
Definition: tuya_light.cpp:93
void set_color_interlock(bool color_interlock)
Definition: tuya_light.h:37
void set_switch_id(uint8_t switch_id)
Definition: tuya_light.h:18
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:27
Definition: a4988.cpp:4
void set_color_temperature_max_value(uint32_t color_temperature_max_value)
Definition: tuya_light.h:28
void set_cold_white_temperature(float cold_white_temperature)
Definition: tuya_light.h:31
void setup() override
Definition: tuya_light.cpp:10
void update_switch_(uint32_t value)
optional< uint8_t > rgb_id_
Definition: tuya_light.h:51
void set_color_temperature_id(uint8_t color_temperature_id)
Definition: tuya_light.h:21
light::LightState * state_
Definition: tuya_light.h:61
optional< uint8_t > switch_id_
Definition: tuya_light.h:50
bool state
Definition: fan.h:34