geoffdavis / esphome-mitsubishiheatpump

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

esphome 2024.6.0 changed the definition of HARDWARE_UART_TO_SERIAL #152

Closed sanjay900 closed 3 months ago

sanjay900 commented 3 months ago

Support for the rp2040 was merged into esphome, which changed the definition of that dictionary and its no longer possible to specify UART2 on the esp32 without a compilation error.

Ended up swapping to https://github.com/echavet/MitsubishiCN105ESPHome though as i was having problems with this component not receiving the temperature from my unit, which was resolved when i swapped.

pomah86 commented 3 months ago

I would prefer not to swap, any chance this will be fixed?

sanjay900 commented 3 months ago

Shouldn't be too hard to fix, just need to change that line to the following and import PLATFORM_ESP8266 from esphome.const

serial = HARDWARE_UART_TO_SERIAL[PLATFORM_ESP8266][config[CONF_HARDWARE_UART]]
Aresitoo commented 3 months ago

Got the same problem here.

But dont understand what i need to modify in my code go make it work ( total noob sorry )

Import what where? And change what line?


esphome:
  name: esphome-web-e5de40
  platform: ESP8266
  board: esp01_1m

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

substitutions:
  devicename: mitsubishi-aa-salon #EJEMPLO
  upper_devicename: Aire salon #EJEMPLO

logger:
  baud_rate: 0 #DESACTIVADO PARA NO CAUSAR CONFLITOS

# Enable Home Assistant API.
api:
  encryption:
    key: "NF8pw                                 hbjHus=" #OPCIONAL

# Enable over-the-air updates.
ota:
  - password: "xxxxxxxxxxxxxxxx" #OPCIONAL
    platform: esphome

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Esphome-Web-E5De40"
    password: "o        ap"

climate:
  #temp: 17-28; no diffuses, no vane
  - platform: mitsubishi_heatpump
    name: $upper_devicename
    hardware_uart: UART0
    baud_rate: 9600
    supports:
      mode: [DRY, COOL, HEAT, FAN_ONLY]
      fan_mode: [LOW, HIGH]
      swing_mode: []
    visual:
      min_temperature: 17
      max_temperature: 28
      temperature_step: 1.0

Error log from Esphome when trying to update is the following


INFO ESPHome 2024.6.1
INFO Reading configuration /config/esphome/esphome-web-e5de40.yaml...
INFO Generating C++ source...
Traceback (most recent call last):
  File "/usr/local/bin/esphome", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/esphome/esphome/__main__.py", line 1079, in main
    return run_esphome(sys.argv)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/esphome/esphome/__main__.py", line 1066, in run_esphome
    rc = POST_CONFIG_ACTIONS[args.command](args, config)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/esphome/esphome/__main__.py", line 484, in command_run
    exit_code = write_cpp(config)
                ^^^^^^^^^^^^^^^^^
  File "/esphome/esphome/__main__.py", line 193, in write_cpp
    generate_cpp_contents(config)
  File "/esphome/esphome/__main__.py", line 205, in generate_cpp_contents
    CORE.flush_tasks()
  File "/esphome/esphome/core/__init__.py", line 681, in flush_tasks
    self.event_loop.flush_tasks()
  File "/esphome/esphome/coroutine.py", line 246, in flush_tasks
    next(task.iterator)
  File "/esphome/esphome/__main__.py", line 185, in wrapped
    await coro(conf)
  File "/esphome/esphome/coroutine.py", line 80, in coro
    ret = yield from _flatten_generator(gen)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/esphome/esphome/coroutine.py", line 118, in _flatten_generator
    val = gen.send(to_send)
          ^^^^^^^^^^^^^^^^^
  File "/data/external_components/3b4567cc/components/mitsubishi_heatpump/climate.py", line 66, in to_code
    serial = HARDWARE_UART_TO_SERIAL[config[CONF_HARDWARE_UART]]
             ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^
KeyError: 'UART0'
ghisch commented 3 months ago

@sanjay900 made a PR following your recommendation, do not hesitate to review

@Aresitoo can't be fixed from your config file, need to be changed in the code

iddiek commented 3 months ago

same problem with a esp8266 board File "/data/external_components/3b4567cc/components/mitsubishi_heatpump/climate.py", line 66, in to_code serial = HARDWARE_UART_TO_SERIAL[config[CONF_HARDWARE_UART]]


KeyError: 'UART0'
Aresitoo commented 3 months ago

@ghisch So meaning just wait till a fix of the code comes out ? ( sorry I'm zero in code HA and Esphome )

ghisch commented 3 months ago

@Aresitoo Yes

sanjay900 commented 3 months ago

Change the external component to this, and you can use the fixed code without waiting for an update :)

