diff --git a/esphome/components/cover/automation.h b/esphome/components/cover/automation.h index 223c7644ea..e056a11ea5 100644 --- a/esphome/components/cover/automation.h +++ b/esphome/components/cover/automation.h @@ -51,8 +51,9 @@ namespace cover_action_detail { template struct Empty {}; } // namespace cover_action_detail -// X-macro: (type, field_name, bit_index). Order/bits must match -// cover_control_to_code's FIELDS table in __init__.py. +// X-macro: (type, field_name, bit_index). Order/bits must match the +// inline field-mask computation in cover_control_to_code in __init__.py: +// stop=bit 0, position=bit 1 (also set by CONF_STATE), tilt=bit 2. #define COVER_CONTROL_FIELDS(X) \ X(bool, stop, 0) \ X(float, position, 1) \ @@ -86,8 +87,10 @@ template class ControlAction : public Action IDLE + - platform: template + id: btn_stop + name: "Stop Cover" + on_press: + - cover.control: + id: test_cover + stop: true diff --git a/tests/integration/test_cover_control_action.py b/tests/integration/test_cover_control_action.py index 206079ca89..29ece37ce5 100644 --- a/tests/integration/test_cover_control_action.py +++ b/tests/integration/test_cover_control_action.py @@ -84,3 +84,9 @@ async def test_cover_control_action( state = await press_and_wait("Publish Op") # CoverOperation.OPENING == 1 assert state.current_operation == 1 + + # Test 8: cover.control stop only (mask 1) + # The template cover's stop_action publishes current_operation: IDLE + state = await press_and_wait("Stop Cover") + # CoverOperation.IDLE == 0 + assert state.current_operation == 0