mirror of
https://github.com/home-assistant/core.git
synced 2026-09-25 17:04:04 -04:00
Fire a Lutron single press when the button reports only a release (#181094)
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user