From 577be399a639085aeb2e4535a52be24f6e391552 Mon Sep 17 00:00:00 2001 From: Maciej Bieniek Date: Tue, 14 Feb 2023 13:59:59 +0100 Subject: [PATCH 1/3] Add support for triple_push event --- homeassistant/components/shelly/const.py | 1 + homeassistant/components/shelly/strings.json | 1 + tests/components/shelly/test_device_trigger.py | 9 ++++++++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/shelly/const.py b/homeassistant/components/shelly/const.py index 41656bbcd6fc0f..b59607780a79cb 100644 --- a/homeassistant/components/shelly/const.py +++ b/homeassistant/components/shelly/const.py @@ -103,6 +103,7 @@ "single_push", "double_push", "long_push", + "triple_push", } BLOCK_INPUTS_EVENTS_TYPES: Final = { diff --git a/homeassistant/components/shelly/strings.json b/homeassistant/components/shelly/strings.json index 1f05364ca3e252..62a43c5bbc0dbc 100644 --- a/homeassistant/components/shelly/strings.json +++ b/homeassistant/components/shelly/strings.json @@ -56,6 +56,7 @@ "btn_up": "{subtype} button up", "single_push": "{subtype} single push", "double_push": "{subtype} double push", + "triple_push": "{subtype} triple push", "long_push": "{subtype} long push" } }, diff --git a/tests/components/shelly/test_device_trigger.py b/tests/components/shelly/test_device_trigger.py index 31e54545b288a3..779e57008fe42e 100644 --- a/tests/components/shelly/test_device_trigger.py +++ b/tests/components/shelly/test_device_trigger.py @@ -91,7 +91,14 @@ async def test_get_triggers_rpc_device(hass, mock_rpc_device): CONF_SUBTYPE: "button1", "metadata": {}, } - for type in ["btn_down", "btn_up", "single_push", "double_push", "long_push"] + for type in [ + "btn_down", + "btn_up", + "single_push", + "double_push", + "long_push", + "triple_push", + ] ] triggers = await async_get_device_automations( From befb623a6d0137e2551496c609f62b162ef50807 Mon Sep 17 00:00:00 2001 From: Maciej Bieniek Date: Tue, 14 Feb 2023 14:04:05 +0100 Subject: [PATCH 2/3] Sort --- homeassistant/components/shelly/const.py | 2 +- tests/components/shelly/test_device_trigger.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/shelly/const.py b/homeassistant/components/shelly/const.py index b59607780a79cb..7aa86af1e9a957 100644 --- a/homeassistant/components/shelly/const.py +++ b/homeassistant/components/shelly/const.py @@ -102,8 +102,8 @@ "btn_up", "single_push", "double_push", - "long_push", "triple_push", + "long_push", } BLOCK_INPUTS_EVENTS_TYPES: Final = { diff --git a/tests/components/shelly/test_device_trigger.py b/tests/components/shelly/test_device_trigger.py index 779e57008fe42e..aab81c9ce5ef20 100644 --- a/tests/components/shelly/test_device_trigger.py +++ b/tests/components/shelly/test_device_trigger.py @@ -96,8 +96,8 @@ async def test_get_triggers_rpc_device(hass, mock_rpc_device): "btn_up", "single_push", "double_push", - "long_push", "triple_push", + "long_push", ] ] From ddf5ed76cb87f3dd09abefcfe0c52fd0164ca47c Mon Sep 17 00:00:00 2001 From: Maciej Bieniek Date: Tue, 14 Feb 2023 14:17:24 +0100 Subject: [PATCH 3/3] Fix tests --- tests/components/shelly/test_utils.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/components/shelly/test_utils.py b/tests/components/shelly/test_utils.py index d3eae71e5e39da..de21ab84573209 100644 --- a/tests/components/shelly/test_utils.py +++ b/tests/components/shelly/test_utils.py @@ -215,11 +215,12 @@ async def test_get_rpc_input_triggers(mock_rpc_device, monkeypatch): """Test get RPC input triggers.""" monkeypatch.setattr(mock_rpc_device, "config", {"input:0": {"type": "button"}}) assert set(get_rpc_input_triggers(mock_rpc_device)) == { - ("long_push", "button1"), - ("single_push", "button1"), ("btn_down", "button1"), - ("double_push", "button1"), ("btn_up", "button1"), + ("single_push", "button1"), + ("double_push", "button1"), + ("triple_push", "button1"), + ("long_push", "button1"), } monkeypatch.setattr(mock_rpc_device, "config", {"input:0": {"type": "switch"}})