Use DeviceAutomationType in tests/components/[m-r]* (#62443)
parent
5926961ed5
commit
f913961d63
|
@ -2,6 +2,7 @@
|
|||
import pytest
|
||||
|
||||
import homeassistant.components.automation as automation
|
||||
from homeassistant.components.device_automation import DeviceAutomationType
|
||||
from homeassistant.components.media_player import DOMAIN
|
||||
from homeassistant.const import (
|
||||
STATE_IDLE,
|
||||
|
@ -88,7 +89,9 @@ async def test_get_conditions(hass, device_reg, entity_reg):
|
|||
"entity_id": f"{DOMAIN}.test_5678",
|
||||
},
|
||||
]
|
||||
conditions = await async_get_device_automations(hass, "condition", device_entry.id)
|
||||
conditions = await async_get_device_automations(
|
||||
hass, DeviceAutomationType.CONDITION, device_entry.id
|
||||
)
|
||||
assert_lists_same(conditions, expected_conditions)
|
||||
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ from datetime import timedelta
|
|||
import pytest
|
||||
|
||||
import homeassistant.components.automation as automation
|
||||
from homeassistant.components.device_automation import DeviceAutomationType
|
||||
from homeassistant.components.media_player import DOMAIN
|
||||
from homeassistant.const import (
|
||||
STATE_IDLE,
|
||||
|
@ -68,7 +69,9 @@ async def test_get_triggers(hass, device_reg, entity_reg):
|
|||
}
|
||||
for trigger in trigger_types
|
||||
]
|
||||
triggers = await async_get_device_automations(hass, "trigger", device_entry.id)
|
||||
triggers = await async_get_device_automations(
|
||||
hass, DeviceAutomationType.TRIGGER, device_entry.id
|
||||
)
|
||||
assert_lists_same(triggers, expected_triggers)
|
||||
|
||||
|
||||
|
@ -82,7 +85,9 @@ async def test_get_trigger_capabilities(hass, device_reg, entity_reg):
|
|||
)
|
||||
entity_reg.async_get_or_create(DOMAIN, "test", "5678", device_id=device_entry.id)
|
||||
|
||||
triggers = await async_get_device_automations(hass, "trigger", device_entry.id)
|
||||
triggers = await async_get_device_automations(
|
||||
hass, DeviceAutomationType.TRIGGER, device_entry.id
|
||||
)
|
||||
assert len(triggers) == 5
|
||||
for trigger in triggers:
|
||||
capabilities = await async_get_device_automation_capabilities(
|
||||
|
|
|
@ -11,9 +11,9 @@ async def test_get_actions(hass, push_registration):
|
|||
webhook_id = push_registration["webhook_id"]
|
||||
device_id = hass.data[DOMAIN][DATA_DEVICES][webhook_id].id
|
||||
|
||||
assert await async_get_device_automations(hass, "action", device_id) == [
|
||||
{"domain": DOMAIN, "device_id": device_id, "type": "notify"}
|
||||
]
|
||||
assert await async_get_device_automations(
|
||||
hass, device_automation.DeviceAutomationType.ACTION, device_id
|
||||
) == [{"domain": DOMAIN, "device_id": device_id, "type": "notify"}]
|
||||
|
||||
capabilitites = await device_automation._async_get_device_automation_capabilities(
|
||||
hass,
|
||||
|
|
|
@ -4,6 +4,7 @@ import json
|
|||
import pytest
|
||||
|
||||
import homeassistant.components.automation as automation
|
||||
from homeassistant.components.device_automation import DeviceAutomationType
|
||||
from homeassistant.components.mqtt import _LOGGER, DOMAIN, debug_info
|
||||
from homeassistant.helpers import device_registry as dr
|
||||
from homeassistant.helpers.trigger import async_initialize_triggers
|
||||
|
@ -62,7 +63,9 @@ async def test_get_triggers(hass, device_reg, entity_reg, mqtt_mock):
|
|||
"subtype": "button_1",
|
||||
},
|
||||
]
|
||||
triggers = await async_get_device_automations(hass, "trigger", device_entry.id)
|
||||
triggers = await async_get_device_automations(
|
||||
hass, DeviceAutomationType.TRIGGER, device_entry.id
|
||||
)
|
||||
assert_lists_same(triggers, expected_triggers)
|
||||
|
||||
|
||||
|
@ -102,7 +105,9 @@ async def test_get_unknown_triggers(hass, device_reg, entity_reg, mqtt_mock):
|
|||
},
|
||||
)
|
||||
|
||||
triggers = await async_get_device_automations(hass, "trigger", device_entry.id)
|
||||
triggers = await async_get_device_automations(
|
||||
hass, DeviceAutomationType.TRIGGER, device_entry.id
|
||||
)
|
||||
assert_lists_same(triggers, [])
|
||||
|
||||
|
||||
|
@ -118,7 +123,9 @@ async def test_get_non_existing_triggers(hass, device_reg, entity_reg, mqtt_mock
|
|||
await hass.async_block_till_done()
|
||||
|
||||
device_entry = device_reg.async_get_device({("mqtt", "0AFFD2")})
|
||||
triggers = await async_get_device_automations(hass, "trigger", device_entry.id)
|
||||
triggers = await async_get_device_automations(
|
||||
hass, DeviceAutomationType.TRIGGER, device_entry.id
|
||||
)
|
||||
assert_lists_same(triggers, [])
|
||||
|
||||
|
||||
|
@ -161,7 +168,9 @@ async def test_discover_bad_triggers(hass, device_reg, entity_reg, mqtt_mock):
|
|||
"subtype": "button_1",
|
||||
},
|
||||
]
|
||||
triggers = await async_get_device_automations(hass, "trigger", device_entry.id)
|
||||
triggers = await async_get_device_automations(
|
||||
hass, DeviceAutomationType.TRIGGER, device_entry.id
|
||||
)
|
||||
assert_lists_same(triggers, expected_triggers)
|
||||
|
||||
|
||||
|
@ -206,14 +215,18 @@ async def test_update_remove_triggers(hass, device_reg, entity_reg, mqtt_mock):
|
|||
expected_triggers2 = [dict(expected_triggers1[0])]
|
||||
expected_triggers2[0]["subtype"] = "button_2"
|
||||
|
||||
triggers = await async_get_device_automations(hass, "trigger", device_entry.id)
|
||||
triggers = await async_get_device_automations(
|
||||
hass, DeviceAutomationType.TRIGGER, device_entry.id
|
||||
)
|
||||
assert_lists_same(triggers, expected_triggers1)
|
||||
|
||||
# Update trigger
|
||||
async_fire_mqtt_message(hass, "homeassistant/device_automation/bla/config", data2)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
triggers = await async_get_device_automations(hass, "trigger", device_entry.id)
|
||||
triggers = await async_get_device_automations(
|
||||
hass, DeviceAutomationType.TRIGGER, device_entry.id
|
||||
)
|
||||
assert_lists_same(triggers, expected_triggers2)
|
||||
|
||||
# Remove trigger
|
||||
|
@ -972,7 +985,9 @@ async def test_cleanup_trigger(hass, device_reg, entity_reg, mqtt_mock):
|
|||
device_entry = device_reg.async_get_device({("mqtt", "helloworld")})
|
||||
assert device_entry is not None
|
||||
|
||||
triggers = await async_get_device_automations(hass, "trigger", device_entry.id)
|
||||
triggers = await async_get_device_automations(
|
||||
hass, DeviceAutomationType.TRIGGER, device_entry.id
|
||||
)
|
||||
assert triggers[0]["type"] == "foo"
|
||||
|
||||
device_reg.async_remove_device(device_entry.id)
|
||||
|
@ -1007,7 +1022,9 @@ async def test_cleanup_device(hass, device_reg, entity_reg, mqtt_mock):
|
|||
device_entry = device_reg.async_get_device({("mqtt", "helloworld")})
|
||||
assert device_entry is not None
|
||||
|
||||
triggers = await async_get_device_automations(hass, "trigger", device_entry.id)
|
||||
triggers = await async_get_device_automations(
|
||||
hass, DeviceAutomationType.TRIGGER, device_entry.id
|
||||
)
|
||||
assert triggers[0]["type"] == "foo"
|
||||
|
||||
async_fire_mqtt_message(hass, "homeassistant/device_automation/bla/config", "")
|
||||
|
@ -1047,7 +1064,9 @@ async def test_cleanup_device_several_triggers(hass, device_reg, entity_reg, mqt
|
|||
device_entry = device_reg.async_get_device({("mqtt", "helloworld")})
|
||||
assert device_entry is not None
|
||||
|
||||
triggers = await async_get_device_automations(hass, "trigger", device_entry.id)
|
||||
triggers = await async_get_device_automations(
|
||||
hass, DeviceAutomationType.TRIGGER, device_entry.id
|
||||
)
|
||||
assert len(triggers) == 2
|
||||
assert triggers[0]["type"] == "foo"
|
||||
assert triggers[1]["type"] == "foo2"
|
||||
|
@ -1059,7 +1078,9 @@ async def test_cleanup_device_several_triggers(hass, device_reg, entity_reg, mqt
|
|||
device_entry = device_reg.async_get_device({("mqtt", "helloworld")})
|
||||
assert device_entry is not None
|
||||
|
||||
triggers = await async_get_device_automations(hass, "trigger", device_entry.id)
|
||||
triggers = await async_get_device_automations(
|
||||
hass, DeviceAutomationType.TRIGGER, device_entry.id
|
||||
)
|
||||
assert len(triggers) == 1
|
||||
assert triggers[0]["type"] == "foo2"
|
||||
|
||||
|
@ -1102,7 +1123,9 @@ async def test_cleanup_device_with_entity1(hass, device_reg, entity_reg, mqtt_mo
|
|||
device_entry = device_reg.async_get_device({("mqtt", "helloworld")})
|
||||
assert device_entry is not None
|
||||
|
||||
triggers = await async_get_device_automations(hass, "trigger", device_entry.id)
|
||||
triggers = await async_get_device_automations(
|
||||
hass, DeviceAutomationType.TRIGGER, device_entry.id
|
||||
)
|
||||
assert len(triggers) == 3 # 2 binary_sensor triggers + device trigger
|
||||
|
||||
async_fire_mqtt_message(hass, "homeassistant/device_automation/bla1/config", "")
|
||||
|
@ -1112,7 +1135,9 @@ async def test_cleanup_device_with_entity1(hass, device_reg, entity_reg, mqtt_mo
|
|||
device_entry = device_reg.async_get_device({("mqtt", "helloworld")})
|
||||
assert device_entry is not None
|
||||
|
||||
triggers = await async_get_device_automations(hass, "trigger", device_entry.id)
|
||||
triggers = await async_get_device_automations(
|
||||
hass, DeviceAutomationType.TRIGGER, device_entry.id
|
||||
)
|
||||
assert len(triggers) == 2 # 2 binary_sensor triggers
|
||||
|
||||
async_fire_mqtt_message(hass, "homeassistant/binary_sensor/bla2/config", "")
|
||||
|
@ -1154,7 +1179,9 @@ async def test_cleanup_device_with_entity2(hass, device_reg, entity_reg, mqtt_mo
|
|||
device_entry = device_reg.async_get_device({("mqtt", "helloworld")})
|
||||
assert device_entry is not None
|
||||
|
||||
triggers = await async_get_device_automations(hass, "trigger", device_entry.id)
|
||||
triggers = await async_get_device_automations(
|
||||
hass, DeviceAutomationType.TRIGGER, device_entry.id
|
||||
)
|
||||
assert len(triggers) == 3 # 2 binary_sensor triggers + device trigger
|
||||
|
||||
async_fire_mqtt_message(hass, "homeassistant/binary_sensor/bla2/config", "")
|
||||
|
@ -1164,7 +1191,9 @@ async def test_cleanup_device_with_entity2(hass, device_reg, entity_reg, mqtt_mo
|
|||
device_entry = device_reg.async_get_device({("mqtt", "helloworld")})
|
||||
assert device_entry is not None
|
||||
|
||||
triggers = await async_get_device_automations(hass, "trigger", device_entry.id)
|
||||
triggers = await async_get_device_automations(
|
||||
hass, DeviceAutomationType.TRIGGER, device_entry.id
|
||||
)
|
||||
assert len(triggers) == 1 # device trigger
|
||||
|
||||
async_fire_mqtt_message(hass, "homeassistant/device_automation/bla1/config", "")
|
||||
|
|
|
@ -5,6 +5,7 @@ from unittest.mock import ANY, patch
|
|||
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.device_automation import DeviceAutomationType
|
||||
from homeassistant.helpers import device_registry as dr
|
||||
|
||||
from tests.common import (
|
||||
|
@ -609,7 +610,9 @@ async def test_cleanup_device_with_entity_and_trigger_1(
|
|||
device_entry = device_reg.async_get_device({("mqtt", "helloworld")})
|
||||
assert device_entry is not None
|
||||
|
||||
triggers = await async_get_device_automations(hass, "trigger", device_entry.id)
|
||||
triggers = await async_get_device_automations(
|
||||
hass, DeviceAutomationType.TRIGGER, device_entry.id
|
||||
)
|
||||
assert len(triggers) == 3 # 2 binary_sensor triggers + device trigger
|
||||
|
||||
async_fire_mqtt_message(hass, "homeassistant/tag/bla1/config", "")
|
||||
|
@ -669,7 +672,9 @@ async def test_cleanup_device_with_entity2(hass, device_reg, entity_reg, mqtt_mo
|
|||
device_entry = device_reg.async_get_device({("mqtt", "helloworld")})
|
||||
assert device_entry is not None
|
||||
|
||||
triggers = await async_get_device_automations(hass, "trigger", device_entry.id)
|
||||
triggers = await async_get_device_automations(
|
||||
hass, DeviceAutomationType.TRIGGER, device_entry.id
|
||||
)
|
||||
assert len(triggers) == 3 # 2 binary_sensor triggers + device trigger
|
||||
|
||||
async_fire_mqtt_message(hass, "homeassistant/device_automation/bla2/config", "")
|
||||
|
|
|
@ -4,6 +4,7 @@ from google_nest_sdm.event import EventMessage
|
|||
import pytest
|
||||
|
||||
import homeassistant.components.automation as automation
|
||||
from homeassistant.components.device_automation import DeviceAutomationType
|
||||
from homeassistant.components.device_automation.exceptions import (
|
||||
InvalidDeviceAutomationConfig,
|
||||
)
|
||||
|
@ -119,7 +120,9 @@ async def test_get_triggers(hass):
|
|||
"device_id": device_entry.id,
|
||||
},
|
||||
]
|
||||
triggers = await async_get_device_automations(hass, "trigger", device_entry.id)
|
||||
triggers = await async_get_device_automations(
|
||||
hass, DeviceAutomationType.TRIGGER, device_entry.id
|
||||
)
|
||||
assert_lists_same(triggers, expected_triggers)
|
||||
|
||||
|
||||
|
@ -147,7 +150,9 @@ async def test_multiple_devices(hass):
|
|||
entry2 = registry.async_get("camera.camera_2")
|
||||
assert entry2.unique_id == "device-id-2-camera"
|
||||
|
||||
triggers = await async_get_device_automations(hass, "trigger", entry1.device_id)
|
||||
triggers = await async_get_device_automations(
|
||||
hass, DeviceAutomationType.TRIGGER, entry1.device_id
|
||||
)
|
||||
assert len(triggers) == 1
|
||||
assert triggers[0] == {
|
||||
"platform": "device",
|
||||
|
@ -156,7 +161,9 @@ async def test_multiple_devices(hass):
|
|||
"device_id": entry1.device_id,
|
||||
}
|
||||
|
||||
triggers = await async_get_device_automations(hass, "trigger", entry2.device_id)
|
||||
triggers = await async_get_device_automations(
|
||||
hass, DeviceAutomationType.TRIGGER, entry2.device_id
|
||||
)
|
||||
assert len(triggers) == 1
|
||||
assert triggers[0] == {
|
||||
"platform": "device",
|
||||
|
@ -191,7 +198,9 @@ async def test_triggers_for_invalid_device_id(hass):
|
|||
assert device_entry_2 is not None
|
||||
|
||||
with pytest.raises(InvalidDeviceAutomationConfig):
|
||||
await async_get_device_automations(hass, "trigger", device_entry_2.id)
|
||||
await async_get_device_automations(
|
||||
hass, DeviceAutomationType.TRIGGER, device_entry_2.id
|
||||
)
|
||||
|
||||
|
||||
async def test_no_triggers(hass):
|
||||
|
@ -203,7 +212,9 @@ async def test_no_triggers(hass):
|
|||
entry = registry.async_get("camera.my_camera")
|
||||
assert entry.unique_id == "some-device-id-camera"
|
||||
|
||||
triggers = await async_get_device_automations(hass, "trigger", entry.device_id)
|
||||
triggers = await async_get_device_automations(
|
||||
hass, DeviceAutomationType.TRIGGER, entry.device_id
|
||||
)
|
||||
assert triggers == []
|
||||
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
import pytest
|
||||
|
||||
import homeassistant.components.automation as automation
|
||||
from homeassistant.components.device_automation import DeviceAutomationType
|
||||
from homeassistant.components.netatmo import DOMAIN as NETATMO_DOMAIN
|
||||
from homeassistant.components.netatmo.const import (
|
||||
CLIMATE_TRIGGERS,
|
||||
|
@ -98,7 +99,7 @@ async def test_get_triggers(
|
|||
triggers = [
|
||||
trigger
|
||||
for trigger in await async_get_device_automations(
|
||||
hass, "trigger", device_entry.id
|
||||
hass, DeviceAutomationType.TRIGGER, device_entry.id
|
||||
)
|
||||
if trigger["domain"] == NETATMO_DOMAIN
|
||||
]
|
||||
|
|
|
@ -3,6 +3,7 @@ import pytest
|
|||
import voluptuous_serialize
|
||||
|
||||
import homeassistant.components.automation as automation
|
||||
from homeassistant.components.device_automation import DeviceAutomationType
|
||||
from homeassistant.components.number import DOMAIN, device_action
|
||||
from homeassistant.helpers import config_validation as cv, device_registry
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
@ -48,7 +49,9 @@ async def test_get_actions(hass, device_reg, entity_reg):
|
|||
"entity_id": "number.test_5678",
|
||||
},
|
||||
]
|
||||
actions = await async_get_device_automations(hass, "action", device_entry.id)
|
||||
actions = await async_get_device_automations(
|
||||
hass, DeviceAutomationType.ACTION, device_entry.id
|
||||
)
|
||||
assert_lists_same(actions, expected_actions)
|
||||
|
||||
|
||||
|
@ -69,7 +72,9 @@ async def test_get_action_no_state(hass, device_reg, entity_reg):
|
|||
"entity_id": "number.test_5678",
|
||||
},
|
||||
]
|
||||
actions = await async_get_device_automations(hass, "action", device_entry.id)
|
||||
actions = await async_get_device_automations(
|
||||
hass, DeviceAutomationType.ACTION, device_entry.id
|
||||
)
|
||||
assert_lists_same(actions, expected_actions)
|
||||
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
import pytest
|
||||
|
||||
import homeassistant.components.automation as automation
|
||||
from homeassistant.components.device_automation import DeviceAutomationType
|
||||
from homeassistant.components.philips_js.const import DOMAIN
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
|
@ -29,7 +30,9 @@ async def test_get_triggers(hass, mock_device):
|
|||
"device_id": mock_device.id,
|
||||
},
|
||||
]
|
||||
triggers = await async_get_device_automations(hass, "trigger", mock_device.id)
|
||||
triggers = await async_get_device_automations(
|
||||
hass, DeviceAutomationType.TRIGGER, mock_device.id
|
||||
)
|
||||
assert_lists_same(triggers, expected_triggers)
|
||||
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
import pytest
|
||||
|
||||
import homeassistant.components.automation as automation
|
||||
from homeassistant.components.device_automation import DeviceAutomationType
|
||||
from homeassistant.components.remote import DOMAIN
|
||||
from homeassistant.const import CONF_PLATFORM, STATE_OFF, STATE_ON
|
||||
from homeassistant.helpers import device_registry
|
||||
|
@ -64,7 +65,9 @@ async def test_get_actions(hass, device_reg, entity_reg):
|
|||
"entity_id": f"{DOMAIN}.test_5678",
|
||||
},
|
||||
]
|
||||
actions = await async_get_device_automations(hass, "action", device_entry.id)
|
||||
actions = await async_get_device_automations(
|
||||
hass, DeviceAutomationType.ACTION, device_entry.id
|
||||
)
|
||||
assert actions == expected_actions
|
||||
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ from unittest.mock import patch
|
|||
import pytest
|
||||
|
||||
import homeassistant.components.automation as automation
|
||||
from homeassistant.components.device_automation import DeviceAutomationType
|
||||
from homeassistant.components.remote import DOMAIN
|
||||
from homeassistant.const import CONF_PLATFORM, STATE_OFF, STATE_ON
|
||||
from homeassistant.helpers import device_registry
|
||||
|
@ -65,7 +66,9 @@ async def test_get_conditions(hass, device_reg, entity_reg):
|
|||
"entity_id": f"{DOMAIN}.test_5678",
|
||||
},
|
||||
]
|
||||
conditions = await async_get_device_automations(hass, "condition", device_entry.id)
|
||||
conditions = await async_get_device_automations(
|
||||
hass, DeviceAutomationType.CONDITION, device_entry.id
|
||||
)
|
||||
assert conditions == expected_conditions
|
||||
|
||||
|
||||
|
@ -83,10 +86,12 @@ async def test_get_condition_capabilities(hass, device_reg, entity_reg):
|
|||
{"name": "for", "optional": True, "type": "positive_time_period_dict"}
|
||||
]
|
||||
}
|
||||
conditions = await async_get_device_automations(hass, "condition", device_entry.id)
|
||||
conditions = await async_get_device_automations(
|
||||
hass, DeviceAutomationType.CONDITION, device_entry.id
|
||||
)
|
||||
for condition in conditions:
|
||||
capabilities = await async_get_device_automation_capabilities(
|
||||
hass, "condition", condition
|
||||
hass, DeviceAutomationType.CONDITION, condition
|
||||
)
|
||||
assert capabilities == expected_capabilities
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ from datetime import timedelta
|
|||
import pytest
|
||||
|
||||
import homeassistant.components.automation as automation
|
||||
from homeassistant.components.device_automation import DeviceAutomationType
|
||||
from homeassistant.components.remote import DOMAIN
|
||||
from homeassistant.const import CONF_PLATFORM, STATE_OFF, STATE_ON
|
||||
from homeassistant.helpers import device_registry
|
||||
|
@ -65,7 +66,9 @@ async def test_get_triggers(hass, device_reg, entity_reg):
|
|||
"entity_id": f"{DOMAIN}.test_5678",
|
||||
},
|
||||
]
|
||||
triggers = await async_get_device_automations(hass, "trigger", device_entry.id)
|
||||
triggers = await async_get_device_automations(
|
||||
hass, DeviceAutomationType.TRIGGER, device_entry.id
|
||||
)
|
||||
assert triggers == expected_triggers
|
||||
|
||||
|
||||
|
@ -83,10 +86,12 @@ async def test_get_trigger_capabilities(hass, device_reg, entity_reg):
|
|||
{"name": "for", "optional": True, "type": "positive_time_period_dict"}
|
||||
]
|
||||
}
|
||||
triggers = await async_get_device_automations(hass, "trigger", device_entry.id)
|
||||
triggers = await async_get_device_automations(
|
||||
hass, DeviceAutomationType.TRIGGER, device_entry.id
|
||||
)
|
||||
for trigger in triggers:
|
||||
capabilities = await async_get_device_automation_capabilities(
|
||||
hass, "trigger", trigger
|
||||
hass, DeviceAutomationType.TRIGGER, trigger
|
||||
)
|
||||
assert capabilities == expected_capabilities
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ import RFXtrx
|
|||
import pytest
|
||||
|
||||
import homeassistant.components.automation as automation
|
||||
from homeassistant.components.device_automation import DeviceAutomationType
|
||||
from homeassistant.components.rfxtrx import DOMAIN
|
||||
from homeassistant.helpers.device_registry import DeviceRegistry
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
@ -98,7 +99,9 @@ async def test_get_actions(hass, device_reg: DeviceRegistry, device, expected):
|
|||
device_entry = device_reg.async_get_device(device.device_identifiers, set())
|
||||
assert device_entry
|
||||
|
||||
actions = await async_get_device_automations(hass, "action", device_entry.id)
|
||||
actions = await async_get_device_automations(
|
||||
hass, DeviceAutomationType.ACTION, device_entry.id
|
||||
)
|
||||
actions = [action for action in actions if action["domain"] == DOMAIN]
|
||||
|
||||
expected_actions = [
|
||||
|
|
|
@ -6,6 +6,7 @@ from typing import Any, NamedTuple
|
|||
import pytest
|
||||
|
||||
import homeassistant.components.automation as automation
|
||||
from homeassistant.components.device_automation import DeviceAutomationType
|
||||
from homeassistant.components.rfxtrx import DOMAIN
|
||||
from homeassistant.helpers.device_registry import DeviceRegistry
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
@ -93,7 +94,9 @@ async def test_get_triggers(hass, device_reg, event: EventTestData, expected):
|
|||
for expect in expected
|
||||
]
|
||||
|
||||
triggers = await async_get_device_automations(hass, "trigger", device_entry.id)
|
||||
triggers = await async_get_device_automations(
|
||||
hass, DeviceAutomationType.TRIGGER, device_entry.id
|
||||
)
|
||||
triggers = [value for value in triggers if value["domain"] == "rfxtrx"]
|
||||
assert_lists_same(triggers, expected_triggers)
|
||||
|
||||
|
|
Loading…
Reference in New Issue