Just grabbed a spare esp32, seems to get past the error just fine

external_components:
  - source: github://ghisch/esphome-mitsubishiheatpump@patch-1
rkboni commented 3 months ago

It definitely built, but the first one I updated has not come back online yet, and it's been long enough that I suspect the change either isn't right, or needs more configuration.

Here's my config:

substitutions:
  name: "basement-minisplit"
  friendly_name: Basement MiniSplit

esphome:
  name: ${name}

esp8266:
  board: d1_mini

# Enable logging
logger:
  # ESP8266 only - disable serial port logging, as the HeatPump component
  # needs the sole hardware UART on the ESP8266
  baud_rate: 0

# Enable Home Assistant API
api:

ota:
  platform: esphome

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  manual_ip:
    static_ip: <static-ip>
    gateway: <gateway-ip>
    subnet: <subnet>
    dns1: <dns-ip>

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "${friendly_name} Fallback"
    password: !secret fallback_password

captive_portal:

# Enable Web server.
web_server:
  port: 80

  # Sync time with Home Assistant.
time:
  - platform: homeassistant
    id: homeassistant_time

# Text sensors with general information.
text_sensor:
  # Expose ESPHome version as sensor.
  - platform: version
    name: ${name} ESPHome Version
  # Expose WiFi information as sensors.
  - platform: wifi_info
    ip_address:
      name: ${name} IP
    ssid:
      name: ${name} SSID
    bssid:
      name: ${name} BSSID

# Sensors with general information.
sensor:
  # Uptime sensor.
  - platform: uptime
    name: ${name} Uptime

  # WiFi Signal sensor.
  - platform: wifi_signal
    name: ${name} WiFi Signal
    update_interval: 60s

switch:
  - platform: restart
    name: "${friendly_name} Restart"

external_components:
  - source: github://ghisch/esphome-mitsubishiheatpump@patch-1

climate:
  - platform: mitsubishi_heatpump
    name: "${friendly_name}"
sanjay900 commented 3 months ago

Damn, unfortunately I wouldn't have a clue why that would be

rkboni commented 3 months ago

It definitely built, but the first one I updated has not come back online yet, and it's been long enough that I suspect the change either isn't right, or needs more configuration.

Oops, this was very unrelated... it failed to connect to the Wifi and was sitting in fallback-hotspot mode :/ (which also happened to the prior update to 2024.5.5 a few weeks ago). It's now connected again and reporting the right data. Sorry for the unwarranted panic!

EDIT: I also looked at the change that caused the issue and the resulting PR here, and given the change in esphome this absolutely looks like the right change.. thanks for doing that @ghisch!

sanjay900 commented 3 months ago

Good to hear, i do wonder if there is a better way to do it that would make it compatible with other micro controllers and older versions of esphome though.

ziolelle commented 3 months ago
github://ghisch/esphome-mitsubishiheatpump@patch-1

This worked perfectly for me, really thank you !!!!

adamderuwe commented 3 months ago

@pomah86

I would prefer not to swap, any chance this will be fixed?

This github repo hasn't had a commit in over 18 months. I think its probably time to migrate to something that is actively maintained like suggested. Don't hold your breath that this bug will be fixed in this repo.

geoffdavis commented 3 months ago

Fixed in #153

pomah86 commented 3 months ago

Fixed in #153

Updated just now and it all went perfect, thank you :)

lambu76 commented 3 months ago

Hi there, I executed "Clean Build File" in ESPHome in order to be sure to force the download of last version and now I ahve the following error.

@geoffdavis can you please advise ?

INFO ESPHome 2024.6.1 INFO Reading configuration /config/esphome/wemos-esp32-condizionatore-mansarda.yaml... WARNING 'wemos_esp32_condizionamansarda': 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 Detected timezone 'Europe/Rome' INFO Generating C++ source... INFO Compiling app... Processing wemos_esp32_condiziona_mansarda (board: nodemcu-32s; framework: arduino; platform: platformio/espressif32@5.4.0)

