mirror of
https://github.com/esphome/esphome.git
synced 2024-11-27 01:08:03 +01:00
Add some sanity checking when set to Internal temperature source
This commit is contained in:
parent
0bb5419851
commit
25326fa6b9
2 changed files with 19 additions and 13 deletions
|
@ -51,9 +51,14 @@ void MitsubishiUART::loop() {
|
||||||
if (ts_bridge_)
|
if (ts_bridge_)
|
||||||
ts_bridge_->loop();
|
ts_bridge_->loop();
|
||||||
|
|
||||||
|
if ((millis() - last_received_temperature_) > TEMPERATURE_SOURCE_TIMEOUT_MS) {
|
||||||
|
if (current_temperature_source_.empty() || current_temperature_source_ != TEMPERATURE_SOURCE_INTERNAL) {
|
||||||
|
ESP_LOGD(TAG, "Reminding heat pump to use internal temperature sensor");
|
||||||
|
// Check to make sure a temperature source is set-- if not, set to internal for sanity reasons
|
||||||
|
IFACTIVE(this->select_temperature_source(TEMPERATURE_SOURCE_INTERNAL);)
|
||||||
|
last_received_temperature_ = millis(); // Count this as "receiving" the internal temperature
|
||||||
|
} else if (!temperature_source_timeout_) {
|
||||||
// If it's been too long since we received a temperature update (and we're not set to Internal)
|
// If it's been too long since we received a temperature update (and we're not set to Internal)
|
||||||
if (((millis() - last_received_temperature_) > TEMPERATURE_SOURCE_TIMEOUT_MS) &&
|
|
||||||
current_temperature_source_ != TEMPERATURE_SOURCE_INTERNAL && !temperature_source_timeout_) {
|
|
||||||
ESP_LOGW(TAG, "No temperature received from %s for %lu milliseconds, reverting to Internal source",
|
ESP_LOGW(TAG, "No temperature received from %s for %lu milliseconds, reverting to Internal source",
|
||||||
current_temperature_source_.c_str(), (unsigned long) TEMPERATURE_SOURCE_TIMEOUT_MS);
|
current_temperature_source_.c_str(), (unsigned long) TEMPERATURE_SOURCE_TIMEOUT_MS);
|
||||||
// Let listeners know we've changed to the Internal temperature source (but do not change
|
// Let listeners know we've changed to the Internal temperature source (but do not change
|
||||||
|
@ -65,6 +70,7 @@ void MitsubishiUART::loop() {
|
||||||
// Send a packet to the heat pump to tell it to switch to internal temperature sensing
|
// Send a packet to the heat pump to tell it to switch to internal temperature sensing
|
||||||
IFACTIVE(hp_bridge_.send_packet(RemoteTemperatureSetRequestPacket().use_internal_temperature());)
|
IFACTIVE(hp_bridge_.send_packet(RemoteTemperatureSetRequestPacket().use_internal_temperature());)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MitsubishiUART::dump_config() {
|
void MitsubishiUART::dump_config() {
|
||||||
|
|
|
@ -165,7 +165,7 @@ class MitsubishiUART : public PollingComponent, public climate::Climate, public
|
||||||
}
|
}
|
||||||
|
|
||||||
// Temperature select extras
|
// Temperature select extras
|
||||||
std::string current_temperature_source_ = TEMPERATURE_SOURCE_INTERNAL;
|
std::string current_temperature_source_;
|
||||||
uint32_t last_received_temperature_ = millis();
|
uint32_t last_received_temperature_ = millis();
|
||||||
bool temperature_source_timeout_ = false; // Has the current source timed out?
|
bool temperature_source_timeout_ = false; // Has the current source timed out?
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue