evgeni / esphome-configs

39 stars 13 forks source link

Very slow response time #104

Open MrBLJ opened 1 month ago

MrBLJ commented 1 month ago

Hello all,

I've been using this config for a while now, and I'm faced with a recurrent issue. Every few weeks/month, the covers in HA becomes very slow to respond (I'm talking about 30 secs between pressing the button in HA and seeing the commands acknowledged in the ESP logs, if it is at all).

I have warning messages displayed when commands are executed. Note that If I press the button several times, with 5s interval between each press, they are all processed at the same time after a while by the ESP :

[11:03:10][D][cover:076]: 'Somfy Cover' - Setting
[11:03:10][D][cover:086]:   Command: CLOSE
[11:03:10][I][somfy:054]: CLOSE
[11:03:11][D][cover:170]: 'Somfy Cover' - Publishing:
[11:03:11][D][cover:178]:   State: CLOSED
[11:03:11][D][cover:186]:   Current Operation: IDLE
[11:03:11][W][component:237]: Component api took a long time for an operation (822 ms).
[11:03:11][W][component:238]: Components should block for at most 30 ms.

This is my config, it is very similar to @evgeni 's :

esphome:
  name: esp32-01
  friendly_name: esp32_01
  libraries:
    - EEPROM
    - SPI
    - SmartRC-CC1101-Driver-Lib@2.5.6
    - Somfy_Remote_Lib@0.4.1
  includes:
    - components/somfy_secrets.h
    - components/esp32/somfy_cover.h

esp32:
  board: esp32doit-devkit-v1
  framework:
    type: arduino

# Enable Home Assistant API
api:
  encryption:
    key: "redacted"

ota:
  - platform: esphome
    password: $ota_paswword

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

# Optional manual IP
  manual_ip:
    static_ip: 192.168.20.128
    gateway: 192.168.20.1
    subnet: 255.255.255.0

cover:
  - platform: custom
    lambda: |-
      auto somfy_remote = new SomfyESPRemote();
      somfy_remote->add_cover("somfy", "auvent", SOMFY_REMOTE_AUVENT);
      somfy_remote->add_cover("somfy", "bedroom", SOMFY_REMOTE_BEDROOM);
      somfy_remote->add_cover("somfy", "garage", SOMFY_REMOTE_GARAGE);
      App.register_component(somfy_remote);
      return somfy_remote->covers;

    covers:
      - id: "somfy"
        name: "Somfy Cover"
      - id: "somfy2"
        name: "Somfy Cover Bedroom"
      - id: "somfy3"
        name: "Somfy Cover garage"

switch:
  - platform: template
    name: "PROG"
    turn_on_action:
      - lambda: |-
          ((SomfyESPCover*)id(somfy))->program();
  - platform: template
    name: "STOP"
    turn_on_action:
      - lambda: |-
          ((SomfyESPCover*)id(somfy))->make_call().set_command_stop().perform();
  - platform: template
    name: "PROG2"
    turn_on_action:
      - lambda: |-
          ((SomfyESPCover*)id(somfy2))->program();
  - platform: template
    name: "STOP2"
    turn_on_action:
      - lambda: |-
          ((SomfyESPCover*)id(somfy2))->make_call().set_command_stop().perform();
  - platform: template
    name: "PROG3"
    turn_on_action:
      - lambda: |-
          ((SomfyESPCover*)id(somfy3))->program();
  - platform: template
    name: "STOP3"
    turn_on_action:
      - lambda: |-
          ((SomfyESPCover*)id(somfy3))->make_call().set_command_stop().perform();

# THIS BLOCK HAS BEEN ADDED FOR DEBUG PURPOSES
logger:
  level: debug

debug:
  update_interval: 600s

text_sensor:
  - platform: debug
    device:
      name: "Device Info"
    reset_reason:
      name: "Reset Reason"

sensor:
  - platform: debug
    free:
      name: "Heap Free"
    loop_time:
      name: "Loop Time"
  - platform: uptime
    type: seconds
    name: Uptime Sensor

Note that I don't think we us the same board, could it be that mine is underpowered ? To me it looks like it's hardware related :

  1. The commands work fine for all covers, when I erase the memory with esphome flasher.
  2. All somfy hardware is functionnal : physical remotes work fine.
  3. ESP device is constantly loosing wifi connection. It is less than 2m from my access point and 30cms from another ESP which is working flawlessly.
  4. Heap free is as follow : image

Does it look like the device is running out of memory ? How would you investigate and fix those symptoms ?

I must confess I'm lost for the time being. Thanks for any help you can provide !

evgeni commented 1 month ago

This sounds like too aggressive power saving, but I've so far not seen that on ESP32 devices, only 8266 ones.

MrBLJ commented 1 month ago

This sounds like too aggressive power saving, but I've so far not seen that on ESP32 devices, only 8266 ones.

Thanks for the time you took to answer. Could you detail a bit more if possible ? I'm afraid I have little to no clue about what you are reffering to.

evgeni commented 1 month ago

I was talking about https://esphome.io/components/wifi.html#wifi-power-save-mode and especially https://github.com/esphome/issues/issues/1532, but that's 8266-specific. Had those issues on our Shelly 2.5 switches.