Library Manager: Installing esphome/AsyncTCP-esphome @ 2.1.3 INFO Installing esphome/AsyncTCP-esphome @ 2.1.3 Unpacking [####################################] 100% Library Manager: AsyncTCP-esphome@2.1.3 has been installed! INFO AsyncTCP-esphome@2.1.3 has been installed! Library Manager: Installing esphome/ESPAsyncWebServer-esphome @ 3.2.2 INFO Installing esphome/ESPAsyncWebServer-esphome @ 3.2.2 Unpacking [####################################] 100% Library Manager: ESPAsyncWebServer-esphome@3.2.2 has been installed! INFO ESPAsyncWebServer-esphome@3.2.2 has been installed! Library Manager: Resolving dependencies... INFO Resolving dependencies... Library Manager: Installing git+https://github.com/SwiCago/HeatPump#5d1e146771d2f458907a855bf9d5d4b9bf5ff033 INFO Installing git+https://github.com/SwiCago/HeatPump#5d1e146771d2f458907a855bf9d5d4b9bf5ff033 git version 2.39.2 Cloning into '/data/cache/platformio/cache/tmp/pkg-installing-h876tpz5'... HEAD is now at 5d1e146 Merge pull request #209 from dzungpv/master Library Manager: HeatPump@1.0.0+sha.5d1e146 has been installed! INFO HeatPump@1.0.0+sha.5d1e146 has been installed! HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash

lambu76 commented 3 months ago

Hi there, I executed "Clean Build File" in ESPHome in order to be sure to force the download of last version and now I ahve the following error.

INFO ESPHome 2024.6.1

INFO Reading configuration /config/esphome/wemos-esp32-condizionatore-mansarda.yaml... WARNING 'wemos_esp32_condizionamansarda': 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

The answer is in your post

"https://esphome.io/guides/faq.html#why-shouldn-t-i-use-underscores-in-my-device-name"

It worked fine for years, btw the error doens't seem related to underscore.

Have you seen the error into the compiling log ? Please don't stop to the first rows.

please let me know.

korttoma commented 3 months ago

Not sure if the errors are related to the hostname or not but I had to change some host names recently to be able to compile and upload so maybe it is wort a try?

btw, what external component are you using? "geoffdavis"? I changed to the "echavet" to work around the "UART" issue.

external_components:

lambu76 commented 3 months ago

Not sure if the errors are related to the hostname or not but I had to change some host names recently to be able to compile and upload so maybe it is wort a try?

btw, what external component are you using? "geoffdavis"? I changed to the "echavet" to work around the "UART" issue.

external_components:

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

external_components:

  • source: github://echavet/MitsubishiCN105ESPHome

I'm using geoffdavis and the error till yesterday was realted to the UART (as in this issue title).

Then today I saw a reply in this thread from geofdavis that the problem was fixed, but now I have that error.

Aresitoo commented 3 months ago

Change the external component to this, and you can use the fixed code without waiting for an update :)

Just grabbed a spare esp32, seems to get past the error just fine

external_components:
  - source: github://ghisch/esphome-mitsubishiheatpump@patch-1

So I have added this repo, it compiles correctly but now when it wants to push to the board it says 

''ERROR Error auth result: Error: Authentication invalid. Is the password correct?''

if I do not put any line and just ''

Enable over-the-air updates.

ota:

I also get error saying it needs a password

my previous config was this

Enable over-the-air updates.

ota:

tried the new config from esphome website

Example configuration entry

ota:

and put

ESPHome

ota_password: xxxxxxxxxxxxxxxx



in the secrets file but is also not working

what am I doing wrong here ?
lambu76 commented 3 months ago

I found the solution in another post in this project.

https://github.com/geoffdavis/esphome-mitsubishiheatpump/issues/117

Basically I added in my esphome below lines.

esphome: .... platformio_options: build_unflags:

I kindly ask you to @geoffdavis to advise if this is the behavior expected.

thx

Aresitoo commented 3 months ago

Ok so in my case I've re-flashed both esp connected to esphome fiscally to the computer, as new projects.

And got everything working and they are updating with the patched external components

Used :

external_components:
  - source: github://ghisch/esphome-mitsubishiheatpump@patch-1

Only modification to my old code has been to the OTA part

ota:
platform: esphome
password: "xxxx"
geoffdavis commented 3 months ago

I found the solution in another post in this project.

https://github.com/geoffdavis/esphome-mitsubishiheatpump/issues/117

Basically I added in my esphome below lines.

esphome:

....

platformio_options:

build_unflags:

  - "-std=gnu++11"

build_flags:

  - "-std=gnu++17"  

I kindly ask you to @geoffdavis to advise if this is the behavior expected.

thx

It's not expected behavior but I have been using 8266s to test.

geoffdavis commented 3 months ago

Note that the echavet repository is a rewrite of this code. I've been working with Eric to try and consolidate repositories, but nothing concrete so far.

ghisch commented 3 months ago

Hey 👋 I was seeing people still cloning my fork so I deleted it, it was only intended for the PR not for use. Please, anyone using github://ghisch/esphome-mitsubishiheatpump@patch-1 as source, switch back to github://geoffdavis/esphome-mitsubishiheatpump