mirror of
https://github.com/geoffdavis/esphome-mitsubishiheatpump
synced 2024-08-30 18:12:13 +00:00
Mark component as failed if serial conflict is detected
This commit is contained in:
parent
980271337a
commit
eaba66fac4
@ -42,15 +42,27 @@ MitsubishiHeatPump::MitsubishiHeatPump(
|
|||||||
this->traits_.set_visual_temperature_step(ESPMHP_TEMPERATURE_STEP);
|
this->traits_.set_visual_temperature_step(ESPMHP_TEMPERATURE_STEP);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MitsubishiHeatPump::check_logger_conflict_() {
|
bool MitsubishiHeatPump::verify_serial() {
|
||||||
|
if (!this->get_hw_serial_()) {
|
||||||
|
ESP_LOGCONFIG(
|
||||||
|
TAG,
|
||||||
|
"No HardwareSerial was provided. "
|
||||||
|
"Software serial ports are unsupported by this component."
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef USE_LOGGER
|
#ifdef USE_LOGGER
|
||||||
if (this->get_hw_serial_() == logger::global_logger->get_hw_serial()) {
|
if (this->get_hw_serial_() == logger::global_logger->get_hw_serial()) {
|
||||||
ESP_LOGW(TAG, " You're using the same serial port for logging"
|
ESP_LOGW(TAG, " You're using the same serial port for logging"
|
||||||
" and the MitsubishiHeatPump component. Please disable"
|
" and the MitsubishiHeatPump component. Please disable"
|
||||||
" logging over the serial port by setting"
|
" logging over the serial port by setting"
|
||||||
" logger:baud_rate to 0.");
|
" logger:baud_rate to 0.");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
// unless something went wrong, assume we have a valid serial configuration
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MitsubishiHeatPump::update() {
|
void MitsubishiHeatPump::update() {
|
||||||
@ -414,18 +426,13 @@ void MitsubishiHeatPump::setup() {
|
|||||||
// This will be called by App.setup()
|
// This will be called by App.setup()
|
||||||
this->banner();
|
this->banner();
|
||||||
ESP_LOGCONFIG(TAG, "Setting up UART...");
|
ESP_LOGCONFIG(TAG, "Setting up UART...");
|
||||||
if (!this->get_hw_serial_()) {
|
|
||||||
ESP_LOGCONFIG(
|
if (!this->verify_serial()) {
|
||||||
TAG,
|
|
||||||
"No HardwareSerial was provided. "
|
|
||||||
"Software serial ports are unsupported by this component."
|
|
||||||
);
|
|
||||||
this->mark_failed();
|
this->mark_failed();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this->check_logger_conflict_();
|
|
||||||
|
|
||||||
ESP_LOGCONFIG(TAG, "Intializing new HeatPump object.");
|
ESP_LOGCONFIG(TAG, "Initializing new HeatPump object.");
|
||||||
this->hp = new HeatPump();
|
this->hp = new HeatPump();
|
||||||
this->current_temperature = NAN;
|
this->current_temperature = NAN;
|
||||||
this->target_temperature = NAN;
|
this->target_temperature = NAN;
|
||||||
|
@ -113,8 +113,8 @@ class MitsubishiHeatPump : public PollingComponent, public climate::Climate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Print a warning message if we're using the sole hardware UART on an
|
//Print a warning message if we're using the sole hardware UART on an
|
||||||
//ESP8266 or UART0 on ESP32
|
//ESP8266 or UART0 on ESP32, or if no serial was provided
|
||||||
void check_logger_conflict_();
|
bool verify_serial();
|
||||||
|
|
||||||
// various prefs to save mode-specific temperatures, akin to how the IR
|
// various prefs to save mode-specific temperatures, akin to how the IR
|
||||||
// remote works.
|
// remote works.
|
||||||
|
Loading…
Reference in New Issue
Block a user