41 lines
1.1 KiB
C++
41 lines
1.1 KiB
C++
#include "tw7100_select.h"
|
|
#include "esphome/core/log.h"
|
|
#include "esphome/core/defines.h"
|
|
#include "esphome/core/helpers.h"
|
|
|
|
namespace esphome {
|
|
namespace tw7100 {
|
|
|
|
std::vector<std::string> get_map_keys(std::map<std::string, uint8_t> map_) {
|
|
std::vector<std::string> map_keys;
|
|
for (auto element : map_) { map_keys.push_back(element.first); }
|
|
return map_keys;
|
|
};
|
|
|
|
void tw7100Select::setup() {
|
|
static const char *const TAG = "tw7100Select::setup()";
|
|
if (cmd_ == "SOURCE") {
|
|
traits.set_options(get_map_keys(sources));
|
|
}
|
|
ESP_LOGV(TAG, "control done");
|
|
}
|
|
|
|
void tw7100Select::dump_config() {
|
|
static const char *const TAG = "dump_config()";
|
|
ESP_LOGCONFIG(TAG, "TW7100:");
|
|
LOG_SELECT(TAG, "tw7100Select", this);
|
|
}
|
|
|
|
void tw7100Select::control(const std::string &value) {
|
|
static const char *const TAG = "tw7100Select::control()";
|
|
|
|
if (cmd_ == "SOURCE") {
|
|
uint8_t source_number = sources[value];
|
|
ESP_LOGV("", "Source selection: %s, sending code %02x", value.c_str(), source_number);
|
|
}
|
|
ESP_LOGV(TAG, "control done");
|
|
};
|
|
|
|
} // namespace tw7100
|
|
} // namespace esphome
|