Introduce dummy class to avoid nullpointer handling

This commit is contained in:
sqozz 2024-09-20 20:45:18 +02:00
parent ad1cc45768
commit a35bb27d50
2 changed files with 157 additions and 210 deletions

View file

@ -1,4 +1,5 @@
#include "tw7100.h" #include "tw7100.h"
#include <deque>
#include "esphome/core/log.h" #include "esphome/core/log.h"
#include "esphome/core/defines.h" #include "esphome/core/defines.h"
#include "esphome/core/helpers.h" #include "esphome/core/helpers.h"
@ -220,70 +221,57 @@ void tw7100Component::update_sensor(std::pair<std::string, std::string> data) {
int value = std::stoi(value_string); int value = std::stoi(value_string);
powered = (value > 0); powered = (value > 0);
#ifdef USE_BINARY_SENSOR #ifdef USE_BINARY_SENSOR
//if (powered_) powered_->publish_state(value > 0); powered_->publish_state(value > 0);
#endif #endif
#ifdef USE_SWITCH #ifdef USE_SWITCH
if (power_switch_) power_switch_->publish_state(value > 0); // ack previous cmd or update switch power_switch_->publish_state(value > 0); // ack previous cmd or update switch
#endif #endif
#ifdef USE_SENSOR #ifdef USE_SENSOR
if (power_status_) power_status_->publish_state(value); power_status_->publish_state(value);
#endif
} else if (cmd == "LAMP") { } else if (cmd == "LAMP") {
ESP_LOGV(TAG, "updating lamp sensors"); ESP_LOGV(TAG, "updating lamp sensors");
#ifdef USE_SENSOR
int value = std::stoi(value_string); int value = std::stoi(value_string);
if (lamp_hours_) lamp_hours_->publish_state(value); lamp_hours_->publish_state(value);
#endif
} else if (cmd == "SIGNAL") { } else if (cmd == "SIGNAL") {
ESP_LOGV(TAG, "updating signal sensors"); ESP_LOGV(TAG, "updating signal sensors");
#ifdef USE_BINARY_SENSOR
int value = std::stoi(value_string); int value = std::stoi(value_string);
if (has_signal_) has_signal_->publish_state(value > 0);
#endif #endif
if (signal_status_) signal_status_->publish_state(value); #ifdef USE_BINARY_SENSOR
has_signal_->publish_state(value > 0);
#endif
#ifdef USE_SENSOR
signal_status_->publish_state(value);
#endif
#ifdef USE_SELECT
} else if (cmd == "LUMINANCE") { } else if (cmd == "LUMINANCE") {
ESP_LOGV(TAG, "updating luminance sensors"); ESP_LOGV(TAG, "updating luminance sensors");
#ifdef USE_SENSOR
int value = std::stoi(value_string); int value = std::stoi(value_string);
if (luminance_level_) luminance_level_->publish_state(value); luminance_level_->publish_state(value);
#endif if(tw7100Select::luminance.find(value_string) != tw7100Select::luminance.end()) {
#ifdef USE_SELECT auto call = luminance_select_->make_call();
if (luminance_select_) { call.set_option(tw7100Select::luminance[value_string]);
if(tw7100Select::luminance.find(value_string) != tw7100Select::luminance.end()) { call.perform();
auto call = luminance_select_->make_call(); } else {
call.set_option(tw7100Select::luminance[value_string]); ESP_LOGE(TAG, "Result %s not present in options", value_string);
call.perform();
} else {
ESP_LOGE(TAG, "Result %s not present in options", value_string);
}
} }
#endif
} else if (cmd == "SOURCE") { } else if (cmd == "SOURCE") {
ESP_LOGV(TAG, "updating source select"); ESP_LOGV(TAG, "updating source select");
#ifdef USE_SELECT if(tw7100Select::sources.find(value_string) != tw7100Select::sources.end()) {
if (source_select_) { auto call = source_select_->make_call();
if(tw7100Select::sources.find(value_string) != tw7100Select::sources.end()) { call.set_option(tw7100Select::sources[value_string]);
auto call = source_select_->make_call(); call.perform();
call.set_option(tw7100Select::sources[value_string]); } else {
call.perform(); ESP_LOGE(TAG, "Result %s not present in options", value_string);
} else {
ESP_LOGE(TAG, "Result %s not present in options", value_string);
}
} }
#endif
} else if (cmd == "ASPECT") { } else if (cmd == "ASPECT") {
ESP_LOGV(TAG, "updating aspect select"); ESP_LOGV(TAG, "updating aspect select");
#ifdef USE_SELECT if(tw7100Select::aspect.find(value_string) != tw7100Select::aspect.end()) {
if (aspect_select_) { auto call = aspect_select_->make_call();
if(tw7100Select::aspect.find(value_string) != tw7100Select::aspect.end()) { call.set_option(tw7100Select::aspect[value_string]);
auto call = aspect_select_->make_call(); call.perform();
call.set_option(tw7100Select::aspect[value_string]); } else {
call.perform(); ESP_LOGE(TAG, "Result %s not present in options", value_string);
} else {
ESP_LOGE(TAG, "Result %s not present in options", value_string);
}
} }
#endif
} else if (cmd == "OVSCAN") { } else if (cmd == "OVSCAN") {
ESP_LOGV(TAG, "updating ovscan select"); ESP_LOGV(TAG, "updating ovscan select");
} else if (cmd == "CMODE") { } else if (cmd == "CMODE") {
@ -302,204 +290,141 @@ void tw7100Component::update_sensor(std::pair<std::string, std::string> data) {
ESP_LOGV(TAG, "updating msel select"); ESP_LOGV(TAG, "updating msel select");
} else if (cmd == "SPEED") { } else if (cmd == "SPEED") {
ESP_LOGV(TAG, "updating speed select"); ESP_LOGV(TAG, "updating speed select");
#ifdef USE_TEXT_SENSOR
} else if (cmd == "SNO") { } else if (cmd == "SNO") {
if (serial_ != nullptr) serial_->publish_state(value_string); serial_->publish_state(value_string);
#endif #endif
#ifdef USE_SWITCH
} else if (cmd == "BTAUDIO") { } else if (cmd == "BTAUDIO") {
ESP_LOGV(TAG, "updating btaudio switch"); ESP_LOGV(TAG, "updating btaudio switch");
#ifdef USE_SWITCH
int value = std::stoi(value_string); int value = std::stoi(value_string);
if (btaudio_switch_) btaudio_switch_->publish_state(value > 0); btaudio_switch_->publish_state(value > 0);
#endif
} else if (cmd == "4KENHANCE") { } else if (cmd == "4KENHANCE") {
ESP_LOGV(TAG, "updating 4kenhance switch"); ESP_LOGV(TAG, "updating 4kenhance switch");
#ifdef USE_SWITCH
int value = std::stoi(value_string); int value = std::stoi(value_string);
if (_4kenhance_switch_) _4kenhance_switch_->publish_state(value > 0); _4kenhance_switch_->publish_state(value > 0);
#endif
} else if (cmd == "IMGPROC") { } else if (cmd == "IMGPROC") {
ESP_LOGV(TAG, "updating imgproc switch"); ESP_LOGV(TAG, "updating imgproc switch");
#ifdef USE_SWITCH
int value = std::stoi(value_string); int value = std::stoi(value_string);
if (img_processing_switch_) img_processing_switch_->publish_state(value > 1); img_processing_switch_->publish_state(value > 1);
#endif
} else if (cmd == "AUDIOOUT") { } else if (cmd == "AUDIOOUT") {
ESP_LOGV(TAG, "updating audioout switch"); ESP_LOGV(TAG, "updating audioout switch");
#ifdef USE_SWITCH
int value = std::stoi(value_string); int value = std::stoi(value_string);
if (audioout_switch_) audioout_switch_->publish_state(value == 11); audioout_switch_->publish_state(value == 11);
#endif
} else if (cmd == "HREVERSE") { } else if (cmd == "HREVERSE") {
ESP_LOGV(TAG, "updating hflip switch"); ESP_LOGV(TAG, "updating hflip switch");
#ifdef USE_SWITCH hflip_switch_->publish_state(value_string == "ON");
if (hflip_switch_) hflip_switch_->publish_state(value_string == "ON");
#endif
} else if (cmd == "VREVERSE") { } else if (cmd == "VREVERSE") {
ESP_LOGV(TAG, "updating vflip switch"); ESP_LOGV(TAG, "updating vflip switch");
#ifdef USE_SWITCH vflip_switch_->publish_state(value_string == "ON");
if (vflip_switch_) vflip_switch_->publish_state(value_string == "ON");
#endif
} else if (cmd == "ILLUM") { } else if (cmd == "ILLUM") {
ESP_LOGV(TAG, "updating illumination switch"); ESP_LOGV(TAG, "updating illumination switch");
#ifdef USE_SWITCH
int value = std::stoi(value_string); int value = std::stoi(value_string);
if (illumination_switch_) illumination_switch_->publish_state(value == 1); illumination_switch_->publish_state(value == 1);
#endif
} else if (cmd == "STANDBYCONF") { } else if (cmd == "STANDBYCONF") {
ESP_LOGV(TAG, "updating standbyconf switch"); ESP_LOGV(TAG, "updating standbyconf switch");
#ifdef USE_SWITCH
int value = std::stoi(value_string); int value = std::stoi(value_string);
if (standbyconf_switch_) standbyconf_switch_->publish_state(value == 1); standbyconf_switch_->publish_state(value == 1);
#endif
} else if (cmd == "AUTOHOME") { } else if (cmd == "AUTOHOME") {
ESP_LOGV(TAG, "updating autohome switch"); ESP_LOGV(TAG, "updating autohome switch");
#ifdef USE_SWITCH
int value = std::stoi(value_string); int value = std::stoi(value_string);
if (autohome_switch_) autohome_switch_->publish_state(value == 1); autohome_switch_->publish_state(value == 1);
#endif
} else if (cmd == "WLPWR") { } else if (cmd == "WLPWR") {
ESP_LOGV(TAG, "updating wlan power switch"); ESP_LOGV(TAG, "updating wlan power switch");
#ifdef USE_SWITCH
int value = std::stoi(value_string); int value = std::stoi(value_string);
if (wlan_power_switch_) wlan_power_switch_->publish_state(value == 1); wlan_power_switch_->publish_state(value == 1);
#endif
} else if (cmd == "LOGTO") { } else if (cmd == "LOGTO") {
ESP_LOGV(TAG, "updating logto switch"); ESP_LOGV(TAG, "updating logto switch");
#ifdef USE_SWITCH
int value = std::stoi(value_string); int value = std::stoi(value_string);
if (logto_switch_) logto_switch_->publish_state(value == 1); logto_switch_->publish_state(value == 1);
#endif
} else if (cmd == "MUTE") { } else if (cmd == "MUTE") {
ESP_LOGV(TAG, "updating mute switch with value %s", value_string.c_str()); ESP_LOGV(TAG, "updating mute switch with value %s", value_string.c_str());
#ifdef USE_SWITCH mute_switch_->publish_state(value_string == "ON");
if (mute_switch_) mute_switch_->publish_state(value_string == "ON");
#endif #endif
#ifdef USE_NUMBER
} else if (cmd == "VOL") { } else if (cmd == "VOL") {
ESP_LOGV(TAG, "updating volume number with value %s", value_string.c_str()); ESP_LOGV(TAG, "updating volume number with value %s", value_string.c_str());
#ifdef USE_NUMBER
int value = std::stoi(value_string); int value = std::stoi(value_string);
if (volume_number_) volume_number_->publish_state(value); volume_number_->publish_state(value);
#endif
} else if (cmd == "VKEYSTONE") { } else if (cmd == "VKEYSTONE") {
ESP_LOGV(TAG, "updating vkeystone number with value %s", value_string.c_str()); ESP_LOGV(TAG, "updating vkeystone number with value %s", value_string.c_str());
#ifdef USE_NUMBER
int value = std::stoi(value_string); int value = std::stoi(value_string);
if (vkeystone_number_) vkeystone_number_->publish_state(value); vkeystone_number_->publish_state(value);
#endif
} else if (cmd == "HKEYSTONE") { } else if (cmd == "HKEYSTONE") {
ESP_LOGV(TAG, "updating hkeystone number with value %s", value_string.c_str()); ESP_LOGV(TAG, "updating hkeystone number with value %s", value_string.c_str());
#ifdef USE_NUMBER
int value = std::stoi(value_string); int value = std::stoi(value_string);
if (hkeystone_number_) hkeystone_number_->publish_state(value); hkeystone_number_->publish_state(value);
#endif
} else if (cmd == "BRIGHT") { } else if (cmd == "BRIGHT") {
ESP_LOGV(TAG, "updating brightness number with value %s", value_string.c_str()); ESP_LOGV(TAG, "updating brightness number with value %s", value_string.c_str());
#ifdef USE_NUMBER
int value = std::stoi(value_string); int value = std::stoi(value_string);
if (brightness_number_) brightness_number_->publish_state(value); brightness_number_->publish_state(value);
#endif
} else if (cmd == "CONTRAST") { } else if (cmd == "CONTRAST") {
ESP_LOGV(TAG, "updating contrast number with value %s", value_string.c_str()); ESP_LOGV(TAG, "updating contrast number with value %s", value_string.c_str());
#ifdef USE_NUMBER
int value = std::stoi(value_string); int value = std::stoi(value_string);
if (contrast_number_) contrast_number_->publish_state(value); contrast_number_->publish_state(value);
#endif
} else if (cmd == "DENSITY") { } else if (cmd == "DENSITY") {
ESP_LOGV(TAG, "updating density number with value %s", value_string.c_str()); ESP_LOGV(TAG, "updating density number with value %s", value_string.c_str());
#ifdef USE_NUMBER
int value = std::stoi(value_string); int value = std::stoi(value_string);
if (density_number_) density_number_->publish_state(value); density_number_->publish_state(value);
#endif
} else if (cmd == "TINT") { } else if (cmd == "TINT") {
ESP_LOGV(TAG, "updating tint number with value %s", value_string.c_str()); ESP_LOGV(TAG, "updating tint number with value %s", value_string.c_str());
#ifdef USE_NUMBER
int value = std::stoi(value_string); int value = std::stoi(value_string);
if (tint_number_) tint_number_->publish_state(value); tint_number_->publish_state(value);
#endif
} else if (cmd == "CTEMP") { } else if (cmd == "CTEMP") {
ESP_LOGV(TAG, "updating ctemp number with value %s", value_string.c_str()); ESP_LOGV(TAG, "updating ctemp number with value %s", value_string.c_str());
#ifdef USE_NUMBER
int value = std::stoi(value_string); int value = std::stoi(value_string);
if (ctemp_number_) ctemp_number_->publish_state(value); ctemp_number_->publish_state(value);
#endif
} else if (cmd == "FCOLOR") { } else if (cmd == "FCOLOR") {
ESP_LOGV(TAG, "updating fcolor number with value %s", value_string.c_str()); ESP_LOGV(TAG, "updating fcolor number with value %s", value_string.c_str());
#ifdef USE_NUMBER
int value = std::stoi(value_string); int value = std::stoi(value_string);
if (fcolor_number_) fcolor_number_->publish_state(value); fcolor_number_->publish_state(value);
#endif
} else if (cmd == "NRS") { } else if (cmd == "NRS") {
ESP_LOGV(TAG, "updating nrs number with value %s", value_string.c_str()); ESP_LOGV(TAG, "updating nrs number with value %s", value_string.c_str());
#ifdef USE_NUMBER
int value = std::stoi(value_string); int value = std::stoi(value_string);
if (nrs_number_) nrs_number_->publish_state(value); nrs_number_->publish_state(value);
#endif
} else if (cmd == "MPEGNRS") { } else if (cmd == "MPEGNRS") {
ESP_LOGV(TAG, "updating mpegngs number with value %s", value_string.c_str()); ESP_LOGV(TAG, "updating mpegngs number with value %s", value_string.c_str());
#ifdef USE_NUMBER
int value = std::stoi(value_string); int value = std::stoi(value_string);
if (mpegnrs_number_) mpegnrs_number_->publish_state(value); mpegnrs_number_->publish_state(value);
#endif
} else if (cmd == "OFFSETR") { } else if (cmd == "OFFSETR") {
ESP_LOGV(TAG, "updating offsetr number with value %s", value_string.c_str()); ESP_LOGV(TAG, "updating offsetr number with value %s", value_string.c_str());
#ifdef USE_NUMBER
int value = std::stoi(value_string); int value = std::stoi(value_string);
if (offsetr_number_) offsetr_number_->publish_state(value); offsetr_number_->publish_state(value);
#endif
} else if (cmd == "OFFSETG") { } else if (cmd == "OFFSETG") {
ESP_LOGV(TAG, "updating offsetg number with value %s", value_string.c_str()); ESP_LOGV(TAG, "updating offsetg number with value %s", value_string.c_str());
#ifdef USE_NUMBER
int value = std::stoi(value_string); int value = std::stoi(value_string);
if (offsetg_number_) offsetg_number_->publish_state(value); offsetg_number_->publish_state(value);
#endif
} else if (cmd == "OFFSETB") { } else if (cmd == "OFFSETB") {
ESP_LOGV(TAG, "updating offsetb number with value %s", value_string.c_str()); ESP_LOGV(TAG, "updating offsetb number with value %s", value_string.c_str());
#ifdef USE_NUMBER
int value = std::stoi(value_string); int value = std::stoi(value_string);
if (offsetb_number_) offsetb_number_->publish_state(value); offsetb_number_->publish_state(value);
#endif
} else if (cmd == "GAINR") { } else if (cmd == "GAINR") {
ESP_LOGV(TAG, "updating gainr number with value %s", value_string.c_str()); ESP_LOGV(TAG, "updating gainr number with value %s", value_string.c_str());
#ifdef USE_NUMBER
int value = std::stoi(value_string); int value = std::stoi(value_string);
if (gainr_number_) gainr_number_->publish_state(value); gainr_number_->publish_state(value);
#endif
} else if (cmd == "GAING") { } else if (cmd == "GAING") {
ESP_LOGV(TAG, "updating gaing number with value %s", value_string.c_str()); ESP_LOGV(TAG, "updating gaing number with value %s", value_string.c_str());
#ifdef USE_NUMBER
int value = std::stoi(value_string); int value = std::stoi(value_string);
if (gaing_number_) gaing_number_->publish_state(value); gaing_number_->publish_state(value);
#endif
} else if (cmd == "GAINB") { } else if (cmd == "GAINB") {
ESP_LOGV(TAG, "updating gainb number with value %s", value_string.c_str()); ESP_LOGV(TAG, "updating gainb number with value %s", value_string.c_str());
#ifdef USE_NUMBER
int value = std::stoi(value_string); int value = std::stoi(value_string);
if (gainb_number_) gainb_number_->publish_state(value); gainb_number_->publish_state(value);
#endif
} else if (cmd == "SHRF") { } else if (cmd == "SHRF") {
ESP_LOGV(TAG, "updating shrf number with value %s", value_string.c_str()); ESP_LOGV(TAG, "updating shrf number with value %s", value_string.c_str());
#ifdef USE_NUMBER
int value = std::stoi(value_string); int value = std::stoi(value_string);
if (shrf_number_) shrf_number_->publish_state(value); shrf_number_->publish_state(value);
#endif
} else if (cmd == "SHRS") { } else if (cmd == "SHRS") {
ESP_LOGV(TAG, "updating shrs number with value %s", value_string.c_str()); ESP_LOGV(TAG, "updating shrs number with value %s", value_string.c_str());
#ifdef USE_NUMBER
int value = std::stoi(value_string); int value = std::stoi(value_string);
if (shrs_number_) shrs_number_->publish_state(value); shrs_number_->publish_state(value);
#endif
} else if (cmd == "DERANGE") { } else if (cmd == "DERANGE") {
ESP_LOGV(TAG, "updating derange number with value %s", value_string.c_str()); ESP_LOGV(TAG, "updating derange number with value %s", value_string.c_str());
#ifdef USE_NUMBER
int value = std::stoi(value_string); int value = std::stoi(value_string);
if (derange_number_) derange_number_->publish_state(value); derange_number_->publish_state(value);
#endif
} else if (cmd == "DESTRENGTH") { } else if (cmd == "DESTRENGTH") {
ESP_LOGV(TAG, "updating destrength number with value %s", value_string.c_str()); ESP_LOGV(TAG, "updating destrength number with value %s", value_string.c_str());
#ifdef USE_NUMBER
int value = std::stoi(value_string); int value = std::stoi(value_string);
if (destrength_number_) destrength_number_->publish_state(value); destrength_number_->publish_state(value);
#endif #endif
} else { } else {
ESP_LOGW(TAG, "Command %s unknown, skipping updating sensor with value", cmd.c_str()); ESP_LOGW(TAG, "Command %s unknown, skipping updating sensor with value", cmd.c_str());

158
tw7100.h
View file

@ -1,8 +1,10 @@
#pragma once #pragma once
#include "esphome/core/component.h" #include "esphome/core/component.h"
#include "esphome/core/entity_base.h"
#include "esphome/core/log.h" #include "esphome/core/log.h"
#include "esphome/components/uart/uart.h" #include "esphome/components/uart/uart.h"
#include <map>
#ifdef USE_SENSOR #ifdef USE_SENSOR
#include "esphome/components/sensor/sensor.h" #include "esphome/components/sensor/sensor.h"
@ -18,6 +20,7 @@
#ifdef USE_SWITCH #ifdef USE_SWITCH
#include "esphome/components/switch/switch.h" #include "esphome/components/switch/switch.h"
#include "switch/tw7100_switch.h"
#endif #endif
#ifdef USE_SELECT #ifdef USE_SELECT
@ -66,20 +69,20 @@ class tw7100Component : public PollingComponent, public uart::UARTDevice {
void set_serial(text_sensor::TextSensor *serial) { this->serial_ = serial; } void set_serial(text_sensor::TextSensor *serial) { this->serial_ = serial; }
#endif #endif
#ifdef USE_SWITCH #ifdef USE_SWITCH
void set_set_pwr(switch_::Switch *switch_) { this->power_switch_ = switch_; } void set_set_pwr(tw7100::tw7100Switch *switch_) { this->power_switch_ = switch_; }
void set_set_btaudio(switch_::Switch *switch_) { this->btaudio_switch_ = switch_; } void set_set_btaudio(tw7100::tw7100Switch *switch_) { this->btaudio_switch_ = switch_; }
void set_set_mute(switch_::Switch *switch_) { this->mute_switch_ = switch_; } void set_set_mute(tw7100::tw7100Switch *switch_) { this->mute_switch_ = switch_; }
void set_set_wlpwr(switch_::Switch *switch_) { this->wlan_power_switch_ = switch_; } void set_set_wlpwr(tw7100::tw7100Switch *switch_) { this->wlan_power_switch_ = switch_; }
void set_set_autohome(switch_::Switch *switch_) { this->autohome_switch_ = switch_; } void set_set_autohome(tw7100::tw7100Switch *switch_) { this->autohome_switch_ = switch_; }
void set_set_product(switch_::Switch *switch_) { this->product_switch_ = switch_; } void set_set_product(tw7100::tw7100Switch *switch_) { this->product_switch_ = switch_; }
void set_set_standbyconf(switch_::Switch *switch_) { this->standbyconf_switch_ = switch_; } void set_set_standbyconf(tw7100::tw7100Switch *switch_) { this->standbyconf_switch_ = switch_; }
void set_set_illum(switch_::Switch *switch_) { this->illumination_switch_ = switch_; } void set_set_illum(tw7100::tw7100Switch *switch_) { this->illumination_switch_ = switch_; }
void set_set_vreverse(switch_::Switch *switch_) { this->vflip_switch_ = switch_; } void set_set_vreverse(tw7100::tw7100Switch *switch_) { this->vflip_switch_ = switch_; }
void set_set_hreverse(switch_::Switch *switch_) { this->hflip_switch_ = switch_; } void set_set_hreverse(tw7100::tw7100Switch *switch_) { this->hflip_switch_ = switch_; }
void set_set_audioout(switch_::Switch *switch_) { this->audioout_switch_ = switch_; } void set_set_audioout(tw7100::tw7100Switch *switch_) { this->audioout_switch_ = switch_; }
void set_set_imgproc(switch_::Switch *switch_) { this->img_processing_switch_ = switch_; } void set_set_imgproc(tw7100::tw7100Switch *switch_) { this->img_processing_switch_ = switch_; }
void set_set_4kenhance(switch_::Switch *switch_) { this->_4kenhance_switch_ = switch_; } void set_set_4kenhance(tw7100::tw7100Switch *switch_) { this->_4kenhance_switch_ = switch_; }
void set_set_logto(switch_::Switch *switch_) { this->logto_switch_ = switch_; } void set_set_logto(tw7100::tw7100Switch *switch_) { this->logto_switch_ = switch_; }
#endif #endif
#ifdef USE_SELECT #ifdef USE_SELECT
void set_set_source(tw7100::tw7100Select *select_) { this->source_select_ = select_; } void set_set_source(tw7100::tw7100Select *select_) { this->source_select_ = select_; }
@ -119,73 +122,92 @@ class tw7100Component : public PollingComponent, public uart::UARTDevice {
void set_set_destrength(tw7100::tw7100Number *number_) { this->destrength_number_ = number_; } void set_set_destrength(tw7100::tw7100Number *number_) { this->destrength_number_ = number_; }
#endif #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: protected:
#ifdef USE_BINARY_SENSOR #ifdef USE_BINARY_SENSOR
binary_sensor::BinarySensor *powered_{nullptr}; binary_sensor::BinarySensor *powered_ = dummy_binary_sensor;
binary_sensor::BinarySensor *has_signal_{nullptr}; binary_sensor::BinarySensor *has_signal_ = dummy_binary_sensor;
#endif #endif
#ifdef USE_SENSOR #ifdef USE_SENSOR
sensor::Sensor *lamp_hours_{nullptr}; sensor::Sensor *lamp_hours_ = dummy_sensor;
sensor::Sensor *power_status_{nullptr}; sensor::Sensor *power_status_ = dummy_sensor;
sensor::Sensor *signal_status_{nullptr}; sensor::Sensor *signal_status_ = dummy_sensor;
sensor::Sensor *luminance_level_{nullptr}; sensor::Sensor *luminance_level_ = dummy_sensor;
#endif #endif
#ifdef USE_TEXT_SENSOR #ifdef USE_TEXT_SENSOR
text_sensor::TextSensor *serial_{nullptr}; text_sensor::TextSensor *serial_ = dummy_text_sensor;
#endif #endif
#ifdef USE_SWITCH #ifdef USE_SWITCH
switch_::Switch *power_switch_{nullptr}; tw7100::tw7100Switch *power_switch_ = dummy_switch;
switch_::Switch *btaudio_switch_{nullptr}; tw7100::tw7100Switch *btaudio_switch_ = dummy_switch;
switch_::Switch *mute_switch_{nullptr}; tw7100::tw7100Switch *mute_switch_ = dummy_switch;
switch_::Switch *wlan_power_switch_{nullptr}; tw7100::tw7100Switch *wlan_power_switch_ = dummy_switch;
switch_::Switch *autohome_switch_{nullptr}; tw7100::tw7100Switch *autohome_switch_ = dummy_switch;
switch_::Switch *product_switch_{nullptr}; tw7100::tw7100Switch *product_switch_ = dummy_switch;
switch_::Switch *standbyconf_switch_{nullptr}; tw7100::tw7100Switch *standbyconf_switch_ = dummy_switch;
switch_::Switch *illumination_switch_{nullptr}; tw7100::tw7100Switch *illumination_switch_ = dummy_switch;
switch_::Switch *vflip_switch_{nullptr}; tw7100::tw7100Switch *vflip_switch_ = dummy_switch;
switch_::Switch *hflip_switch_{nullptr}; tw7100::tw7100Switch *hflip_switch_ = dummy_switch;
switch_::Switch *audioout_switch_{nullptr}; tw7100::tw7100Switch *audioout_switch_ = dummy_switch;
switch_::Switch *img_processing_switch_{nullptr}; tw7100::tw7100Switch *img_processing_switch_ = dummy_switch;
switch_::Switch *_4kenhance_switch_{nullptr}; tw7100::tw7100Switch *_4kenhance_switch_ = dummy_switch;
switch_::Switch *logto_switch_{nullptr}; tw7100::tw7100Switch *logto_switch_ = dummy_switch;
#endif #endif
#ifdef USE_SELECT #ifdef USE_SELECT
tw7100::tw7100Select *source_select_{nullptr}; tw7100::tw7100Select *source_select_ = dummy_select;;
tw7100::tw7100Select *luminance_select_{nullptr}; tw7100::tw7100Select *luminance_select_ = dummy_select;
tw7100::tw7100Select *aspect_select_{nullptr}; tw7100::tw7100Select *aspect_select_ = dummy_select;
tw7100::tw7100Select *ovscan_select_{nullptr}; tw7100::tw7100Select *ovscan_select_ = dummy_select;
tw7100::tw7100Select *cmode_select_{nullptr}; tw7100::tw7100Select *cmode_select_ = dummy_select;
tw7100::tw7100Select *gamma_select_{nullptr}; tw7100::tw7100Select *gamma_select_ = dummy_select;
tw7100::tw7100Select *imgpreset_select_{nullptr}; tw7100::tw7100Select *imgpreset_select_ = dummy_select;
tw7100::tw7100Select *mcfi_select_{nullptr}; tw7100::tw7100Select *mcfi_select_ = dummy_select;
tw7100::tw7100Select *clrspace_select_{nullptr}; tw7100::tw7100Select *clrspace_select_ = dummy_select;
tw7100::tw7100Select *dynrange_select_{nullptr}; tw7100::tw7100Select *dynrange_select_ = dummy_select;
tw7100::tw7100Select *msel_select_{nullptr}; tw7100::tw7100Select *msel_select_ = dummy_select;
tw7100::tw7100Select *speed_select_{nullptr}; tw7100::tw7100Select *speed_select_ = dummy_select;
#endif #endif
#ifdef USE_NUMBER #ifdef USE_NUMBER
tw7100::tw7100Number *volume_number_{nullptr}; tw7100::tw7100Number *volume_number_ = dummy_number;
tw7100::tw7100Number *vkeystone_number_{nullptr}; tw7100::tw7100Number *vkeystone_number_ = dummy_number;
tw7100::tw7100Number *hkeystone_number_{nullptr}; tw7100::tw7100Number *hkeystone_number_ = dummy_number;
tw7100::tw7100Number *brightness_number_{nullptr}; tw7100::tw7100Number *brightness_number_ = dummy_number;
tw7100::tw7100Number *contrast_number_{nullptr}; tw7100::tw7100Number *contrast_number_ = dummy_number;
tw7100::tw7100Number *density_number_{nullptr}; tw7100::tw7100Number *density_number_ = dummy_number;
tw7100::tw7100Number *tint_number_{nullptr}; tw7100::tw7100Number *tint_number_ = dummy_number;
tw7100::tw7100Number *ctemp_number_{nullptr}; tw7100::tw7100Number *ctemp_number_ = dummy_number;
tw7100::tw7100Number *fcolor_number_{nullptr}; tw7100::tw7100Number *fcolor_number_ = dummy_number;
tw7100::tw7100Number *nrs_number_{nullptr}; tw7100::tw7100Number *nrs_number_ = dummy_number;
tw7100::tw7100Number *mpegnrs_number_{nullptr}; tw7100::tw7100Number *mpegnrs_number_ = dummy_number;
tw7100::tw7100Number *offsetr_number_{nullptr}; tw7100::tw7100Number *offsetr_number_ = dummy_number;
tw7100::tw7100Number *offsetg_number_{nullptr}; tw7100::tw7100Number *offsetg_number_ = dummy_number;
tw7100::tw7100Number *offsetb_number_{nullptr}; tw7100::tw7100Number *offsetb_number_ = dummy_number;
tw7100::tw7100Number *gainr_number_{nullptr}; tw7100::tw7100Number *gainr_number_ = dummy_number;
tw7100::tw7100Number *gaing_number_{nullptr}; tw7100::tw7100Number *gaing_number_ = dummy_number;
tw7100::tw7100Number *gainb_number_{nullptr}; tw7100::tw7100Number *gainb_number_ = dummy_number;
tw7100::tw7100Number *shrf_number_{nullptr}; tw7100::tw7100Number *shrf_number_ = dummy_number;
tw7100::tw7100Number *shrs_number_{nullptr}; tw7100::tw7100Number *shrs_number_ = dummy_number;
tw7100::tw7100Number *derange_number_{nullptr}; tw7100::tw7100Number *derange_number_ = dummy_number;
tw7100::tw7100Number *destrength_number_{nullptr}; tw7100::tw7100Number *destrength_number_ = dummy_number;
#endif #endif
}; };