Fix Shelly button device triggers (#48974)
This commit is contained in:
parent
9b0b2d9168
commit
98396e13af
2 changed files with 85 additions and 1 deletions
|
@ -27,6 +27,7 @@ from .const import (
|
|||
DOMAIN,
|
||||
EVENT_SHELLY_CLICK,
|
||||
INPUTS_EVENTS_SUBTYPES,
|
||||
SHBTN_1_INPUTS_EVENTS_TYPES,
|
||||
SUPPORTED_INPUTS_EVENTS_TYPES,
|
||||
)
|
||||
from .utils import get_device_wrapper, get_input_triggers
|
||||
|
@ -45,7 +46,7 @@ async def async_validate_trigger_config(hass, config):
|
|||
|
||||
# if device is available verify parameters against device capabilities
|
||||
wrapper = get_device_wrapper(hass, config[CONF_DEVICE_ID])
|
||||
if not wrapper:
|
||||
if not wrapper or not wrapper.device.initialized:
|
||||
return config
|
||||
|
||||
trigger = (config[CONF_TYPE], config[CONF_SUBTYPE])
|
||||
|
@ -68,6 +69,19 @@ async def async_get_triggers(hass: HomeAssistant, device_id: str) -> list[dict]:
|
|||
if not wrapper:
|
||||
raise InvalidDeviceAutomationConfig(f"Device not found: {device_id}")
|
||||
|
||||
if wrapper.model in ("SHBTN-1", "SHBTN-2"):
|
||||
for trigger in SHBTN_1_INPUTS_EVENTS_TYPES:
|
||||
triggers.append(
|
||||
{
|
||||
CONF_PLATFORM: "device",
|
||||
CONF_DEVICE_ID: device_id,
|
||||
CONF_DOMAIN: DOMAIN,
|
||||
CONF_TYPE: trigger,
|
||||
CONF_SUBTYPE: "button",
|
||||
}
|
||||
)
|
||||
return triggers
|
||||
|
||||
for block in wrapper.device.blocks:
|
||||
input_triggers = get_input_triggers(wrapper.device, block)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue