Add support for Shelly SHBTN-2 device triggers (#46644)

This commit is contained in:
CurrentThread 2021-02-26 11:52:47 +01:00 committed by GitHub
parent 5780615251
commit d5ee49cd4e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -111,7 +111,7 @@ def get_device_channel_name(
def is_momentary_input(settings: dict, block: aioshelly.Block) -> bool:
"""Return true if input button settings is set to a momentary type."""
# Shelly Button type is fixed to momentary and no btn_type
if settings["device"]["type"] == "SHBTN-1":
if settings["device"]["type"] in ("SHBTN-1", "SHBTN-2"):
return True
button = settings.get("relays") or settings.get("lights") or settings.get("inputs")
@ -158,7 +158,7 @@ def get_input_triggers(
else:
subtype = f"button{int(block.channel)+1}"
if device.settings["device"]["type"] == "SHBTN-1":
if device.settings["device"]["type"] in ("SHBTN-1", "SHBTN-2"):
trigger_types = SHBTN_1_INPUTS_EVENTS_TYPES
elif device.settings["device"]["type"] == "SHIX3-1":
trigger_types = SHIX3_1_INPUTS_EVENTS_TYPES