Giter Club home page Giter Club logo

Comments (8)

thompsa avatar thompsa commented on August 17, 2024

The HA Esphome api will disconnect if any invalid states are send through, you can check this by increasing the logging

logs:
  aioesphomeapi: debug

It will show something like

2021-04-27 06:38:44 DEBUG (MainThread) [aioesphomeapi.connection] heatpump.local: Got message of type <class 'api_pb2.ClimateStateResponse'>: key: 4281390649
current_temperature: nan
target_temperature: -1.6947395e+38
fan_mode: 254
swing_mode: 254

2021-04-27 06:38:44 INFO (MainThread) [aioesphomeapi.connection] heatpump.local: Unexpected error while reading incoming messages: 254 is not a valid ClimateFanMode
2021-04-27 06:38:44 DEBUG (MainThread) [aioesphomeapi.connection] heatpump.local: Closed socket

I resolved this by initialising those on setup. It is trying to publish the state before the first SwiCago/HeatPump callback.

diff --git a/espmhp.cpp b/espmhp.cpp
index e3a217d..0ba46bb 100644
--- a/espmhp.cpp
+++ b/espmhp.cpp
@@ -412,6 +412,10 @@ void MitsubishiHeatPump::setup() {
 
     ESP_LOGCONFIG(TAG, "Intializing new HeatPump object.");
     this->hp = new HeatPump();
+    this->current_temperature = 16;
+    this->target_temperature = 16;
+    this->fan_mode = climate::CLIMATE_FAN_OFF;
+    this->swing_mode = climate::CLIMATE_SWING_OFF;
 
 #ifdef USE_CALLBACKS
     hp->setSettingsChangedCallback(

from esphome-mitsubishiheatpump.

bulletmark avatar bulletmark commented on August 17, 2024

@thompsa, how do you go about making the above change? I am new to HA and ESPHOME, only discovering them by reference from this repo. I am using ESP32 D1 mini clones from Aliexpress for my 4 new aircon units. I thought I would practice generating my ESP32 boards before I get them connected as I am waiting for delivery of the CN105 connectors. Esphome seems to build and install fine but I get constant immediate disconnects/connects to HA, probably due to the issue you point out just above. If I change the source file in my build dir then it gets regenerated when I do a compile. If I git clone this repo to my machine and change the external_components/source line to point to that then I get Platform not found: 'climate.mitsubishi_heatpump' error. How can I make esphome use my own source? [I guess I could fork this repo and point to that, but there has to be a simpler way].

Also, @geoffdavis, this seems a simple fix. Any reason you don't want to add it? BTW, thanks for superb project. I leaned back in amused shock when I typed the esphome run command and everything downloaded, built, uploaded by USB to the device, then it appeared on my wifi network and automatically in HA.

from esphome-mitsubishiheatpump.

bulletmark avatar bulletmark commented on August 17, 2024

OK, so I went ahead and forked this repo, made the change, pointed the component to my forked repo, then rebuilt and uploaded where it is now working fine, i.e. it stays connected (and showing 16 degrees in HA of course now). Still interested in knowing how to do a change locally though?

from esphome-mitsubishiheatpump.

thompsa avatar thompsa commented on August 17, 2024

For me this turned out to be a symptom of the serial connection to the heatpump not working, I was using Serial2 on the ESP32 which worked fine for TX (I could control the heatpump mode, etc) but RX did not work. As the esp was not receiving any data from the heatpump the above state variables were uninitialised. Switching back to Serial0 resolved it.

While initialising them does stop HA from repeatedly disconnecting the sensor, you will want to fix the communication issue. You don't want it to say 16 degrees forever.

from esphome-mitsubishiheatpump.

bulletmark avatar bulletmark commented on August 17, 2024

@thompsa, please understand, I certainly don't want my HA to report 16 degrees forever!? It won't once I eventually get it connected to my aircon unit but that is not the issue here.

@geoffdavis, the issue is that if the CN105 connection 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 at least 4 times per second forever, i.e. it smashes the server ad-infinitum. Clearly this is undesirable and I am simply stating that the 4 line patch above fixes that issue.

from esphome-mitsubishiheatpump.

bulletmark avatar bulletmark commented on August 17, 2024

I worked out how to make source changes locally. You have to point to the actual components dir when specifying a path.

Also, a better patch is:

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 esphome-mitsubishiheatpump.

geoffdavis avatar geoffdavis commented on August 17, 2024

I like the NAN values better than dummy valid values, as it signifies to the user that something is wrong. I wish there were something similar for the climate modes. It might be worth adding a binary sensor that signifies a working connection to the equipment.

from esphome-mitsubishiheatpump.

geoffdavis avatar geoffdavis commented on August 17, 2024

Fixed in GH-34

from esphome-mitsubishiheatpump.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.