geoffdavis / esphome-mitsubishiheatpump

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

Warning: Component esphome.coroutine took a long time for an operation (0.10 s). #107

Closed kbarnes3 closed 9 months ago

kbarnes3 commented 11 months ago

I updated to ESPHome 2023.7.0 and a new warning is showing up every few seconds in the logs for all my ESP devices with this project running:

[11:08:35][W][component:204]: Component esphome.coroutine took a long time for an operation (0.10 s).
[11:08:35][W][component:205]: Components should block for at most 20-30ms.

This is new as of 2023.7.0 (I was previously running 2023.6.5) and my other ESP devices do not have similar warnings in their logs. All my heat pumps are using ESP8266 controllers running this project.

albertofralbe commented 11 months ago

Same happening to me updating two ESP8266 to the last version

ErikT80 commented 11 months ago

Same issue here after updating to 2023.7.0

immortalnzl commented 11 months ago

Is anyone else having them drop off the network? When I check the logs, the esphome.coroutine warning is gone. But I need to reinstall the firmware to get connection again.

kbarnes3 commented 11 months ago

I haven't had any reliability problems with my 3 controllers since this update, I've just had the warnings above logged frequently.

banemonster commented 10 months ago

Seems to be related to this open issue with ESPhome.

ESPHome Issue 4717

cfarence commented 10 months ago

Can say I have the same issues on an ESP32 and I've noticed the climate entity went unavailable when I was attempting to modify settings, though I haven't tracked it over time yet to see if it's regularly going offline.

brillb commented 10 months ago

Same for me since 2023.7.0, WeMos D1 Mini: 10:53:24 | [W] | [component:205] | Components should block for at most 20-30ms. 10:53:26 | [W] | [component:204] | Component esphome.coroutine took a long time for an operation (0.10 s).

ziolelle commented 10 months ago

Same also for me with Wemos D1 Mini: [07:41:46][W][component:204]: Component esphome.coroutine took a long time for an operation (0.10 s). [07:41:46][W][component:205]: Components should block for at most 20-30ms.

geoffdavis commented 9 months ago

All, this is unlikely to get fixed by me. I'd suggest changing your logging level to filter the message out if it bugs you.

A blurb like this ought to do it:

logging:
  logs:
    component: ERROR

The listed log message isn't new, just it's priority in the ESPHome logging system. As such, it's been working for years, and It's not likely to cause any real-world performance problems, assuming that you're not running five different hardware sensors and expecting near-real-time feedback.

The issue, as far as I can divine it from the linked ESPHOME ticket (thanks for the find @banemonster), is that the Serial UART reads and writes are blocking calls that cannot be interrupted. Without digging into the bowels of the Arduino serial library, I don't see a way for the underlying HeatPump component to "yield" the CPU until more data appears. These heatpumps typically communicate at 4800 baud, and that's not exactly lightning quick.

Someone with far deeper understanding of the Arduino Serial libraries may have a different answer. If so, I'm happy to accept a pull-request, but you'll likely need to work with @swicago on the underlying library.

jfisbein commented 9 months ago

@geoffdavis thank you for the information. What finally worked for me to hide those log messages is this config:

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

because the tag of those error messages is component not esphome.coroutine

geoffdavis commented 9 months ago

You're right, I had applied the old version to my systems, and it didn't work, then I fixed it but forgot to change my comment before hitting send and running out the door. I edited my comment.

jfisbein commented 9 months ago

Only one small typo, the root configuration element is logger not logging