Comments (8)
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.
@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.
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.
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.
@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.
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.
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.
Fixed in GH-34
from esphome-mitsubishiheatpump.
Related Issues (20)
- how to set control over fan speed from web server? HOT 2
- My device works sometimes but, after shows IDLE. HOT 4
- External sensor types and temperature deltas HOT 1
- Using the ESPHome Uart component
- Turning on climate doesnโt remember last state
- Compile error: src/esphome/components/mitsubishi_heatpump/espmhp.cpp:454:46: error: comparison between distinct pointer types 'HardwareSerial*' and 'HWCDC*' lacks a cast HOT 2
- NTXUKS Model not communicating
- ESPHome 2024.4 compilation errors HOT 5
- Fan Modes in HA MSZ-RW25 HOT 1
- Provide a sensor for set fanspeed?
- Does the project support Mitsubishi Electric MSZ-HR35 HOT 3
- External temperature from HomeAssistant not stable HOT 1
- Component esphome.coroutine is marked FAILED HOT 9
- esphome 2024.6.0 changed the definition of HARDWARE_UART_TO_SERIAL HOT 26
- Error E4
- Compilation error using 2.5.0 & 2024.6.4 HOT 9
- Compile errors with new ESPHOME versions HOT 1
- Air Handler no longer reporting temperature HOT 2
- fan speed support in web interface
- ESP32 not starting HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from esphome-mitsubishiheatpump.