Add Tuya select (#3469)

This commit is contained in:
Maxim Ocheretianko
2022-05-15 22:49:40 +03:00
committed by GitHub
parent 0665acd190
commit f62d5d3b9d
6 changed files with 140 additions and 0 deletions
@@ -0,0 +1,30 @@
#pragma once
#include "esphome/core/component.h"
#include "esphome/components/tuya/tuya.h"
#include "esphome/components/select/select.h"
namespace esphome {
namespace tuya {
class TuyaSelect : public select::Select, public Component {
public:
void setup() override;
void dump_config() override;
void set_tuya_parent(Tuya *parent) { this->parent_ = parent; }
void set_optimistic(bool optimistic) { this->optimistic_ = optimistic; }
void set_select_id(uint8_t select_id) { this->select_id_ = select_id; }
void set_select_mappings(std::vector<uint8_t> mappings) { this->mappings_ = std::move(mappings); }
protected:
void control(const std::string &value) override;
Tuya *parent_;
bool optimistic_ = false;
uint8_t select_id_;
std::vector<uint8_t> mappings_;
};
} // namespace tuya
} // namespace esphome