ginkage / MHI-AC-Ctrl-ESPHome

ESPHome integration for MHI-AC-Ctrl project
MIT License
112 stars 39 forks source link

sensors not working with latest Home Assistant / ESPHome #15

Closed DirkHer closed 2 years ago

DirkHer commented 2 years ago

during compilation, the following error shows up:

Compiling /data/airco-dg/.pioenvs/airco-dg/src/main.cpp.o In file included from src/main.cpp:34: src/mhi_ac_ctrl.h: In member function 'virtual void MhiAcCtrl::cbiStatusFunction(ACStatus, int)': src/mhi_ac_ctrl.h:55:16: warning: enumeration value 'status_mqtt_lost' not handled in switch [-Wswitch] 55 | switch (status) { | ^ src/mhi_ac_ctrl.h:55:16: warning: enumeration value 'status_wifi_lost' not handled in switch [-Wswitch] /config/esphome/airco-dg.yaml: In lambda function: /config/esphome/airco-dg.yaml:50:44: error: 'class MhiAcCtrl' has no member named 'get_sensors' 50 | return ((MhiAcCtrl)mhi_ac_ctrl_dg)->get_sensors(); | ^~~ /config/esphome/airco-dg.yaml: In lambda function: /config/esphome/airco-dg.yaml:59:44: error: 'class MhiAcCtrl' has no member named 'get_binary_sensors' 59 | return ((MhiAcCtrl)mhi_ac_ctrl_dg)->get_binary_sensors(); | ^~~~~~ *** [/data/airco-dg/.pioenvs/airco-dg/src/main.cpp.o] Error 1 ========================= [FAILED] Took 12.23 seconds =========================

DYLaKo commented 2 years ago

Are you sure you are using the latest files from this github repo? I had similar errors a while back while compiling a new config in ESPHome. Solved it with updating the files from this github repo. (I already had the files from one of the first versions and never updated them).

DirkHer commented 2 years ago

today I've deleted all related files and copied the ones from the repo to the esphome folder. Then I used the original yaml file to create a new configuration. The sensor related errors appear with a different message and let the installation fail:

Compiling /data/lr_mhi_ac_ctrl/.pioenvs/lr_mhi_ac_ctrl/src/main.cpp.o In file included from src/main.cpp:29: src/mhi_ac_ctrl.h:393:39: error: could not convert '{"Defrost"}' from '' to 'esphome::binary_sensor::BinarySensor' 393 BinarySensor defrost_ { "Defrost" }; ^
/config/esphome/lr_mhi_ac_ctrl.yaml: In lambda function: /config/esphome/lr_mhi_ac_ctrl.yaml:28:26: error: could not convert '{mhi_ac_ctrl}' from '' to 'std::vector<esphome::climate::Climate*>' 28 return {mhi_ac_ctrl}; ^

*** [/data/lr_mhi_ac_ctrl/.pioenvs/lr_mhi_ac_ctrl/src/main.cpp.o] Error 1 ========================= [FAILED] Took 73.91 seconds =========================

ogizhelev commented 2 years ago

Same here - that is with ESPHome 2022.3.x version I did downgrade the ESPHome to 2022.2.6 - which worked fine

DYLaKo commented 2 years ago

Just tried to recompile the firmware for one of the units, while running ESPHome 2022.3.0 - Works fine. Updated to ESPHome 2022.3.1 (released march-23), recompiled - Works fine.

Processing woonkamer (board: d1_mini; framework: arduino; platform: platformio/espressif8266 @ 3.2.0) -------------------------------------------------------------------------------- (all compiling information...) Building /data/woonkamer/.pioenvs/woonkamer/firmware.bin esp8266_copy_factory_bin(["/data/woonkamer/.pioenvs/woonkamer/firmware.bin"], ["/data/woonkamer/.pioenvs/woonkamer/firmware.elf"]) ========================= [SUCCESS] Took 54.63 seconds =========================

Can you share your yaml config which you use for compiling?

ogizhelev commented 2 years ago

https://pastebin.com/RY33NGuR

DYLaKo commented 2 years ago

Ok, copied your yaml into a new device in ESPHome, modified wifi lines and the include lines to match my config and tried to compile - Error.

I will check it against my config to find the related differences.

DYLaKo commented 2 years ago

checked it, the problem lies in your config in lines: 87 - 92

128 - 133 binary_sensor:

When I remove these lines, it compiles without issues. Those sensors are not used in my config, so not sure yet what is wrong in them.

hvorragend commented 2 years ago

Did you modify your mhi_ac_ctrl.h? How? I also had similar problems and with the code of the user branch I also got errors.

I swapped BinarySensor defrost_ { "Defrost" }; with BinarySensor defrost_; at the end of mhi_ac_ctrl.h.

...
    MHI_AC_Ctrl_Core mhi_ac_ctrl_core;

    Sensor error_code_ { "Error code" };
    Sensor outdoor_temperature_ { "Outdoor temperature" };
    BinarySensor defrost_;
};
DYLaKo commented 2 years ago

