mirror of
https://github.com/Threnklyn/esphome-dev.git
synced 2026-06-07 05:13:31 +02:00
Add new component for Tuya dimmers (#743)
* Add new component for Tuya dimmers * Update code * Class naming * Log output * Fixes * Lint * Format * Fix test * log setting datapoint values * remove in_setup_ and fix datapoint handling Co-authored-by: Samuel Sieb <samuel@sieb.net> Co-authored-by: Otto Winter <otto@otto-winter.com>
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
#pragma once
|
||||
|
||||
#include "esphome/core/component.h"
|
||||
#include "esphome/components/tuya/tuya.h"
|
||||
#include "esphome/components/light/light_output.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace tuya {
|
||||
|
||||
class TuyaLight : public Component, public light::LightOutput {
|
||||
public:
|
||||
void setup() override;
|
||||
void dump_config() override;
|
||||
void set_dimmer_id(uint8_t dimmer_id) { this->dimmer_id_ = dimmer_id; }
|
||||
void set_switch_id(uint8_t switch_id) { this->switch_id_ = switch_id; }
|
||||
void set_tuya_parent(Tuya *parent) { this->parent_ = parent; }
|
||||
void set_min_value(uint32_t min_value) { min_value_ = min_value; }
|
||||
void set_max_value(uint32_t max_value) { max_value_ = max_value; }
|
||||
light::LightTraits get_traits() override;
|
||||
void setup_state(light::LightState *state) override;
|
||||
void write_state(light::LightState *state) override;
|
||||
|
||||
protected:
|
||||
void update_dimmer_(uint32_t value);
|
||||
void update_switch_(uint32_t value);
|
||||
|
||||
Tuya *parent_;
|
||||
optional<uint8_t> dimmer_id_{};
|
||||
optional<uint8_t> switch_id_{};
|
||||
uint32_t min_value_ = 0;
|
||||
uint32_t max_value_ = 255;
|
||||
light::LightState *state_{nullptr};
|
||||
};
|
||||
|
||||
} // namespace tuya
|
||||
} // namespace esphome
|
||||
Reference in New Issue
Block a user