esphome / issues

Issue Tracker for ESPHome
https://esphome.io/
294 stars 38 forks source link

`cover.toggle` does not use `toggle_action ` #6388

Open francescocarzaniga opened 1 month ago

francescocarzaniga commented 1 month ago

The problem

I have defined a simple template cover as follows:

cover:
- platform: template
  name: "Gate"
  lambda: |-
    if (id(gate_sensor).state) {
      return COVER_OPEN;
    } else {
      return COVER_CLOSED;
    }
  open_action:
    - button.press: gate_open
  close_action:
    - button.press: gate_close
  toggle_action:
    - button.press: gate_toggle
  device_class: gate

The cover works perfectly fine; it opens, closes, and reports the right state both in ESPHome itself and in HomeAssistant.

However, the cover.toggle service in HomeAssistant does not use toggle_action, but calls open_action and close_action directly. Since toggle_action can contain different logic than directly opening and closing, I would expect it to be respected.

Which version of ESPHome has the issue?

2024.7.3

What type of installation are you using?

pip

Which version of Home Assistant has the issue?

2024.8.2

What platform are you using?

ESP32

Board

No response

Component causing the issue

cover

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

ssieb commented 1 month ago

This sounds more likely to be an HA issue. Can you tell if it's happening in core HA or the esphome integration?

francescocarzaniga commented 1 month ago

I'm not sure how I would check that. This is the relevant excerpt from the debug logs when I use cover.toggle:

<DATE> DEBUG (MainThread) [aioesphomeapi.connection] <DEVICE> @ <IP>: Sending PingRequest: 
<DATE> DEBUG (MainThread) [aioesphomeapi._frame_helper.base] <DEVICE> @ <IP>: Sending frame: [010014c6e6828b84084d7d6554123e44b20ebe22a66517]
<DATE> DEBUG (MainThread) [aioesphomeapi.connection] <DEVICE> @ <IP>: Got message of type PingResponse: 
<DATE> DEBUG (MainThread) [aioesphomeapi.connection] <DEVICE> @ <IP>: Sending CoverCommandRequest: key: 3797311759
has_position: true
position: 1

<DATE> DEBUG (MainThread) [aioesphomeapi._frame_helper.base] <DEVICE> @ <IP>: Sending frame: [010020702c4484c546065eab4c5450623c410c4225f13a0846359aaf3c23b6ec4faaeb]
<DATE> DEBUG (MainThread) [aioesphomeapi.connection] <DEVICE> @ <IP>: Got message of type CoverStateResponse: key: 3797311759
legacy_state: LEGACY_COVER_STATE_CLOSED

<DATE> DEBUG (MainThread) [aioesphomeapi.connection] <DEVICE> @ <IP>: Got message of type CoverStateResponse: key: 3797311759
position: 1

<DATE> DEBUG (MainThread) [aioesphomeapi.connection] <DEVICE> @ <IP>: Sending CoverCommandRequest: key: 3797311759
has_position: true

<DATE> DEBUG (MainThread) [aioesphomeapi._frame_helper.base] <DEVICE> @ <IP>: Sending frame: [01001b34035d1db539eb367e59ac9b3b74f4759193fc18223b0e9321bd87]
<DATE> DEBUG (MainThread) [aioesphomeapi.connection] <DEVICE> @ <IP>: Got message of type CoverStateResponse: key: 3797311759
position: 1

<DATE> DEBUG (MainThread) [aioesphomeapi.connection] <DEVICE> @ <IP>: Got message of type CoverStateResponse: key: 3797311759
legacy_state: LEGACY_COVER_STATE_CLOSED