From aa60a7f4ef59f02a5619df5f006861b2de2d2ff9 Mon Sep 17 00:00:00 2001 From: Mark Blakeney Date: Sat, 12 Jun 2021 11:19:02 +1000 Subject: [PATCH 1/2] Fix HA connection thrashing when no comms If the CN105 connection to the heat pump is down (i.e. unplugged, wrongly configured, etc), then the ESP device goes into a hard thrash loop where it is disconnecting and reconnecting to the HA server 2 times every second, i.e. it smashes the HA server ad-infinitum. This commit fixes this by ensuring the heat pump attributes are initialised to at least something non-random. We set the temperatures to NAN so it is clear they have not been initialised by heat pump, and thus apparent in logs etc. --- components/mitsubishi_heatpump/espmhp.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/components/mitsubishi_heatpump/espmhp.cpp b/components/mitsubishi_heatpump/espmhp.cpp index e1cb942..5bceea9 100644 --- a/components/mitsubishi_heatpump/espmhp.cpp +++ b/components/mitsubishi_heatpump/espmhp.cpp @@ -428,6 +428,10 @@ void MitsubishiHeatPump::setup() { ESP_LOGCONFIG(TAG, "Intializing new HeatPump object."); this->hp = new HeatPump(); + this->current_temperature = NAN; + this->target_temperature = NAN; + this->fan_mode = climate::CLIMATE_FAN_OFF; + this->swing_mode = climate::CLIMATE_SWING_OFF; #ifdef USE_CALLBACKS hp->setSettingsChangedCallback( From 6e3ea4989b172c072c2232f2c41aed82ca75a36e Mon Sep 17 00:00:00 2001 From: Mark Blakeney Date: Mon, 21 Jun 2021 14:28:38 +1000 Subject: [PATCH 2/2] Fix esphome v1.19 changes Addresses issue #37. --- README.md | 4 ++-- components/mitsubishi_heatpump/climate.py | 2 +- components/mitsubishi_heatpump/espmhp.cpp | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 9154912..33492cc 100644 --- a/README.md +++ b/README.md @@ -239,7 +239,7 @@ climate: hardware_uart: UART2 baud_rate: 9600 supports: - mode: [AUTO, COOL, HEAT, FAN_ONLY] + mode: [HEAT_COOL, COOL, HEAT, FAN_ONLY] fan_mode: [AUTO, LOW, MEDIUM, HIGH] swing_mode: [OFF, VERTICAL] visual: @@ -261,7 +261,7 @@ climate: is 9 seconds due to underlying issues with the HeatPump library. Default: 500ms * *supports* (_Optional_): Supported features for the device. ** *mode* (_Optional_, list): Supported climate modes for the HeatPump. Default: - `['AUTO', 'COOL', 'HEAT', 'DRY', 'FAN_ONLY']` + `['HEAT_COOL', 'COOL', 'HEAT', 'DRY', 'FAN_ONLY']` ** *fan_mode* (_Optional_, list): Supported fan speeds for the HeatPump. Default: `['AUTO', 'DIFFUSE', 'LOW', 'MEDIUM', 'MIDDLE', 'HIGH']` ** *swing_mode* (_Optional_, list): Supported diff --git a/components/mitsubishi_heatpump/climate.py b/components/mitsubishi_heatpump/climate.py index 901ef7f..d92a3aa 100644 --- a/components/mitsubishi_heatpump/climate.py +++ b/components/mitsubishi_heatpump/climate.py @@ -16,7 +16,7 @@ from esphome.core import CORE, coroutine AUTO_LOAD = ["climate"] CONF_SUPPORTS = "supports" -DEFAULT_CLIMATE_MODES = ['AUTO', 'COOL', 'HEAT', 'DRY', 'FAN_ONLY'] +DEFAULT_CLIMATE_MODES = ['HEAT_COOL', 'COOL', 'HEAT', 'DRY', 'FAN_ONLY'] DEFAULT_FAN_MODES = ['AUTO', 'DIFFUSE', 'LOW', 'MEDIUM', 'MIDDLE', 'HIGH'] DEFAULT_SWING_MODES = ['OFF', 'VERTICAL'] diff --git a/components/mitsubishi_heatpump/espmhp.cpp b/components/mitsubishi_heatpump/espmhp.cpp index 5bceea9..62842fc 100644 --- a/components/mitsubishi_heatpump/espmhp.cpp +++ b/components/mitsubishi_heatpump/espmhp.cpp @@ -141,7 +141,7 @@ void MitsubishiHeatPump::control(const climate::ClimateCall &call) { updated = true; } break; - case climate::CLIMATE_MODE_AUTO: + case climate::CLIMATE_MODE_HEAT_COOL: hp->setModeSetting("AUTO"); hp->setPowerSetting("ON"); if (has_mode){ @@ -291,7 +291,7 @@ void MitsubishiHeatPump::hpSettingsChanged() { this->mode = climate::CLIMATE_MODE_FAN_ONLY; this->action = climate::CLIMATE_ACTION_FAN; } else if (strcmp(currentSettings.mode, "AUTO") == 0) { - this->mode = climate::CLIMATE_MODE_AUTO; + this->mode = climate::CLIMATE_MODE_HEAT_COOL; if (auto_setpoint != currentSettings.temperature) { auto_setpoint = currentSettings.temperature; save(currentSettings.temperature, auto_storage); @@ -378,7 +378,7 @@ void MitsubishiHeatPump::hpStatusChanged(heatpumpStatus currentStatus) { this->action = climate::CLIMATE_ACTION_IDLE; } break; - case climate::CLIMATE_MODE_AUTO: + case climate::CLIMATE_MODE_HEAT_COOL: this->action = climate::CLIMATE_ACTION_IDLE; if (currentStatus.operating) { if (this->current_temperature > this->target_temperature) {