publish to select

This commit is contained in:
T 2025-03-14 18:05:03 +01:00
parent 6454dc6d58
commit 2c29ef0e71
2 changed files with 17 additions and 4 deletions

View File

@ -19,6 +19,17 @@ template<typename C, typename M> static void publish(C *c, M m) {
c->publish_state(m);
}
void OptomaRS232Component::publish_input_(const std::string &state) const {
#ifdef USE_SELECT
if (beamer_input_select_)
beamer_input_select_->publish_state(state);
#endif
#ifdef USE_TEXT_SENSOR
if (beamer_input_text_sensor_)
beamer_input_text_sensor_->publish_state(state);
#endif
}
void OptomaRS232Component::dump_config() {
ESP_LOGCONFIG(TAG, "Optoma RS232:");
check_uart_settings(9600);
@ -137,20 +148,20 @@ void OptomaRS232Component::process_query_response_(const std::string &str) {
switch (input) {
case Inputs::HDMI_1:
current_input_ = Inputs::HDMI_1;
publish(beamer_input_text_sensor_, "HDMI 1");
publish_input_("HDMI 1");
break;
case Inputs::HDMI_2:
current_input_ = Inputs::HDMI_2;
publish(beamer_input_text_sensor_, "HDMI 2");
publish_input_("HDMI 2");
break;
case Inputs::VGA:
current_input_ = Inputs::VGA;
publish(beamer_input_text_sensor_, "VGA");
publish_input_("VGA");
break;
default:
case Inputs::UNKNOWN:
current_input_ = Inputs::UNKNOWN;
publish(beamer_input_text_sensor_, "Unknown");
publish_input_("Unknown");
break;
}
buf[8] = 0;

View File

@ -72,6 +72,8 @@ class OptomaRS232Component : public uart::UARTDevice, public PollingComponent {
private:
char buffer_[128]{};
size_t cursor_ = 0;
void publish_input_(const std::string &state) const;
};
#ifdef USE_SELECT