Fire a Lutron single press when the button reports only a release (#181094)

This commit is contained in:
rqi14
2026-09-02 18:11:59 +01:00
committed by GitHub
parent 0c5bac0896
commit 487f863245
2 changed files with 23 additions and 1 deletions
+2 -1
View File
@@ -94,7 +94,8 @@ class LutronEventEntity(LutronKeypad, EventEntity):
action = LutronEventType.PRESS
else:
action = LutronEventType.RELEASE
elif event == Button.Event.PRESSED:
elif event in (Button.Event.PRESSED, Button.Event.RELEASED):
# Buttons carrying a hold action report only a release, never a press.
action = LutronEventType.SINGLE_PRESS
if action:
+21
View File
@@ -93,3 +93,24 @@ async def test_event_press_release(
assert len(events) == 2
assert events[1].data["action"] == "released"
async def test_event_release_only_button(
hass: HomeAssistant, mock_lutron: MagicMock, mock_config_entry: MockConfigEntry
) -> None:
"""A button that only ever reports a release still fires a single press."""
mock_config_entry.add_to_hass(hass)
button = mock_lutron.areas[0].keypads[0].buttons[0]
await hass.config_entries.async_setup(mock_config_entry.entry_id)
await hass.async_block_till_done()
events = async_capture_events(hass, "lutron_event")
for call in button.subscribe.call_args_list:
callback = call[0][0]
callback(button, None, Button.Event.RELEASED, None)
await hass.async_block_till_done()
assert len(events) == 1
assert events[0].data["action"] == "single"