I didn't change the mhi_ac_ctrl.h file, but your comment made me check it, there is no reference like you mentioned above.

It seems I am using the "master" branch, which works fine without these additional sensors. You are using the "sensor" branch, which comes with these sensors, but are now broken in the new ESPHome version.

Did you modify your mhi_ac_ctrl.h? How? I also had similar problems and with the code of the user branch I also got errors.

I swapped BinarySensor defrost_ { "Defrost" }; with BinarySensor defrost_; at the end of mhi_ac_ctrl.h.

...
    MHI_AC_Ctrl_Core mhi_ac_ctrl_core;

    Sensor error_code_ { "Error code" };
    Sensor outdoor_temperature_ { "Outdoor temperature" };
    BinarySensor defrost_;
};
DirkHer commented 2 years ago

thanks a lot, modifying the mhi_ac_ctrl.h as suggested fixed it

hvorragend commented 2 years ago

Even with today's latest code I still have the following errors:

Compiling /data/mhi_ac_ctrl/.pioenvs/mhi_ac_ctrl/lib67b/ESP8266WiFi/BearSSLHelpers.cpp.o
In file included from src/main.cpp:47:
src/mhi_ac_ctrl.h:465:39: error: could not convert '{"Defrost"}' from '<brace-enclosed initializer list>' to 'esphome::binary_sensor::BinarySensor'
  465 |     BinarySensor defrost_ { "Defrost" };
      |                                       ^
      |                                       |
      |                                       <brace-enclosed initializer list>
/config/esphome/mhi_ac_ctrl.yaml: In lambda function:
/config/esphome/mhi_ac_ctrl.yaml:46:26: error: could not convert '{mhi_ac_ctrl}' from '<brace-enclosed initializer list>' to 'std::vector<esphome::climate::Climate*>'
   46 |       return {mhi_ac_ctrl};
      |                          ^
      |                          |
      |                          <brace-enclosed initializer list>
Compiling /data/mhi_ac_ctrl/.pioenvs/mhi_ac_ctrl/lib67b/ESP8266WiFi/CertStoreBearSSL.cpp.o
*** [/data/mhi_ac_ctrl/.pioenvs/mhi_ac_ctrl/src/main.cpp.o] Error 1
========================= [FAILED] Took 38.43 seconds =========================

I still have to change BinarySensor defrost_ { "Defrost" }; to BinarySensor defrost_; in mhi_ac_ctrl.h.

ginkage commented 2 years ago

@synegic Could you please take a look? Might be caused by an outdated ESPHome version, or something...

hvorragend commented 2 years ago

FYI: I am running ESPHome v2022.3.1.

arpiecodes commented 2 years ago

Weird. I can confirm it does not compile after upgrading. I was running version 2022.2.x myself which still worked.

https://github.com/ginkage/MHI-AC-Ctrl-ESPHome/pull/19 should fix it. I don't think that vector initialisation suffix was actually doing anything anyways. But I'm neither a ESPHome nor C++ expert. :)