Compare commits
1 commit
main
...
dummy_clas
Author | SHA1 | Date | |
---|---|---|---|
sqozz | 8ae2dd3300 |
|
@ -140,24 +140,6 @@ void tw7100Select::control(const std::string &value) {
|
|||
for (auto element : luminance) { if (element.second == value) { param = element.first; break; } }
|
||||
} else if (cmd_ == "ASPECT") {
|
||||
for (auto element : aspect) { if (element.second == value) { param = element.first; break; } }
|
||||
} else if ( cmd_ == "OVSCAN") {
|
||||
for (auto element : aspect) { if (element.second == value) { param = element.first; break; } }
|
||||
} else if ( cmd_ == "CMODE") {
|
||||
for (auto element : cmode) { if (element.second == value) { param = element.first; break; } }
|
||||
} else if ( cmd_ == "GAMMA") {
|
||||
for (auto element : gamma) { if (element.second == value) { param = element.first; break; } }
|
||||
} else if ( cmd_ == "IMGPRESET") {
|
||||
for (auto element : imgpreset) { if (element.second == value) { param = element.first; break; } }
|
||||
} else if ( cmd_ == "MCFI") {
|
||||
for (auto element : mcfi) { if (element.second == value) { param = element.first; break; } }
|
||||
} else if ( cmd_ == "CLRSPACE") {
|
||||
for (auto element : clrspace) { if (element.second == value) { param = element.first; break; } }
|
||||
} else if ( cmd_ == "DYNRANGE") {
|
||||
for (auto element : dynrange) { if (element.second == value) { param = element.first; break; } }
|
||||
} else if ( cmd_ == "MSEL") {
|
||||
for (auto element : msel) { if (element.second == value) { param = element.first; break; } }
|
||||
} else if ( cmd_ == "SPEED") {
|
||||
//for (auto element : speed) { if (element.second == value) { param = element.first; break; } }
|
||||
}
|
||||
|
||||
if (param.length() > 0) {
|
||||
|
@ -171,102 +153,5 @@ void tw7100Select::control(const std::string &value) {
|
|||
ESP_LOGV(TAG, "control done");
|
||||
};
|
||||
|
||||
void tw7100Select::set_option_by_key(std::string key) {
|
||||
static const char *const TAG = "tw7100Select::set_option_by_key()";
|
||||
|
||||
std::string value_found = "";
|
||||
if ( cmd_ == "LUMINANCE") {
|
||||
ESP_LOGV(TAG, "updating luminance select");
|
||||
if(tw7100Select::luminance.find(key) != tw7100Select::luminance.end()) {
|
||||
value_found = tw7100Select::luminance[key];
|
||||
} else {
|
||||
ESP_LOGE(TAG, "Result %s not present in options", key);
|
||||
}
|
||||
} else if ( cmd_ == "SOURCE") {
|
||||
ESP_LOGV(TAG, "updating source select");
|
||||
if(tw7100Select::sources.find(key) != tw7100Select::sources.end()) {
|
||||
value_found = tw7100Select::sources[key];
|
||||
} else {
|
||||
ESP_LOGE(TAG, "Result %s not present in options", key);
|
||||
}
|
||||
} else if ( cmd_ == "ASPECT") {
|
||||
ESP_LOGV(TAG, "updating aspect select");
|
||||
if(tw7100Select::aspect.find(key) != tw7100Select::aspect.end()) {
|
||||
value_found = tw7100Select::aspect[key];
|
||||
} else {
|
||||
ESP_LOGE(TAG, "Result %s not present in options", key);
|
||||
}
|
||||
} else if ( cmd_ == "OVSCAN") {
|
||||
ESP_LOGV(TAG, "updating ovscan select");
|
||||
if(tw7100Select::ovscan.find(key) != tw7100Select::ovscan.end()) {
|
||||
value_found = tw7100Select::ovscan[key];
|
||||
} else {
|
||||
ESP_LOGE(TAG, "Result %s not present in options", key);
|
||||
}
|
||||
} else if ( cmd_ == "CMODE") {
|
||||
ESP_LOGV(TAG, "updating cmode select");
|
||||
if(tw7100Select::cmode.find(key) != tw7100Select::cmode.end()) {
|
||||
value_found = tw7100Select::cmode[key];
|
||||
} else {
|
||||
ESP_LOGE(TAG, "Result %s not present in options", key);
|
||||
}
|
||||
} else if ( cmd_ == "GAMMA") {
|
||||
ESP_LOGV(TAG, "updating gamma select");
|
||||
if(tw7100Select::gamma.find(key) != tw7100Select::gamma.end()) {
|
||||
value_found = tw7100Select::gamma[key];
|
||||
} else {
|
||||
ESP_LOGE(TAG, "Result %s not present in options", key);
|
||||
}
|
||||
} else if ( cmd_ == "IMGPRESET") {
|
||||
ESP_LOGV(TAG, "updating imgpreset select");
|
||||
if(tw7100Select::imgpreset.find(key) != tw7100Select::imgpreset.end()) {
|
||||
value_found = tw7100Select::imgpreset[key];
|
||||
} else {
|
||||
ESP_LOGE(TAG, "Result %s not present in options", key);
|
||||
}
|
||||
} else if ( cmd_ == "MCFI") {
|
||||
ESP_LOGV(TAG, "updating mcfi select");
|
||||
if(tw7100Select::mcfi.find(key) != tw7100Select::mcfi.end()) {
|
||||
value_found = tw7100Select::mcfi[key];
|
||||
} else {
|
||||
ESP_LOGE(TAG, "Result %s not present in options", key);
|
||||
}
|
||||
} else if ( cmd_ == "CLRSPACE") {
|
||||
ESP_LOGV(TAG, "updating clrspace select");
|
||||
if(tw7100Select::clrspace.find(key) != tw7100Select::clrspace.end()) {
|
||||
value_found = tw7100Select::clrspace[key];
|
||||
} else {
|
||||
ESP_LOGE(TAG, "Result %s not present in options", key);
|
||||
}
|
||||
} else if ( cmd_ == "DYNRANGE") {
|
||||
ESP_LOGV(TAG, "updating dynrange select");
|
||||
if(tw7100Select::dynrange.find(key) != tw7100Select::dynrange.end()) {
|
||||
value_found = tw7100Select::dynrange[key];
|
||||
} else {
|
||||
ESP_LOGE(TAG, "Result %s not present in options", key);
|
||||
}
|
||||
} else if ( cmd_ == "MSEL") {
|
||||
ESP_LOGV(TAG, "updating msel select");
|
||||
if(tw7100Select::msel.find(key) != tw7100Select::msel.end()) {
|
||||
value_found = tw7100Select::msel[key];
|
||||
} else {
|
||||
ESP_LOGE(TAG, "Result %s not present in options", key);
|
||||
}
|
||||
} else if ( cmd_ == "SPEED") {
|
||||
ESP_LOGV(TAG, "updating speed select");
|
||||
if(tw7100Select::speed.find(key) != tw7100Select::speed.end()) {
|
||||
value_found = tw7100Select::speed[key];
|
||||
} else {
|
||||
ESP_LOGE(TAG, "Result %s not present in options", key);
|
||||
}
|
||||
}
|
||||
|
||||
if (value_found.length() > 0) {
|
||||
auto call = make_call();
|
||||
call.set_option(value_found);
|
||||
call.perform();
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace tw7100
|
||||
} // namespace esphome
|
||||
|
|
|
@ -15,7 +15,6 @@ class tw7100Select : public select::Select, public Component {
|
|||
void dump_config() override;
|
||||
void set_tw7100_parent(tw7100Component *parent) { this->parent_ = parent; }
|
||||
void set_cmd(std::string cmd) { this->cmd_ = cmd; }
|
||||
void set_option_by_key(std::string key);
|
||||
static std::map<std::string, std::string> sources;
|
||||
static std::map<std::string, std::string> luminance;
|
||||
static std::map<std::string, std::string> aspect;
|
||||
|
|
204
tw7100.cpp
204
tw7100.cpp
|
@ -1,5 +1,4 @@
|
|||
#include "tw7100.h"
|
||||
#include <deque>
|
||||
#include "esphome/core/log.h"
|
||||
#include "esphome/core/defines.h"
|
||||
#include "esphome/core/helpers.h"
|
||||
|
@ -221,203 +220,284 @@ void tw7100Component::update_sensor(std::pair<std::string, std::string> data) {
|
|||
int value = std::stoi(value_string);
|
||||
powered = (value > 0);
|
||||
#ifdef USE_BINARY_SENSOR
|
||||
powered_->publish_state(value > 0);
|
||||
//if (powered_) powered_->publish_state(value > 0);
|
||||
#endif
|
||||
#ifdef USE_SWITCH
|
||||
power_switch_->publish_state(value > 0); // ack previous cmd or update switch
|
||||
if (power_switch_) power_switch_->publish_state(value > 0); // ack previous cmd or update switch
|
||||
#endif
|
||||
#ifdef USE_SENSOR
|
||||
power_status_->publish_state(value);
|
||||
if (power_status_) power_status_->publish_state(value);
|
||||
#endif
|
||||
} else if (cmd == "LAMP") {
|
||||
ESP_LOGV(TAG, "updating lamp sensors");
|
||||
#ifdef USE_SENSOR
|
||||
int value = std::stoi(value_string);
|
||||
lamp_hours_->publish_state(value);
|
||||
if (lamp_hours_) lamp_hours_->publish_state(value);
|
||||
#endif
|
||||
} else if (cmd == "SIGNAL") {
|
||||
ESP_LOGV(TAG, "updating signal sensors");
|
||||
int value = std::stoi(value_string);
|
||||
#endif
|
||||
#ifdef USE_BINARY_SENSOR
|
||||
has_signal_->publish_state(value > 0);
|
||||
#endif
|
||||
#ifdef USE_SENSOR
|
||||
signal_status_->publish_state(value);
|
||||
#endif
|
||||
#ifdef USE_SELECT
|
||||
if (signal_status_) signal_status_->publish_state(value);
|
||||
} else if (cmd == "LUMINANCE") {
|
||||
ESP_LOGV(TAG, "updating luminance sensors");
|
||||
#ifdef USE_SENSOR
|
||||
int value = std::stoi(value_string);
|
||||
luminance_level_->publish_state(value);
|
||||
luminance_select_->set_option_by_key(value_string);
|
||||
if (luminance_level_) luminance_level_->publish_state(value);
|
||||
#endif
|
||||
#ifdef USE_SELECT
|
||||
if (luminance_select_) {
|
||||
if(tw7100Select::luminance.find(value_string) != tw7100Select::luminance.end()) {
|
||||
auto call = luminance_select_->make_call();
|
||||
call.set_option(tw7100Select::luminance[value_string]);
|
||||
call.perform();
|
||||
} else {
|
||||
ESP_LOGE(TAG, "Result %s not present in options", value_string);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
} else if (cmd == "SOURCE") {
|
||||
ESP_LOGV(TAG, "updating source select");
|
||||
source_select_->set_option_by_key(value_string);
|
||||
#ifdef USE_SELECT
|
||||
if (source_select_) {
|
||||
if(tw7100Select::sources.find(value_string) != tw7100Select::sources.end()) {
|
||||
auto call = source_select_->make_call();
|
||||
call.set_option(tw7100Select::sources[value_string]);
|
||||
call.perform();
|
||||
} else {
|
||||
ESP_LOGE(TAG, "Result %s not present in options", value_string);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
} else if (cmd == "ASPECT") {
|
||||
ESP_LOGV(TAG, "updating aspect select");
|
||||
aspect_select_->set_option_by_key(value_string);
|
||||
#ifdef USE_SELECT
|
||||
if (aspect_select_) {
|
||||
if(tw7100Select::aspect.find(value_string) != tw7100Select::aspect.end()) {
|
||||
auto call = aspect_select_->make_call();
|
||||
call.set_option(tw7100Select::aspect[value_string]);
|
||||
call.perform();
|
||||
} else {
|
||||
ESP_LOGE(TAG, "Result %s not present in options", value_string);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
} else if (cmd == "OVSCAN") {
|
||||
ESP_LOGV(TAG, "updating ovscan select");
|
||||
ovscan_select_->set_option_by_key(value_string);
|
||||
} else if (cmd == "CMODE") {
|
||||
ESP_LOGV(TAG, "updating cmode select");
|
||||
cmode_select_->set_option_by_key(value_string);
|
||||
} else if (cmd == "GAMMA") {
|
||||
ESP_LOGV(TAG, "updating gamma select");
|
||||
gamma_select_->set_option_by_key(value_string);
|
||||
} else if (cmd == "IMGPRESET") {
|
||||
ESP_LOGV(TAG, "updating imgpreset select");
|
||||
imgpreset_select_->set_option_by_key(value_string);
|
||||
} else if (cmd == "MCFI") {
|
||||
ESP_LOGV(TAG, "updating mcfi select");
|
||||
mcfi_select_->set_option_by_key(value_string);
|
||||
} else if (cmd == "CLRSPACE") {
|
||||
ESP_LOGV(TAG, "updating clrspace select");
|
||||
clrspace_select_->set_option_by_key(value_string);
|
||||
} else if (cmd == "DYNRANGE") {
|
||||
ESP_LOGV(TAG, "updating dynrange select");
|
||||
dynrange_select_->set_option_by_key(value_string);
|
||||
} else if (cmd == "MSEL") {
|
||||
ESP_LOGV(TAG, "updating msel select");
|
||||
msel_select_->set_option_by_key(value_string);
|
||||
} else if (cmd == "SPEED") {
|
||||
ESP_LOGV(TAG, "updating speed select");
|
||||
speed_select_->set_option_by_key(value_string);
|
||||
#endif
|
||||
#ifdef USE_TEXT_SENSOR
|
||||
} else if (cmd == "SNO") {
|
||||
serial_->publish_state(value_string);
|
||||
if (serial_ != nullptr) serial_->publish_state(value_string);
|
||||
#endif
|
||||
#ifdef USE_SWITCH
|
||||
} else if (cmd == "BTAUDIO") {
|
||||
ESP_LOGV(TAG, "updating btaudio switch");
|
||||
#ifdef USE_SWITCH
|
||||
int value = std::stoi(value_string);
|
||||
btaudio_switch_->publish_state(value > 0);
|
||||
if (btaudio_switch_) btaudio_switch_->publish_state(value > 0);
|
||||
#endif
|
||||
} else if (cmd == "4KENHANCE") {
|
||||
ESP_LOGV(TAG, "updating 4kenhance switch");
|
||||
#ifdef USE_SWITCH
|
||||
int value = std::stoi(value_string);
|
||||
_4kenhance_switch_->publish_state(value > 0);
|
||||
if (_4kenhance_switch_) _4kenhance_switch_->publish_state(value > 0);
|
||||
#endif
|
||||
} else if (cmd == "IMGPROC") {
|
||||
ESP_LOGV(TAG, "updating imgproc switch");
|
||||
#ifdef USE_SWITCH
|
||||
int value = std::stoi(value_string);
|
||||
img_processing_switch_->publish_state(value > 1);
|
||||
if (img_processing_switch_) img_processing_switch_->publish_state(value > 1);
|
||||
#endif
|
||||
} else if (cmd == "AUDIOOUT") {
|
||||
ESP_LOGV(TAG, "updating audioout switch");
|
||||
#ifdef USE_SWITCH
|
||||
int value = std::stoi(value_string);
|
||||
audioout_switch_->publish_state(value == 11);
|
||||
if (audioout_switch_) audioout_switch_->publish_state(value == 11);
|
||||
#endif
|
||||
} else if (cmd == "HREVERSE") {
|
||||
ESP_LOGV(TAG, "updating hflip switch");
|
||||
hflip_switch_->publish_state(value_string == "ON");
|
||||
#ifdef USE_SWITCH
|
||||
if (hflip_switch_) hflip_switch_->publish_state(value_string == "ON");
|
||||
#endif
|
||||
} else if (cmd == "VREVERSE") {
|
||||
ESP_LOGV(TAG, "updating vflip switch");
|
||||
vflip_switch_->publish_state(value_string == "ON");
|
||||
#ifdef USE_SWITCH
|
||||
if (vflip_switch_) vflip_switch_->publish_state(value_string == "ON");
|
||||
#endif
|
||||
} else if (cmd == "ILLUM") {
|
||||
ESP_LOGV(TAG, "updating illumination switch");
|
||||
#ifdef USE_SWITCH
|
||||
int value = std::stoi(value_string);
|
||||
illumination_switch_->publish_state(value == 1);
|
||||
if (illumination_switch_) illumination_switch_->publish_state(value == 1);
|
||||
#endif
|
||||
} else if (cmd == "STANDBYCONF") {
|
||||
ESP_LOGV(TAG, "updating standbyconf switch");
|
||||
#ifdef USE_SWITCH
|
||||
int value = std::stoi(value_string);
|
||||
standbyconf_switch_->publish_state(value == 1);
|
||||
if (standbyconf_switch_) standbyconf_switch_->publish_state(value == 1);
|
||||
#endif
|
||||
} else if (cmd == "AUTOHOME") {
|
||||
ESP_LOGV(TAG, "updating autohome switch");
|
||||
#ifdef USE_SWITCH
|
||||
int value = std::stoi(value_string);
|
||||
autohome_switch_->publish_state(value == 1);
|
||||
if (autohome_switch_) autohome_switch_->publish_state(value == 1);
|
||||
#endif
|
||||
} else if (cmd == "WLPWR") {
|
||||
ESP_LOGV(TAG, "updating wlan power switch");
|
||||
#ifdef USE_SWITCH
|
||||
int value = std::stoi(value_string);
|
||||
wlan_power_switch_->publish_state(value == 1);
|
||||
if (wlan_power_switch_) wlan_power_switch_->publish_state(value == 1);
|
||||
#endif
|
||||
} else if (cmd == "LOGTO") {
|
||||
ESP_LOGV(TAG, "updating logto switch");
|
||||
#ifdef USE_SWITCH
|
||||
int value = std::stoi(value_string);
|
||||
logto_switch_->publish_state(value == 1);
|
||||
if (logto_switch_) logto_switch_->publish_state(value == 1);
|
||||
#endif
|
||||
} else if (cmd == "MUTE") {
|
||||
ESP_LOGV(TAG, "updating mute switch with value %s", value_string.c_str());
|
||||
mute_switch_->publish_state(value_string == "ON");
|
||||
#ifdef USE_SWITCH
|
||||
if (mute_switch_) mute_switch_->publish_state(value_string == "ON");
|
||||
#endif
|
||||
#ifdef USE_NUMBER
|
||||
} else if (cmd == "VOL") {
|
||||
ESP_LOGV(TAG, "updating volume number with value %s", value_string.c_str());
|
||||
#ifdef USE_NUMBER
|
||||
int value = std::stoi(value_string);
|
||||
volume_number_->publish_state(value);
|
||||
if (volume_number_) volume_number_->publish_state(value);
|
||||
#endif
|
||||
} else if (cmd == "VKEYSTONE") {
|
||||
ESP_LOGV(TAG, "updating vkeystone number with value %s", value_string.c_str());
|
||||
#ifdef USE_NUMBER
|
||||
int value = std::stoi(value_string);
|
||||
vkeystone_number_->publish_state(value);
|
||||
if (vkeystone_number_) vkeystone_number_->publish_state(value);
|
||||
#endif
|
||||
} else if (cmd == "HKEYSTONE") {
|
||||
ESP_LOGV(TAG, "updating hkeystone number with value %s", value_string.c_str());
|
||||
#ifdef USE_NUMBER
|
||||
int value = std::stoi(value_string);
|
||||
hkeystone_number_->publish_state(value);
|
||||
if (hkeystone_number_) hkeystone_number_->publish_state(value);
|
||||
#endif
|
||||
} else if (cmd == "BRIGHT") {
|
||||
ESP_LOGV(TAG, "updating brightness number with value %s", value_string.c_str());
|
||||
#ifdef USE_NUMBER
|
||||
int value = std::stoi(value_string);
|
||||
brightness_number_->publish_state(value);
|
||||
if (brightness_number_) brightness_number_->publish_state(value);
|
||||
#endif
|
||||
} else if (cmd == "CONTRAST") {
|
||||
ESP_LOGV(TAG, "updating contrast number with value %s", value_string.c_str());
|
||||
#ifdef USE_NUMBER
|
||||
int value = std::stoi(value_string);
|
||||
contrast_number_->publish_state(value);
|
||||
if (contrast_number_) contrast_number_->publish_state(value);
|
||||
#endif
|
||||
} else if (cmd == "DENSITY") {
|
||||
ESP_LOGV(TAG, "updating density number with value %s", value_string.c_str());
|
||||
#ifdef USE_NUMBER
|
||||
int value = std::stoi(value_string);
|
||||
density_number_->publish_state(value);
|
||||
if (density_number_) density_number_->publish_state(value);
|
||||
#endif
|
||||
} else if (cmd == "TINT") {
|
||||
ESP_LOGV(TAG, "updating tint number with value %s", value_string.c_str());
|
||||
#ifdef USE_NUMBER
|
||||
int value = std::stoi(value_string);
|
||||
tint_number_->publish_state(value);
|
||||
if (tint_number_) tint_number_->publish_state(value);
|
||||
#endif
|
||||
} else if (cmd == "CTEMP") {
|
||||
ESP_LOGV(TAG, "updating ctemp number with value %s", value_string.c_str());
|
||||
#ifdef USE_NUMBER
|
||||
int value = std::stoi(value_string);
|
||||
ctemp_number_->publish_state(value);
|
||||
if (ctemp_number_) ctemp_number_->publish_state(value);
|
||||
#endif
|
||||
} else if (cmd == "FCOLOR") {
|
||||
ESP_LOGV(TAG, "updating fcolor number with value %s", value_string.c_str());
|
||||
#ifdef USE_NUMBER
|
||||
int value = std::stoi(value_string);
|
||||
fcolor_number_->publish_state(value);
|
||||
if (fcolor_number_) fcolor_number_->publish_state(value);
|
||||
#endif
|
||||
} else if (cmd == "NRS") {
|
||||
ESP_LOGV(TAG, "updating nrs number with value %s", value_string.c_str());
|
||||
#ifdef USE_NUMBER
|
||||
int value = std::stoi(value_string);
|
||||
nrs_number_->publish_state(value);
|
||||
if (nrs_number_) nrs_number_->publish_state(value);
|
||||
#endif
|
||||
} else if (cmd == "MPEGNRS") {
|
||||
ESP_LOGV(TAG, "updating mpegngs number with value %s", value_string.c_str());
|
||||
#ifdef USE_NUMBER
|
||||
int value = std::stoi(value_string);
|
||||
mpegnrs_number_->publish_state(value);
|
||||
if (mpegnrs_number_) mpegnrs_number_->publish_state(value);
|
||||
#endif
|
||||
} else if (cmd == "OFFSETR") {
|
||||
ESP_LOGV(TAG, "updating offsetr number with value %s", value_string.c_str());
|
||||
#ifdef USE_NUMBER
|
||||
int value = std::stoi(value_string);
|
||||
offsetr_number_->publish_state(value);
|
||||
if (offsetr_number_) offsetr_number_->publish_state(value);
|
||||
#endif
|
||||
} else if (cmd == "OFFSETG") {
|
||||
ESP_LOGV(TAG, "updating offsetg number with value %s", value_string.c_str());
|
||||
#ifdef USE_NUMBER
|
||||
int value = std::stoi(value_string);
|
||||
offsetg_number_->publish_state(value);
|
||||
if (offsetg_number_) offsetg_number_->publish_state(value);
|
||||
#endif
|
||||
} else if (cmd == "OFFSETB") {
|
||||
ESP_LOGV(TAG, "updating offsetb number with value %s", value_string.c_str());
|
||||
#ifdef USE_NUMBER
|
||||
int value = std::stoi(value_string);
|
||||
offsetb_number_->publish_state(value);
|
||||
if (offsetb_number_) offsetb_number_->publish_state(value);
|
||||
#endif
|
||||
} else if (cmd == "GAINR") {
|
||||
ESP_LOGV(TAG, "updating gainr number with value %s", value_string.c_str());
|
||||
#ifdef USE_NUMBER
|
||||
int value = std::stoi(value_string);
|
||||
gainr_number_->publish_state(value);
|
||||
if (gainr_number_) gainr_number_->publish_state(value);
|
||||
#endif
|
||||
} else if (cmd == "GAING") {
|
||||
ESP_LOGV(TAG, "updating gaing number with value %s", value_string.c_str());
|
||||
#ifdef USE_NUMBER
|
||||
int value = std::stoi(value_string);
|
||||
gaing_number_->publish_state(value);
|
||||
if (gaing_number_) gaing_number_->publish_state(value);
|
||||
#endif
|
||||
} else if (cmd == "GAINB") {
|
||||
ESP_LOGV(TAG, "updating gainb number with value %s", value_string.c_str());
|
||||
#ifdef USE_NUMBER
|
||||
int value = std::stoi(value_string);
|
||||
gainb_number_->publish_state(value);
|
||||
if (gainb_number_) gainb_number_->publish_state(value);
|
||||
#endif
|
||||
} else if (cmd == "SHRF") {
|
||||
ESP_LOGV(TAG, "updating shrf number with value %s", value_string.c_str());
|
||||
#ifdef USE_NUMBER
|
||||
int value = std::stoi(value_string);
|
||||
shrf_number_->publish_state(value);
|
||||
if (shrf_number_) shrf_number_->publish_state(value);
|
||||
#endif
|
||||
} else if (cmd == "SHRS") {
|
||||
ESP_LOGV(TAG, "updating shrs number with value %s", value_string.c_str());
|
||||
#ifdef USE_NUMBER
|
||||
int value = std::stoi(value_string);
|
||||
shrs_number_->publish_state(value);
|
||||
if (shrs_number_) shrs_number_->publish_state(value);
|
||||
#endif
|
||||
} else if (cmd == "DERANGE") {
|
||||
ESP_LOGV(TAG, "updating derange number with value %s", value_string.c_str());
|
||||
#ifdef USE_NUMBER
|
||||
int value = std::stoi(value_string);
|
||||
derange_number_->publish_state(value);
|
||||
if (derange_number_) derange_number_->publish_state(value);
|
||||
#endif
|
||||
} else if (cmd == "DESTRENGTH") {
|
||||
ESP_LOGV(TAG, "updating destrength number with value %s", value_string.c_str());
|
||||
#ifdef USE_NUMBER
|
||||
int value = std::stoi(value_string);
|
||||
destrength_number_->publish_state(value);
|
||||
if (destrength_number_) destrength_number_->publish_state(value);
|
||||
#endif
|
||||
} else {
|
||||
ESP_LOGW(TAG, "Command %s unknown, skipping updating sensor with value", cmd.c_str());
|
||||
|
|
168
tw7100.h
168
tw7100.h
|
@ -1,10 +1,8 @@
|
|||
#pragma once
|
||||
|
||||
#include "esphome/core/component.h"
|
||||
#include "esphome/core/entity_base.h"
|
||||
#include "esphome/core/log.h"
|
||||
#include "esphome/components/uart/uart.h"
|
||||
#include <map>
|
||||
|
||||
#ifdef USE_SENSOR
|
||||
#include "esphome/components/sensor/sensor.h"
|
||||
|
@ -20,7 +18,6 @@
|
|||
|
||||
#ifdef USE_SWITCH
|
||||
#include "esphome/components/switch/switch.h"
|
||||
#include "switch/tw7100_switch.h"
|
||||
#endif
|
||||
|
||||
#ifdef USE_SELECT
|
||||
|
@ -33,6 +30,27 @@
|
|||
#include "number/tw7100_number.h"
|
||||
#endif
|
||||
|
||||
namespace esphome {
|
||||
#ifndef USE_SENSOR
|
||||
namespace sensor {
|
||||
class Sensor : public Component {
|
||||
public:
|
||||
void publish_state(float state) { ESP_LOGW("dummy_sensor", "skipping updating value for this unconfigured sensor"); };
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef USE_BINARY_SENSOR
|
||||
namespace binary_sensor {
|
||||
class BinarySensor : public Component {
|
||||
public:
|
||||
void publish_state(bool state) { ESP_LOGW("dummy_binary_sensor", "skipping updating value for this unconfigured sensor"); };
|
||||
};
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
namespace esphome {
|
||||
namespace tw7100 {
|
||||
|
||||
|
@ -69,20 +87,20 @@ class tw7100Component : public PollingComponent, public uart::UARTDevice {
|
|||
void set_serial(text_sensor::TextSensor *serial) { this->serial_ = serial; }
|
||||
#endif
|
||||
#ifdef USE_SWITCH
|
||||
void set_set_pwr(tw7100::tw7100Switch *switch_) { this->power_switch_ = switch_; }
|
||||
void set_set_btaudio(tw7100::tw7100Switch *switch_) { this->btaudio_switch_ = switch_; }
|
||||
void set_set_mute(tw7100::tw7100Switch *switch_) { this->mute_switch_ = switch_; }
|
||||
void set_set_wlpwr(tw7100::tw7100Switch *switch_) { this->wlan_power_switch_ = switch_; }
|
||||
void set_set_autohome(tw7100::tw7100Switch *switch_) { this->autohome_switch_ = switch_; }
|
||||
void set_set_product(tw7100::tw7100Switch *switch_) { this->product_switch_ = switch_; }
|
||||
void set_set_standbyconf(tw7100::tw7100Switch *switch_) { this->standbyconf_switch_ = switch_; }
|
||||
void set_set_illum(tw7100::tw7100Switch *switch_) { this->illumination_switch_ = switch_; }
|
||||
void set_set_vreverse(tw7100::tw7100Switch *switch_) { this->vflip_switch_ = switch_; }
|
||||
void set_set_hreverse(tw7100::tw7100Switch *switch_) { this->hflip_switch_ = switch_; }
|
||||
void set_set_audioout(tw7100::tw7100Switch *switch_) { this->audioout_switch_ = switch_; }
|
||||
void set_set_imgproc(tw7100::tw7100Switch *switch_) { this->img_processing_switch_ = switch_; }
|
||||
void set_set_4kenhance(tw7100::tw7100Switch *switch_) { this->_4kenhance_switch_ = switch_; }
|
||||
void set_set_logto(tw7100::tw7100Switch *switch_) { this->logto_switch_ = switch_; }
|
||||
void set_set_pwr(switch_::Switch *switch_) { this->power_switch_ = switch_; }
|
||||
void set_set_btaudio(switch_::Switch *switch_) { this->btaudio_switch_ = switch_; }
|
||||
void set_set_mute(switch_::Switch *switch_) { this->mute_switch_ = switch_; }
|
||||
void set_set_wlpwr(switch_::Switch *switch_) { this->wlan_power_switch_ = switch_; }
|
||||
void set_set_autohome(switch_::Switch *switch_) { this->autohome_switch_ = switch_; }
|
||||
void set_set_product(switch_::Switch *switch_) { this->product_switch_ = switch_; }
|
||||
void set_set_standbyconf(switch_::Switch *switch_) { this->standbyconf_switch_ = switch_; }
|
||||
void set_set_illum(switch_::Switch *switch_) { this->illumination_switch_ = switch_; }
|
||||
void set_set_vreverse(switch_::Switch *switch_) { this->vflip_switch_ = switch_; }
|
||||
void set_set_hreverse(switch_::Switch *switch_) { this->hflip_switch_ = switch_; }
|
||||
void set_set_audioout(switch_::Switch *switch_) { this->audioout_switch_ = switch_; }
|
||||
void set_set_imgproc(switch_::Switch *switch_) { this->img_processing_switch_ = switch_; }
|
||||
void set_set_4kenhance(switch_::Switch *switch_) { this->_4kenhance_switch_ = switch_; }
|
||||
void set_set_logto(switch_::Switch *switch_) { this->logto_switch_ = switch_; }
|
||||
#endif
|
||||
#ifdef USE_SELECT
|
||||
void set_set_source(tw7100::tw7100Select *select_) { this->source_select_ = select_; }
|
||||
|
@ -123,91 +141,71 @@ class tw7100Component : public PollingComponent, public uart::UARTDevice {
|
|||
#endif
|
||||
|
||||
private:
|
||||
#ifdef USE_BINARY_SENSOR
|
||||
binary_sensor::BinarySensor *dummy_binary_sensor = new binary_sensor::BinarySensor();
|
||||
#endif
|
||||
#ifdef USE_SENSOR
|
||||
sensor::Sensor *dummy_sensor = new sensor::Sensor();
|
||||
#endif
|
||||
#ifdef USE_TEXT_SENSOR
|
||||
text_sensor::TextSensor *dummy_text_sensor = new text_sensor::TextSensor();
|
||||
#endif
|
||||
#ifdef USE_SWITCH
|
||||
tw7100::tw7100Switch *dummy_switch = new tw7100::tw7100Switch();
|
||||
#endif
|
||||
#ifdef USE_SELECT
|
||||
tw7100::tw7100Select *dummy_select = new tw7100::tw7100Select();
|
||||
#endif
|
||||
#ifdef USE_NUMBER
|
||||
tw7100::tw7100Number *dummy_number = new tw7100::tw7100Number();
|
||||
#endif
|
||||
|
||||
protected:
|
||||
#ifdef USE_BINARY_SENSOR
|
||||
binary_sensor::BinarySensor *powered_ = dummy_binary_sensor;
|
||||
binary_sensor::BinarySensor *has_signal_ = dummy_binary_sensor;
|
||||
#endif
|
||||
#ifdef USE_SENSOR
|
||||
sensor::Sensor *lamp_hours_ = dummy_sensor;
|
||||
sensor::Sensor *power_status_ = dummy_sensor;
|
||||
sensor::Sensor *signal_status_ = dummy_sensor;
|
||||
sensor::Sensor *luminance_level_ = dummy_sensor;
|
||||
#endif
|
||||
#ifdef USE_TEXT_SENSOR
|
||||
text_sensor::TextSensor *serial_ = dummy_text_sensor;
|
||||
text_sensor::TextSensor *serial_{nullptr};
|
||||
#endif
|
||||
#ifdef USE_SWITCH
|
||||
tw7100::tw7100Switch *power_switch_ = dummy_switch;
|
||||
tw7100::tw7100Switch *btaudio_switch_ = dummy_switch;
|
||||
tw7100::tw7100Switch *mute_switch_ = dummy_switch;
|
||||
tw7100::tw7100Switch *wlan_power_switch_ = dummy_switch;
|
||||
tw7100::tw7100Switch *autohome_switch_ = dummy_switch;
|
||||
tw7100::tw7100Switch *product_switch_ = dummy_switch;
|
||||
tw7100::tw7100Switch *standbyconf_switch_ = dummy_switch;
|
||||
tw7100::tw7100Switch *illumination_switch_ = dummy_switch;
|
||||
tw7100::tw7100Switch *vflip_switch_ = dummy_switch;
|
||||
tw7100::tw7100Switch *hflip_switch_ = dummy_switch;
|
||||
tw7100::tw7100Switch *audioout_switch_ = dummy_switch;
|
||||
tw7100::tw7100Switch *img_processing_switch_ = dummy_switch;
|
||||
tw7100::tw7100Switch *_4kenhance_switch_ = dummy_switch;
|
||||
tw7100::tw7100Switch *logto_switch_ = dummy_switch;
|
||||
switch_::Switch *power_switch_{nullptr};
|
||||
switch_::Switch *btaudio_switch_{nullptr};
|
||||
switch_::Switch *mute_switch_{nullptr};
|
||||
switch_::Switch *wlan_power_switch_{nullptr};
|
||||
switch_::Switch *autohome_switch_{nullptr};
|
||||
switch_::Switch *product_switch_{nullptr};
|
||||
switch_::Switch *standbyconf_switch_{nullptr};
|
||||
switch_::Switch *illumination_switch_{nullptr};
|
||||
switch_::Switch *vflip_switch_{nullptr};
|
||||
switch_::Switch *hflip_switch_{nullptr};
|
||||
switch_::Switch *audioout_switch_{nullptr};
|
||||
switch_::Switch *img_processing_switch_{nullptr};
|
||||
switch_::Switch *_4kenhance_switch_{nullptr};
|
||||
switch_::Switch *logto_switch_{nullptr};
|
||||
#endif
|
||||
#ifdef USE_SELECT
|
||||
tw7100::tw7100Select *source_select_ = dummy_select;;
|
||||
tw7100::tw7100Select *luminance_select_ = dummy_select;
|
||||
tw7100::tw7100Select *aspect_select_ = dummy_select;
|
||||
tw7100::tw7100Select *ovscan_select_ = dummy_select;
|
||||
tw7100::tw7100Select *cmode_select_ = dummy_select;
|
||||
tw7100::tw7100Select *gamma_select_ = dummy_select;
|
||||
tw7100::tw7100Select *imgpreset_select_ = dummy_select;
|
||||
tw7100::tw7100Select *mcfi_select_ = dummy_select;
|
||||
tw7100::tw7100Select *clrspace_select_ = dummy_select;
|
||||
tw7100::tw7100Select *dynrange_select_ = dummy_select;
|
||||
tw7100::tw7100Select *msel_select_ = dummy_select;
|
||||
tw7100::tw7100Select *speed_select_ = dummy_select;
|
||||
tw7100::tw7100Select *source_select_{nullptr};
|
||||
tw7100::tw7100Select *luminance_select_{nullptr};
|
||||
tw7100::tw7100Select *aspect_select_{nullptr};
|
||||
tw7100::tw7100Select *ovscan_select_{nullptr};
|
||||
tw7100::tw7100Select *cmode_select_{nullptr};
|
||||
tw7100::tw7100Select *gamma_select_{nullptr};
|
||||
tw7100::tw7100Select *imgpreset_select_{nullptr};
|
||||
tw7100::tw7100Select *mcfi_select_{nullptr};
|
||||
tw7100::tw7100Select *clrspace_select_{nullptr};
|
||||
tw7100::tw7100Select *dynrange_select_{nullptr};
|
||||
tw7100::tw7100Select *msel_select_{nullptr};
|
||||
tw7100::tw7100Select *speed_select_{nullptr};
|
||||
#endif
|
||||
#ifdef USE_NUMBER
|
||||
tw7100::tw7100Number *volume_number_ = dummy_number;
|
||||
tw7100::tw7100Number *vkeystone_number_ = dummy_number;
|
||||
tw7100::tw7100Number *hkeystone_number_ = dummy_number;
|
||||
tw7100::tw7100Number *brightness_number_ = dummy_number;
|
||||
tw7100::tw7100Number *contrast_number_ = dummy_number;
|
||||
tw7100::tw7100Number *density_number_ = dummy_number;
|
||||
tw7100::tw7100Number *tint_number_ = dummy_number;
|
||||
tw7100::tw7100Number *ctemp_number_ = dummy_number;
|
||||
tw7100::tw7100Number *fcolor_number_ = dummy_number;
|
||||
tw7100::tw7100Number *nrs_number_ = dummy_number;
|
||||
tw7100::tw7100Number *mpegnrs_number_ = dummy_number;
|
||||
tw7100::tw7100Number *offsetr_number_ = dummy_number;
|
||||
tw7100::tw7100Number *offsetg_number_ = dummy_number;
|
||||
tw7100::tw7100Number *offsetb_number_ = dummy_number;
|
||||
tw7100::tw7100Number *gainr_number_ = dummy_number;
|
||||
tw7100::tw7100Number *gaing_number_ = dummy_number;
|
||||
tw7100::tw7100Number *gainb_number_ = dummy_number;
|
||||
tw7100::tw7100Number *shrf_number_ = dummy_number;
|
||||
tw7100::tw7100Number *shrs_number_ = dummy_number;
|
||||
tw7100::tw7100Number *derange_number_ = dummy_number;
|
||||
tw7100::tw7100Number *destrength_number_ = dummy_number;
|
||||
tw7100::tw7100Number *volume_number_{nullptr};
|
||||
tw7100::tw7100Number *vkeystone_number_{nullptr};
|
||||
tw7100::tw7100Number *hkeystone_number_{nullptr};
|
||||
tw7100::tw7100Number *brightness_number_{nullptr};
|
||||
tw7100::tw7100Number *contrast_number_{nullptr};
|
||||
tw7100::tw7100Number *density_number_{nullptr};
|
||||
tw7100::tw7100Number *tint_number_{nullptr};
|
||||
tw7100::tw7100Number *ctemp_number_{nullptr};
|
||||
tw7100::tw7100Number *fcolor_number_{nullptr};
|
||||
tw7100::tw7100Number *nrs_number_{nullptr};
|
||||
tw7100::tw7100Number *mpegnrs_number_{nullptr};
|
||||
tw7100::tw7100Number *offsetr_number_{nullptr};
|
||||
tw7100::tw7100Number *offsetg_number_{nullptr};
|
||||
tw7100::tw7100Number *offsetb_number_{nullptr};
|
||||
tw7100::tw7100Number *gainr_number_{nullptr};
|
||||
tw7100::tw7100Number *gaing_number_{nullptr};
|
||||
tw7100::tw7100Number *gainb_number_{nullptr};
|
||||
tw7100::tw7100Number *shrf_number_{nullptr};
|
||||
tw7100::tw7100Number *shrs_number_{nullptr};
|
||||
tw7100::tw7100Number *derange_number_{nullptr};
|
||||
tw7100::tw7100Number *destrength_number_{nullptr};
|
||||
#endif
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue