geoffdavis / esphome-mitsubishiheatpump

ESPHome Climate Component for Mitsubishi Heatpumps using direct serial connection
BSD 2-Clause "Simplified" License
588 stars 158 forks source link

Compilation error using 2.5.0 & 2024.6.4 #157

Open yaro24 opened 5 months ago

yaro24 commented 5 months ago

With both the current versions of mhp and esphome I can't compile the projects anymore.

Here's the config:

esphome:
  name: klima_wintergarten
  friendly_name: Klima Wintergarten

esp32:
  board: esp32dev
  framework: 
    type: arduino

external_components:
  - source: github://geoffdavis/esphome-mitsubishiheatpump

# Enable logging
logger:
#  level: DEBUG
#  baud_rate: 0

<api , ota, wifi> 

climate:
  - platform: mitsubishi_heatpump
    name: Klimaanlage
    id: hp
    supports:
      mode: [HEAT_COOL, COOL, HEAT, FAN_ONLY]
      #mode: [COOL, HEAT, FAN_ONLY]
      fan_mode: [AUTO, DIFFUSE, LOW, MEDIUM, HIGH]
    hardware_uart: UART2

sensor:
  - platform: wifi_signal
    name: Klima Wintergarten WiFi Signal
    update_interval: 60s
  - platform: homeassistant
    name: "Thermometer"
    entity_id: sensor.berglampe_bmp_temperatur
    internal: true
    filters:
      - throttle: 10s
      - heartbeat: 1min             # Maximum interval between updates.
      - debounce: 1s
    on_value:
      then:
        - lambda: 'id(hp).set_remote_temperature(x);'

Here's the log output:

INFO ESPHome 2024.6.4
INFO Reading configuration /config/klima-wg.yaml...
WARNING 'klima_wintergarten': Using the '_' (underscore) character in the hostname is discouraged as it can cause problems with some DHCP and local name services. For more information, see https://esphome.io/guides/faq.html#why-shouldn-t-i-use-underscores-in-my-device-name
INFO Generating C++ source...
INFO Compiling app...
Processing klima_wintergarten (board: esp32dev; framework: arduino; platform: platformio/espressif32@5.4.0)
--------------------------------------------------------------------------------
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
 - toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch5
Dependency Graph
|-- AsyncTCP-esphome @ 2.1.3
|-- WiFi @ 2.0.0
|-- FS @ 2.0.0
|-- Update @ 2.0.0
|-- ESPAsyncWebServer-esphome @ 3.2.2
|-- DNSServer @ 2.0.0
|-- ESPmDNS @ 2.0.0
|-- noise-c @ 0.1.4
|-- HeatPump @ 1.0.0+sha.5d1e146
Compiling .pioenvs/klima_wintergarten/src/esphome/components/mitsubishi_heatpump/espmhp.cpp.o
Compiling .pioenvs/klima_wintergarten/src/esphome/components/sensor/sensor.cpp.o
Compiling .pioenvs/klima_wintergarten/src/esphome/components/socket/bsd_sockets_impl.cpp.o
Compiling .pioenvs/klima_wintergarten/src/esphome/components/socket/lwip_raw_tcp_impl.cpp.o
Compiling .pioenvs/klima_wintergarten/src/esphome/components/socket/lwip_sockets_impl.cpp.o
Compiling .pioenvs/klima_wintergarten/src/esphome/components/socket/socket.cpp.o
Compiling .pioenvs/klima_wintergarten/src/esphome/components/web_server_base/web_server_base.cpp.o
In file included from src/esphome.h:30,
                 from src/esphome/components/mitsubishi_heatpump/espmhp.h:20,
                 from src/esphome/components/mitsubishi_heatpump/espmhp.cpp:21:
src/esphome/components/mitsubishi_heatpump/espmhp.h:182:14: error: 'optional' in namespace 'std' does not name a template type
         std::optional<std::chrono::duration<long long, std::ratio<60>>> remote_operating_timeout_;
              ^~~~~~~~
src/esphome/components/mitsubishi_heatpump/espmhp.h:182:9: note: 'std::optional' is only available from C++17 onwards
         std::optional<std::chrono::duration<long long, std::ratio<60>>> remote_operating_timeout_;
         ^~~
src/esphome/components/mitsubishi_heatpump/espmhp.h:183:14: error: 'optional' in namespace 'std' does not name a template type
         std::optional<std::chrono::duration<long long, std::ratio<60>>> remote_idle_timeout_;
              ^~~~~~~~
src/esphome/components/mitsubishi_heatpump/espmhp.h:183:9: note: 'std::optional' is only available from C++17 onwards
         std::optional<std::chrono::duration<long long, std::ratio<60>>> remote_idle_timeout_;
         ^~~
src/esphome/components/mitsubishi_heatpump/espmhp.h:184:14: error: 'optional' in namespace 'std' does not name a template type
         std::optional<std::chrono::duration<long long, std::ratio<60>>> remote_ping_timeout_;
              ^~~~~~~~
src/esphome/components/mitsubishi_heatpump/espmhp.h:184:9: note: 'std::optional' is only available from C++17 onwards
         std::optional<std::chrono::duration<long long, std::ratio<60>>> remote_ping_timeout_;
         ^~~
src/esphome/components/mitsubishi_heatpump/espmhp.h:185:14: error: 'optional' in namespace 'std' does not name a template type
         std::optional<std::chrono::time_point<std::chrono::steady_clock>> last_remote_temperature_sensor_update_;
              ^~~~~~~~
src/esphome/components/mitsubishi_heatpump/espmhp.h:185:9: note: 'std::optional' is only available from C++17 onwards
         std::optional<std::chrono::time_point<std::chrono::steady_clock>> last_remote_temperature_sensor_update_;
         ^~~
src/esphome/components/mitsubishi_heatpump/espmhp.h:186:14: error: 'optional' in namespace 'std' does not name a template type
         std::optional<std::chrono::time_point<std::chrono::steady_clock>> last_ping_request_;
              ^~~~~~~~
src/esphome/components/mitsubishi_heatpump/espmhp.h:186:9: note: 'std::optional' is only available from C++17 onwards
         std::optional<std::chrono::time_point<std::chrono::steady_clock>> last_ping_request_;
         ^~~
Compiling .pioenvs/klima_wintergarten/src/esphome/components/wifi/wifi_component.cpp.o
src/esphome/components/mitsubishi_heatpump/espmhp.cpp: In member function 'virtual void MitsubishiHeatPump::control(const esphome::climate::ClimateCall&)':
src/esphome/components/mitsubishi_heatpump/espmhp.cpp:252:9: error: 'last_remote_temperature_sensor_update_' was not declared in this scope
     if (last_remote_temperature_sensor_update_.has_value()) {
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/esphome/components/mitsubishi_heatpump/espmhp.cpp:252:9: note: suggested alternative: 'enforce_remote_temperature_sensor_timeout'
     if (last_remote_temperature_sensor_update_.has_value()) {
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         enforce_remote_temperature_sensor_timeout
src/esphome/components/mitsubishi_heatpump/espmhp.cpp: In member function 'void MitsubishiHeatPump::set_remote_temperature(float)':
src/esphome/components/mitsubishi_heatpump/espmhp.cpp:625:9: error: 'last_remote_temperature_sensor_update_' was not declared in this scope
         last_remote_temperature_sensor_update_ =
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/esphome/components/mitsubishi_heatpump/espmhp.cpp:625:9: note: suggested alternative: 'enforce_remote_temperature_sensor_timeout'
         last_remote_temperature_sensor_update_ =
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         enforce_remote_temperature_sensor_timeout
src/esphome/components/mitsubishi_heatpump/espmhp.cpp:628:9: error: 'last_remote_temperature_sensor_update_' was not declared in this scope
         last_remote_temperature_sensor_update_.reset();
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/esphome/components/mitsubishi_heatpump/espmhp.cpp:628:9: note: suggested alternative: 'enforce_remote_temperature_sensor_timeout'
         last_remote_temperature_sensor_update_.reset();
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         enforce_remote_temperature_sensor_timeout
src/esphome/components/mitsubishi_heatpump/espmhp.cpp: In member function 'void MitsubishiHeatPump::ping()':
src/esphome/components/mitsubishi_heatpump/espmhp.cpp:636:5: error: 'last_ping_request_' was not declared in this scope
     last_ping_request_ = std::chrono::steady_clock::now();
     ^~~~~~~~~~~~~~~~~~
src/esphome/components/mitsubishi_heatpump/espmhp.cpp: In member function 'void MitsubishiHeatPump::set_remote_operating_timeout_minutes(int)':
src/esphome/components/mitsubishi_heatpump/espmhp.cpp:641:5: error: 'remote_operating_timeout_' was not declared in this scope
     remote_operating_timeout_ = std::chrono::minutes(minutes);
     ^~~~~~~~~~~~~~~~~~~~~~~~~
Compiling .pioenvs/klima_wintergarten/src/esphome/components/wifi/wifi_component_esp32_arduino.cpp.o
src/esphome/components/mitsubishi_heatpump/espmhp.cpp:641:5: note: suggested alternative: 'set_remote_operating_timeout_minutes'
     remote_operating_timeout_ = std::chrono::minutes(minutes);
     ^~~~~~~~~~~~~~~~~~~~~~~~~
     set_remote_operating_timeout_minutes
src/esphome/components/mitsubishi_heatpump/espmhp.cpp: In member function 'void MitsubishiHeatPump::set_remote_idle_timeout_minutes(int)':
src/esphome/components/mitsubishi_heatpump/espmhp.cpp:646:5: error: 'remote_idle_timeout_' was not declared in this scope
     remote_idle_timeout_ = std::chrono::minutes(minutes);
     ^~~~~~~~~~~~~~~~~~~~
src/esphome/components/mitsubishi_heatpump/espmhp.cpp:646:5: note: suggested alternative: 'set_timeout'
     remote_idle_timeout_ = std::chrono::minutes(minutes);
     ^~~~~~~~~~~~~~~~~~~~
     set_timeout
src/esphome/components/mitsubishi_heatpump/espmhp.cpp: In member function 'void MitsubishiHeatPump::set_remote_ping_timeout_minutes(int)':
src/esphome/components/mitsubishi_heatpump/espmhp.cpp:651:5: error: 'remote_ping_timeout_' was not declared in this scope
     remote_ping_timeout_ = std::chrono::minutes(minutes);
     ^~~~~~~~~~~~~~~~~~~~
src/esphome/components/mitsubishi_heatpump/espmhp.cpp:651:5: note: suggested alternative: 'set_timeout'
     remote_ping_timeout_ = std::chrono::minutes(minutes);
     ^~~~~~~~~~~~~~~~~~~~
     set_timeout
src/esphome/components/mitsubishi_heatpump/espmhp.cpp: In member function 'void MitsubishiHeatPump::enforce_remote_temperature_sensor_timeout()':
src/esphome/components/mitsubishi_heatpump/espmhp.cpp:656:9: error: 'remote_ping_timeout_' was not declared in this scope
     if (remote_ping_timeout_.has_value() && last_ping_request_.has_value()) {
         ^~~~~~~~~~~~~~~~~~~~
src/esphome/components/mitsubishi_heatpump/espmhp.cpp:656:9: note: suggested alternative: 'set_timeout'
     if (remote_ping_timeout_.has_value() && last_ping_request_.has_value()) {
         ^~~~~~~~~~~~~~~~~~~~
         set_timeout
src/esphome/components/mitsubishi_heatpump/espmhp.cpp:656:45: error: 'last_ping_request_' was not declared in this scope
     if (remote_ping_timeout_.has_value() && last_ping_request_.has_value()) {
                                             ^~~~~~~~~~~~~~~~~~
src/esphome/components/mitsubishi_heatpump/espmhp.cpp:669:28: error: 'remote_operating_timeout_' was not declared in this scope
         this->operating_ ? remote_operating_timeout_ : remote_idle_timeout_;
                            ^~~~~~~~~~~~~~~~~~~~~~~~~
src/esphome/components/mitsubishi_heatpump/espmhp.cpp:669:28: note: suggested alternative: 'set_remote_operating_timeout_minutes'
         this->operating_ ? remote_operating_timeout_ : remote_idle_timeout_;
                            ^~~~~~~~~~~~~~~~~~~~~~~~~
                            set_remote_operating_timeout_minutes
src/esphome/components/mitsubishi_heatpump/espmhp.cpp:669:56: error: 'remote_idle_timeout_' was not declared in this scope
         this->operating_ ? remote_operating_timeout_ : remote_idle_timeout_;
                                                        ^~~~~~~~~~~~~~~~~~~~
src/esphome/components/mitsubishi_heatpump/espmhp.cpp:669:56: note: suggested alternative: 'set_timeout'
         this->operating_ ? remote_operating_timeout_ : remote_idle_timeout_;
                                                        ^~~~~~~~~~~~~~~~~~~~
                                                        set_timeout
src/esphome/components/mitsubishi_heatpump/espmhp.cpp:671:13: error: 'last_remote_temperature_sensor_update_' was not declared in this scope
             last_remote_temperature_sensor_update_.has_value()) {
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/esphome/components/mitsubishi_heatpump/espmhp.cpp:671:13: note: suggested alternative: 'enforce_remote_temperature_sensor_timeout'
             last_remote_temperature_sensor_update_.has_value()) {
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
             enforce_remote_temperature_sensor_timeout
*** [.pioenvs/klima_wintergarten/src/esphome/components/mitsubishi_heatpump/espmhp.cpp.o] Error 1
========================== [FAILED] Took 4.50 seconds ==========================

Please let me know if you need any more information or testing

65698888 commented 5 months ago

Who has the solution to the same problem?

FedericoAntoniazzi commented 5 months ago

Hello there, I pinned the commit before all the merges and confirm it is a regression.

Here for reference:

external_components:
  - source: "github://geoffdavis/esphome-mitsubishiheatpump@31ed3068fcf0713873b157e28d0d36248a352d83"
TimelessNL commented 5 months ago

Here for reference:

external_components:
  - source: "github://geoffdavis/esphome-mitsubishiheatpump@31ed3068fcf0713873b157e28d0d36248a352d83"

@FedericoAntoniazzi What do you mean exactly? Using that commit result in another compile error:

Compiling .pioenvs/mitsubishi-airco/lib05e/AsyncTCP-esphome/AsyncTCP.cpp.o
src/main.cpp: In function 'void setup()':
src/main.cpp:524:57: error: no matching function for call to 'MitsubishiHeatPump::MitsubishiHeatPump(HWCDC*)'
   mitsubishiheatpump_id = new MitsubishiHeatPump(&Serial);
                                                         ^
In file included from src/esphome.h:48,
                 from src/main.cpp:3:
src/esphome/components/mitsubishi_heatpump/espmhp.h:55:9: note: candidate: 'MitsubishiHeatPump::MitsubishiHeatPump(HardwareSerial*, uint32_t)'
         MitsubishiHeatPump(
         ^~~~~~~~~~~~~~~~~~
src/esphome/components/mitsubishi_heatpump/espmhp.h:55:9: note:   no known conversion for argument 1 from 'HWCDC*' to 'HardwareSerial*'
src/esphome/components/mitsubishi_heatpump/espmhp.h:44:7: note: candidate: 'MitsubishiHeatPump::MitsubishiHeatPump(const MitsubishiHeatPump&)'
 class MitsubishiHeatPump : public PollingComponent, public climate::Climate {
       ^~~~~~~~~~~~~~~~~~
src/esphome/components/mitsubishi_heatpump/espmhp.h:44:7: note:   no known conversion for argument 1 from 'HWCDC*' to 'const MitsubishiHeatPump&'
src/esphome/components/mitsubishi_heatpump/espmhp.h:44:7: note: candidate: 'MitsubishiHeatPump::MitsubishiHeatPump(MitsubishiHeatPump&&)'
src/esphome/components/mitsubishi_heatpump/espmhp.h:44:7: note:   no known conversion for argument 1 from 'HWCDC*' to 'MitsubishiHeatPump&&'

Never mind, seems the ESP32-C3 with its default logger port being USB_CDC together with this external component causes this compile error. Configuring the logger port as UART0 similarly to the ESP32 seems to work:

logger:
  hardware_uart: UART0
  baud_rate: 0
jonathandann commented 4 months ago

This got it working for me with a Wemos ESP32-S2-mini v1.0.0 https://www.wemos.cc/en/latest/s2/s2_mini.html

external_components:
  - source: github://geoffdavis/esphome-mitsubishiheatpump@2.5.0

esphome:
  platformio_options:
    build_flags: 
      - -std=gnu++17
    build_unflags:
      - -std=gnu++11

esp32:
  board: lolin_s2_mini
  variant: esp32s2
  framework:
    type: arduino

https://github.com/SwiCago/HeatPump/issues/13#issuecomment-2222657355

SCUZNUTS commented 4 months ago

Hello there, I pinned the commit before all the merges and confirm it is a regression.

Here for reference:

external_components:
  - source: "github://geoffdavis/esphome-mitsubishiheatpump@31ed3068fcf0713873b157e28d0d36248a352d83"

confirmed this version works for me

adeptcain commented 4 months ago

This got it working for me with a Wemos ESP32-S2-mini v1.0.0 https://www.wemos.cc/en/latest/s2/s2_mini.html

external_components:
  - source: github://geoffdavis/esphome-mitsubishiheatpump@2.5.0

esphome:
  platformio_options:
    build_flags: 
      - -std=gnu++17
    build_unflags:
      - -std=gnu++11

esp32:
  board: lolin_s2_mini
  variant: esp32s2
  framework:
    type: arduino

SwiCago/HeatPump#13 (comment)

Can confirm this worked for me on a cheap clone ESP32. Reverting to a previous commit also worked, but I'd rather be running the latest.

geoffdavis commented 4 months ago

@adeptcain Thanks for tracking this down. Looks like one of the newer commits starting using C++17 code, and the ESP8266 toolchain is totally fine with it.

@SCUZNUTS and @yaro24 please verify that the "platformio_options" that @adeptcain provided work for your boards, and I'll update the documentation for the ESP32.

SCUZNUTS commented 4 months ago

Can confirm, doing the above works for me;


esp32:
  board: esp32-c3-devkitm-1
  framework:
    type: arduino

external_components:
  - source: github://geoffdavis/esphome-mitsubishiheatpump

esphome:
  platformio_options:
    build_flags: 
      - -std=gnu++17
    build_unflags:
      - -std=gnu++11
adeptcain commented 4 months ago

@geoffdavis thanks, but it was @jonathandann who found the fix by the looks of it, I was just confirming it works for me :)