diff --git a/homeassistant/helpers/trigger.py b/homeassistant/helpers/trigger.py index b5a82c3c0202f0de4a7a51fc1168fa019e3827b6..29f344a6fa022a4c5d6d5cb8382e6194acb3f5bf 100644 --- a/homeassistant/helpers/trigger.py +++ b/homeassistant/helpers/trigger.py @@ -21,7 +21,8 @@ _PLATFORM_ALIASES = { async def _async_get_trigger_platform(hass: HomeAssistant, config: ConfigType) -> Any: - platform = config[CONF_PLATFORM] + platform_and_sub_type = config[CONF_PLATFORM].split(".") + platform = platform_and_sub_type[0] for alias, triggers in _PLATFORM_ALIASES.items(): if platform in triggers: platform = alias diff --git a/tests/helpers/test_trigger.py b/tests/helpers/test_trigger.py index b4bfb881186518d5664688418c8953315776699c..7afdb629792b9155eafcc2bd725b88883f479db9 100644 --- a/tests/helpers/test_trigger.py +++ b/tests/helpers/test_trigger.py @@ -1,8 +1,13 @@ """The tests for the trigger helper.""" +from unittest.mock import MagicMock, call, patch + import pytest import voluptuous as vol -from homeassistant.helpers.trigger import async_validate_trigger_config +from homeassistant.helpers.trigger import ( + _async_get_trigger_platform, + async_validate_trigger_config, +) async def test_bad_trigger_platform(hass): @@ -10,3 +15,12 @@ async def test_bad_trigger_platform(hass): with pytest.raises(vol.Invalid) as ex: await async_validate_trigger_config(hass, [{"platform": "not_a_platform"}]) assert "Invalid platform 'not_a_platform' specified" in str(ex) + + +async def test_trigger_subtype(hass): + """Test trigger subtypes.""" + with patch( + "homeassistant.helpers.trigger.async_get_integration", return_value=MagicMock() + ) as integration_mock: + await _async_get_trigger_platform(hass, {"platform": "test.subtype"}) + assert integration_mock.call_args == call(hass, "test")