Mark device conditions from hidden or auxiliary entities as secondary (#70333)
This commit is contained in:
parent
7c0b0f7cc1
commit
150f173eed
18 changed files with 800 additions and 95 deletions
|
@ -265,7 +265,10 @@ async def async_get_device_automations(
|
||||||
)
|
)
|
||||||
continue
|
continue
|
||||||
for automation in device_results:
|
for automation in device_results:
|
||||||
if automation_type == DeviceAutomationType.ACTION:
|
if automation_type in (
|
||||||
|
DeviceAutomationType.ACTION,
|
||||||
|
DeviceAutomationType.CONDITION,
|
||||||
|
):
|
||||||
_async_set_entity_device_automation_metadata(hass, automation)
|
_async_set_entity_device_automation_metadata(hass, automation)
|
||||||
combined_results[automation["device_id"]].append(automation)
|
combined_results[automation["device_id"]].append(automation)
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,8 @@ from homeassistant.const import (
|
||||||
STATE_ALARM_TRIGGERED,
|
STATE_ALARM_TRIGGERED,
|
||||||
)
|
)
|
||||||
from homeassistant.helpers import device_registry
|
from homeassistant.helpers import device_registry
|
||||||
|
from homeassistant.helpers.entity import EntityCategory
|
||||||
|
from homeassistant.helpers.entity_registry import RegistryEntryHider
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
|
|
||||||
from tests.common import (
|
from tests.common import (
|
||||||
|
@ -120,6 +122,7 @@ async def test_get_conditions(
|
||||||
"type": condition,
|
"type": condition,
|
||||||
"device_id": device_entry.id,
|
"device_id": device_entry.id,
|
||||||
"entity_id": f"{DOMAIN}.test_5678",
|
"entity_id": f"{DOMAIN}.test_5678",
|
||||||
|
"metadata": {"secondary": False},
|
||||||
}
|
}
|
||||||
for condition in basic_condition_types
|
for condition in basic_condition_types
|
||||||
]
|
]
|
||||||
|
@ -130,6 +133,7 @@ async def test_get_conditions(
|
||||||
"type": condition,
|
"type": condition,
|
||||||
"device_id": device_entry.id,
|
"device_id": device_entry.id,
|
||||||
"entity_id": f"{DOMAIN}.test_5678",
|
"entity_id": f"{DOMAIN}.test_5678",
|
||||||
|
"metadata": {"secondary": False},
|
||||||
}
|
}
|
||||||
for condition in expected_condition_types
|
for condition in expected_condition_types
|
||||||
]
|
]
|
||||||
|
@ -139,6 +143,54 @@ async def test_get_conditions(
|
||||||
assert_lists_same(conditions, expected_conditions)
|
assert_lists_same(conditions, expected_conditions)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
"hidden_by,entity_category",
|
||||||
|
(
|
||||||
|
(RegistryEntryHider.INTEGRATION, None),
|
||||||
|
(RegistryEntryHider.USER, None),
|
||||||
|
(None, EntityCategory.CONFIG),
|
||||||
|
(None, EntityCategory.DIAGNOSTIC),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
async def test_get_conditions_hidden_auxiliary(
|
||||||
|
hass,
|
||||||
|
device_reg,
|
||||||
|
entity_reg,
|
||||||
|
hidden_by,
|
||||||
|
entity_category,
|
||||||
|
):
|
||||||
|
"""Test we get the expected conditions from a hidden or auxiliary entity."""
|
||||||
|
config_entry = MockConfigEntry(domain="test", data={})
|
||||||
|
config_entry.add_to_hass(hass)
|
||||||
|
device_entry = device_reg.async_get_or_create(
|
||||||
|
config_entry_id=config_entry.entry_id,
|
||||||
|
connections={(device_registry.CONNECTION_NETWORK_MAC, "12:34:56:AB:CD:EF")},
|
||||||
|
)
|
||||||
|
entity_reg.async_get_or_create(
|
||||||
|
DOMAIN,
|
||||||
|
"test",
|
||||||
|
"5678",
|
||||||
|
device_id=device_entry.id,
|
||||||
|
entity_category=entity_category,
|
||||||
|
hidden_by=hidden_by,
|
||||||
|
)
|
||||||
|
expected_conditions = [
|
||||||
|
{
|
||||||
|
"condition": "device",
|
||||||
|
"domain": DOMAIN,
|
||||||
|
"type": condition,
|
||||||
|
"device_id": device_entry.id,
|
||||||
|
"entity_id": f"{DOMAIN}.test_5678",
|
||||||
|
"metadata": {"secondary": True},
|
||||||
|
}
|
||||||
|
for condition in ["is_disarmed", "is_triggered"]
|
||||||
|
]
|
||||||
|
conditions = await async_get_device_automations(
|
||||||
|
hass, DeviceAutomationType.CONDITION, device_entry.id
|
||||||
|
)
|
||||||
|
assert_lists_same(conditions, expected_conditions)
|
||||||
|
|
||||||
|
|
||||||
async def test_if_state(hass, calls):
|
async def test_if_state(hass, calls):
|
||||||
"""Test for all conditions."""
|
"""Test for all conditions."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
|
|
@ -10,11 +10,14 @@ from homeassistant.components.binary_sensor.device_condition import ENTITY_CONDI
|
||||||
from homeassistant.components.device_automation import DeviceAutomationType
|
from homeassistant.components.device_automation import DeviceAutomationType
|
||||||
from homeassistant.const import CONF_PLATFORM, STATE_OFF, STATE_ON
|
from homeassistant.const import CONF_PLATFORM, STATE_OFF, STATE_ON
|
||||||
from homeassistant.helpers import device_registry
|
from homeassistant.helpers import device_registry
|
||||||
|
from homeassistant.helpers.entity import EntityCategory
|
||||||
|
from homeassistant.helpers.entity_registry import RegistryEntryHider
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
import homeassistant.util.dt as dt_util
|
import homeassistant.util.dt as dt_util
|
||||||
|
|
||||||
from tests.common import (
|
from tests.common import (
|
||||||
MockConfigEntry,
|
MockConfigEntry,
|
||||||
|
assert_lists_same,
|
||||||
async_get_device_automation_capabilities,
|
async_get_device_automation_capabilities,
|
||||||
async_get_device_automations,
|
async_get_device_automations,
|
||||||
async_mock_service,
|
async_mock_service,
|
||||||
|
@ -71,6 +74,7 @@ async def test_get_conditions(hass, device_reg, entity_reg, enable_custom_integr
|
||||||
"type": condition["type"],
|
"type": condition["type"],
|
||||||
"device_id": device_entry.id,
|
"device_id": device_entry.id,
|
||||||
"entity_id": platform.ENTITIES[device_class].entity_id,
|
"entity_id": platform.ENTITIES[device_class].entity_id,
|
||||||
|
"metadata": {"secondary": False},
|
||||||
}
|
}
|
||||||
for device_class in BinarySensorDeviceClass
|
for device_class in BinarySensorDeviceClass
|
||||||
for condition in ENTITY_CONDITIONS[device_class]
|
for condition in ENTITY_CONDITIONS[device_class]
|
||||||
|
@ -78,7 +82,55 @@ async def test_get_conditions(hass, device_reg, entity_reg, enable_custom_integr
|
||||||
conditions = await async_get_device_automations(
|
conditions = await async_get_device_automations(
|
||||||
hass, DeviceAutomationType.CONDITION, device_entry.id
|
hass, DeviceAutomationType.CONDITION, device_entry.id
|
||||||
)
|
)
|
||||||
assert conditions == expected_conditions
|
assert_lists_same(conditions, expected_conditions)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
"hidden_by,entity_category",
|
||||||
|
(
|
||||||
|
(RegistryEntryHider.INTEGRATION, None),
|
||||||
|
(RegistryEntryHider.USER, None),
|
||||||
|
(None, EntityCategory.CONFIG),
|
||||||
|
(None, EntityCategory.DIAGNOSTIC),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
async def test_get_conditions_hidden_auxiliary(
|
||||||
|
hass,
|
||||||
|
device_reg,
|
||||||
|
entity_reg,
|
||||||
|
hidden_by,
|
||||||
|
entity_category,
|
||||||
|
):
|
||||||
|
"""Test we get the expected conditions from a hidden or auxiliary entity."""
|
||||||
|
config_entry = MockConfigEntry(domain="test", data={})
|
||||||
|
config_entry.add_to_hass(hass)
|
||||||
|
device_entry = device_reg.async_get_or_create(
|
||||||
|
config_entry_id=config_entry.entry_id,
|
||||||
|
connections={(device_registry.CONNECTION_NETWORK_MAC, "12:34:56:AB:CD:EF")},
|
||||||
|
)
|
||||||
|
entity_reg.async_get_or_create(
|
||||||
|
DOMAIN,
|
||||||
|
"test",
|
||||||
|
"5678",
|
||||||
|
device_id=device_entry.id,
|
||||||
|
entity_category=entity_category,
|
||||||
|
hidden_by=hidden_by,
|
||||||
|
)
|
||||||
|
expected_conditions = [
|
||||||
|
{
|
||||||
|
"condition": "device",
|
||||||
|
"domain": DOMAIN,
|
||||||
|
"type": condition,
|
||||||
|
"device_id": device_entry.id,
|
||||||
|
"entity_id": f"{DOMAIN}.test_5678",
|
||||||
|
"metadata": {"secondary": True},
|
||||||
|
}
|
||||||
|
for condition in ["is_on", "is_off"]
|
||||||
|
]
|
||||||
|
conditions = await async_get_device_automations(
|
||||||
|
hass, DeviceAutomationType.CONDITION, device_entry.id
|
||||||
|
)
|
||||||
|
assert_lists_same(conditions, expected_conditions)
|
||||||
|
|
||||||
|
|
||||||
async def test_get_conditions_no_state(hass, device_reg, entity_reg):
|
async def test_get_conditions_no_state(hass, device_reg, entity_reg):
|
||||||
|
@ -108,6 +160,7 @@ async def test_get_conditions_no_state(hass, device_reg, entity_reg):
|
||||||
"type": condition["type"],
|
"type": condition["type"],
|
||||||
"device_id": device_entry.id,
|
"device_id": device_entry.id,
|
||||||
"entity_id": entity_ids[device_class],
|
"entity_id": entity_ids[device_class],
|
||||||
|
"metadata": {"secondary": False},
|
||||||
}
|
}
|
||||||
for device_class in BinarySensorDeviceClass
|
for device_class in BinarySensorDeviceClass
|
||||||
for condition in ENTITY_CONDITIONS[device_class]
|
for condition in ENTITY_CONDITIONS[device_class]
|
||||||
|
|
|
@ -6,6 +6,8 @@ import homeassistant.components.automation as automation
|
||||||
from homeassistant.components.climate import DOMAIN, const, device_condition
|
from homeassistant.components.climate import DOMAIN, const, device_condition
|
||||||
from homeassistant.components.device_automation import DeviceAutomationType
|
from homeassistant.components.device_automation import DeviceAutomationType
|
||||||
from homeassistant.helpers import config_validation as cv, device_registry
|
from homeassistant.helpers import config_validation as cv, device_registry
|
||||||
|
from homeassistant.helpers.entity import EntityCategory
|
||||||
|
from homeassistant.helpers.entity_registry import RegistryEntryHider
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
|
|
||||||
from tests.common import (
|
from tests.common import (
|
||||||
|
@ -91,6 +93,7 @@ async def test_get_conditions(
|
||||||
"type": condition,
|
"type": condition,
|
||||||
"device_id": device_entry.id,
|
"device_id": device_entry.id,
|
||||||
"entity_id": f"{DOMAIN}.test_5678",
|
"entity_id": f"{DOMAIN}.test_5678",
|
||||||
|
"metadata": {"secondary": False},
|
||||||
}
|
}
|
||||||
for condition in expected_condition_types
|
for condition in expected_condition_types
|
||||||
]
|
]
|
||||||
|
@ -100,6 +103,54 @@ async def test_get_conditions(
|
||||||
assert_lists_same(conditions, expected_conditions)
|
assert_lists_same(conditions, expected_conditions)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
"hidden_by,entity_category",
|
||||||
|
(
|
||||||
|
(RegistryEntryHider.INTEGRATION, None),
|
||||||
|
(RegistryEntryHider.USER, None),
|
||||||
|
(None, EntityCategory.CONFIG),
|
||||||
|
(None, EntityCategory.DIAGNOSTIC),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
async def test_get_conditions_hidden_auxiliary(
|
||||||
|
hass,
|
||||||
|
device_reg,
|
||||||
|
entity_reg,
|
||||||
|
hidden_by,
|
||||||
|
entity_category,
|
||||||
|
):
|
||||||
|
"""Test we get the expected conditions from a hidden or auxiliary entity."""
|
||||||
|
config_entry = MockConfigEntry(domain="test", data={})
|
||||||
|
config_entry.add_to_hass(hass)
|
||||||
|
device_entry = device_reg.async_get_or_create(
|
||||||
|
config_entry_id=config_entry.entry_id,
|
||||||
|
connections={(device_registry.CONNECTION_NETWORK_MAC, "12:34:56:AB:CD:EF")},
|
||||||
|
)
|
||||||
|
entity_reg.async_get_or_create(
|
||||||
|
DOMAIN,
|
||||||
|
"test",
|
||||||
|
"5678",
|
||||||
|
device_id=device_entry.id,
|
||||||
|
entity_category=entity_category,
|
||||||
|
hidden_by=hidden_by,
|
||||||
|
)
|
||||||
|
expected_conditions = [
|
||||||
|
{
|
||||||
|
"condition": "device",
|
||||||
|
"domain": DOMAIN,
|
||||||
|
"type": condition,
|
||||||
|
"device_id": device_entry.id,
|
||||||
|
"entity_id": f"{DOMAIN}.test_5678",
|
||||||
|
"metadata": {"secondary": True},
|
||||||
|
}
|
||||||
|
for condition in ["is_hvac_mode"]
|
||||||
|
]
|
||||||
|
conditions = await async_get_device_automations(
|
||||||
|
hass, DeviceAutomationType.CONDITION, device_entry.id
|
||||||
|
)
|
||||||
|
assert_lists_same(conditions, expected_conditions)
|
||||||
|
|
||||||
|
|
||||||
async def test_if_state(hass, calls):
|
async def test_if_state(hass, calls):
|
||||||
"""Test for turn_on and turn_off conditions."""
|
"""Test for turn_on and turn_off conditions."""
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
|
|
|
@ -19,6 +19,8 @@ from homeassistant.const import (
|
||||||
STATE_UNAVAILABLE,
|
STATE_UNAVAILABLE,
|
||||||
)
|
)
|
||||||
from homeassistant.helpers import device_registry
|
from homeassistant.helpers import device_registry
|
||||||
|
from homeassistant.helpers.entity import EntityCategory
|
||||||
|
from homeassistant.helpers.entity_registry import RegistryEntryHider
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
|
|
||||||
from tests.common import (
|
from tests.common import (
|
||||||
|
@ -103,6 +105,7 @@ async def test_get_conditions(
|
||||||
"type": condition,
|
"type": condition,
|
||||||
"device_id": device_entry.id,
|
"device_id": device_entry.id,
|
||||||
"entity_id": f"{DOMAIN}.test_5678",
|
"entity_id": f"{DOMAIN}.test_5678",
|
||||||
|
"metadata": {"secondary": False},
|
||||||
}
|
}
|
||||||
for condition in expected_condition_types
|
for condition in expected_condition_types
|
||||||
]
|
]
|
||||||
|
@ -112,6 +115,55 @@ async def test_get_conditions(
|
||||||
assert_lists_same(conditions, expected_conditions)
|
assert_lists_same(conditions, expected_conditions)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
"hidden_by,entity_category",
|
||||||
|
(
|
||||||
|
(RegistryEntryHider.INTEGRATION, None),
|
||||||
|
(RegistryEntryHider.USER, None),
|
||||||
|
(None, EntityCategory.CONFIG),
|
||||||
|
(None, EntityCategory.DIAGNOSTIC),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
async def test_get_conditions_hidden_auxiliary(
|
||||||
|
hass,
|
||||||
|
device_reg,
|
||||||
|
entity_reg,
|
||||||
|
hidden_by,
|
||||||
|
entity_category,
|
||||||
|
):
|
||||||
|
"""Test we get the expected conditions from a hidden or auxiliary entity."""
|
||||||
|
config_entry = MockConfigEntry(domain="test", data={})
|
||||||
|
config_entry.add_to_hass(hass)
|
||||||
|
device_entry = device_reg.async_get_or_create(
|
||||||
|
config_entry_id=config_entry.entry_id,
|
||||||
|
connections={(device_registry.CONNECTION_NETWORK_MAC, "12:34:56:AB:CD:EF")},
|
||||||
|
)
|
||||||
|
entity_reg.async_get_or_create(
|
||||||
|
DOMAIN,
|
||||||
|
"test",
|
||||||
|
"5678",
|
||||||
|
device_id=device_entry.id,
|
||||||
|
entity_category=entity_category,
|
||||||
|
hidden_by=hidden_by,
|
||||||
|
supported_features=SUPPORT_CLOSE,
|
||||||
|
)
|
||||||
|
expected_conditions = [
|
||||||
|
{
|
||||||
|
"condition": "device",
|
||||||
|
"domain": DOMAIN,
|
||||||
|
"type": condition,
|
||||||
|
"device_id": device_entry.id,
|
||||||
|
"entity_id": f"{DOMAIN}.test_5678",
|
||||||
|
"metadata": {"secondary": True},
|
||||||
|
}
|
||||||
|
for condition in ["is_open", "is_closed", "is_opening", "is_closing"]
|
||||||
|
]
|
||||||
|
conditions = await async_get_device_automations(
|
||||||
|
hass, DeviceAutomationType.CONDITION, device_entry.id
|
||||||
|
)
|
||||||
|
assert_lists_same(conditions, expected_conditions)
|
||||||
|
|
||||||
|
|
||||||
async def test_get_condition_capabilities(
|
async def test_get_condition_capabilities(
|
||||||
hass, device_reg, entity_reg, enable_custom_integrations
|
hass, device_reg, entity_reg, enable_custom_integrations
|
||||||
):
|
):
|
||||||
|
|
|
@ -105,6 +105,7 @@ async def test_websocket_get_conditions(hass, hass_ws_client, device_reg, entity
|
||||||
"type": "is_off",
|
"type": "is_off",
|
||||||
"device_id": device_entry.id,
|
"device_id": device_entry.id,
|
||||||
"entity_id": "light.test_5678",
|
"entity_id": "light.test_5678",
|
||||||
|
"metadata": {"secondary": False},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"condition": "device",
|
"condition": "device",
|
||||||
|
@ -112,6 +113,7 @@ async def test_websocket_get_conditions(hass, hass_ws_client, device_reg, entity
|
||||||
"type": "is_on",
|
"type": "is_on",
|
||||||
"device_id": device_entry.id,
|
"device_id": device_entry.id,
|
||||||
"entity_id": "light.test_5678",
|
"entity_id": "light.test_5678",
|
||||||
|
"metadata": {"secondary": False},
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,8 @@ from homeassistant.components.device_automation import DeviceAutomationType
|
||||||
from homeassistant.components.device_tracker import DOMAIN
|
from homeassistant.components.device_tracker import DOMAIN
|
||||||
from homeassistant.const import STATE_HOME
|
from homeassistant.const import STATE_HOME
|
||||||
from homeassistant.helpers import device_registry
|
from homeassistant.helpers import device_registry
|
||||||
|
from homeassistant.helpers.entity import EntityCategory
|
||||||
|
from homeassistant.helpers.entity_registry import RegistryEntryHider
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
|
|
||||||
from tests.common import (
|
from tests.common import (
|
||||||
|
@ -50,17 +52,60 @@ async def test_get_conditions(hass, device_reg, entity_reg):
|
||||||
{
|
{
|
||||||
"condition": "device",
|
"condition": "device",
|
||||||
"domain": DOMAIN,
|
"domain": DOMAIN,
|
||||||
"type": "is_not_home",
|
"type": condition,
|
||||||
"device_id": device_entry.id,
|
"device_id": device_entry.id,
|
||||||
"entity_id": f"{DOMAIN}.test_5678",
|
"entity_id": f"{DOMAIN}.test_5678",
|
||||||
},
|
"metadata": {"secondary": False},
|
||||||
|
}
|
||||||
|
for condition in ["is_not_home", "is_home"]
|
||||||
|
]
|
||||||
|
conditions = await async_get_device_automations(
|
||||||
|
hass, DeviceAutomationType.CONDITION, device_entry.id
|
||||||
|
)
|
||||||
|
assert_lists_same(conditions, expected_conditions)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
"hidden_by,entity_category",
|
||||||
|
(
|
||||||
|
(RegistryEntryHider.INTEGRATION, None),
|
||||||
|
(RegistryEntryHider.USER, None),
|
||||||
|
(None, EntityCategory.CONFIG),
|
||||||
|
(None, EntityCategory.DIAGNOSTIC),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
async def test_get_conditions_hidden_auxiliary(
|
||||||
|
hass,
|
||||||
|
device_reg,
|
||||||
|
entity_reg,
|
||||||
|
hidden_by,
|
||||||
|
entity_category,
|
||||||
|
):
|
||||||
|
"""Test we get the expected conditions from a hidden or auxiliary entity."""
|
||||||
|
config_entry = MockConfigEntry(domain="test", data={})
|
||||||
|
config_entry.add_to_hass(hass)
|
||||||
|
device_entry = device_reg.async_get_or_create(
|
||||||
|
config_entry_id=config_entry.entry_id,
|
||||||
|
connections={(device_registry.CONNECTION_NETWORK_MAC, "12:34:56:AB:CD:EF")},
|
||||||
|
)
|
||||||
|
entity_reg.async_get_or_create(
|
||||||
|
DOMAIN,
|
||||||
|
"test",
|
||||||
|
"5678",
|
||||||
|
device_id=device_entry.id,
|
||||||
|
entity_category=entity_category,
|
||||||
|
hidden_by=hidden_by,
|
||||||
|
)
|
||||||
|
expected_conditions = [
|
||||||
{
|
{
|
||||||
"condition": "device",
|
"condition": "device",
|
||||||
"domain": DOMAIN,
|
"domain": DOMAIN,
|
||||||
"type": "is_home",
|
"type": condition,
|
||||||
"device_id": device_entry.id,
|
"device_id": device_entry.id,
|
||||||
"entity_id": f"{DOMAIN}.test_5678",
|
"entity_id": f"{DOMAIN}.test_5678",
|
||||||
},
|
"metadata": {"secondary": True},
|
||||||
|
}
|
||||||
|
for condition in ["is_not_home", "is_home"]
|
||||||
]
|
]
|
||||||
conditions = await async_get_device_automations(
|
conditions = await async_get_device_automations(
|
||||||
hass, DeviceAutomationType.CONDITION, device_entry.id
|
hass, DeviceAutomationType.CONDITION, device_entry.id
|
||||||
|
|
|
@ -6,6 +6,8 @@ from homeassistant.components.device_automation import DeviceAutomationType
|
||||||
from homeassistant.components.fan import DOMAIN
|
from homeassistant.components.fan import DOMAIN
|
||||||
from homeassistant.const import STATE_OFF, STATE_ON
|
from homeassistant.const import STATE_OFF, STATE_ON
|
||||||
from homeassistant.helpers import device_registry
|
from homeassistant.helpers import device_registry
|
||||||
|
from homeassistant.helpers.entity import EntityCategory
|
||||||
|
from homeassistant.helpers.entity_registry import RegistryEntryHider
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
|
|
||||||
from tests.common import (
|
from tests.common import (
|
||||||
|
@ -50,17 +52,60 @@ async def test_get_conditions(hass, device_reg, entity_reg):
|
||||||
{
|
{
|
||||||
"condition": "device",
|
"condition": "device",
|
||||||
"domain": DOMAIN,
|
"domain": DOMAIN,
|
||||||
"type": "is_off",
|
"type": condition,
|
||||||
"device_id": device_entry.id,
|
"device_id": device_entry.id,
|
||||||
"entity_id": f"{DOMAIN}.test_5678",
|
"entity_id": f"{DOMAIN}.test_5678",
|
||||||
},
|
"metadata": {"secondary": False},
|
||||||
|
}
|
||||||
|
for condition in ["is_off", "is_on"]
|
||||||
|
]
|
||||||
|
conditions = await async_get_device_automations(
|
||||||
|
hass, DeviceAutomationType.CONDITION, device_entry.id
|
||||||
|
)
|
||||||
|
assert_lists_same(conditions, expected_conditions)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
"hidden_by,entity_category",
|
||||||
|
(
|
||||||
|
(RegistryEntryHider.INTEGRATION, None),
|
||||||
|
(RegistryEntryHider.USER, None),
|
||||||
|
(None, EntityCategory.CONFIG),
|
||||||
|
(None, EntityCategory.DIAGNOSTIC),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
async def test_get_conditions_hidden_auxiliary(
|
||||||
|
hass,
|
||||||
|
device_reg,
|
||||||
|
entity_reg,
|
||||||
|
hidden_by,
|
||||||
|
entity_category,
|
||||||
|
):
|
||||||
|
"""Test we get the expected conditions from a hidden or auxiliary entity."""
|
||||||
|
config_entry = MockConfigEntry(domain="test", data={})
|
||||||
|
config_entry.add_to_hass(hass)
|
||||||
|
device_entry = device_reg.async_get_or_create(
|
||||||
|
config_entry_id=config_entry.entry_id,
|
||||||
|
connections={(device_registry.CONNECTION_NETWORK_MAC, "12:34:56:AB:CD:EF")},
|
||||||
|
)
|
||||||
|
entity_reg.async_get_or_create(
|
||||||
|
DOMAIN,
|
||||||
|
"test",
|
||||||
|
"5678",
|
||||||
|
device_id=device_entry.id,
|
||||||
|
entity_category=entity_category,
|
||||||
|
hidden_by=hidden_by,
|
||||||
|
)
|
||||||
|
expected_conditions = [
|
||||||
{
|
{
|
||||||
"condition": "device",
|
"condition": "device",
|
||||||
"domain": DOMAIN,
|
"domain": DOMAIN,
|
||||||
"type": "is_on",
|
"type": condition,
|
||||||
"device_id": device_entry.id,
|
"device_id": device_entry.id,
|
||||||
"entity_id": f"{DOMAIN}.test_5678",
|
"entity_id": f"{DOMAIN}.test_5678",
|
||||||
},
|
"metadata": {"secondary": True},
|
||||||
|
}
|
||||||
|
for condition in ["is_off", "is_on"]
|
||||||
]
|
]
|
||||||
conditions = await async_get_device_automations(
|
conditions = await async_get_device_automations(
|
||||||
hass, DeviceAutomationType.CONDITION, device_entry.id
|
hass, DeviceAutomationType.CONDITION, device_entry.id
|
||||||
|
|
|
@ -7,6 +7,8 @@ from homeassistant.components.device_automation import DeviceAutomationType
|
||||||
from homeassistant.components.humidifier import DOMAIN, const, device_condition
|
from homeassistant.components.humidifier import DOMAIN, const, device_condition
|
||||||
from homeassistant.const import ATTR_MODE, STATE_OFF, STATE_ON
|
from homeassistant.const import ATTR_MODE, STATE_OFF, STATE_ON
|
||||||
from homeassistant.helpers import config_validation as cv, device_registry
|
from homeassistant.helpers import config_validation as cv, device_registry
|
||||||
|
from homeassistant.helpers.entity import EntityCategory
|
||||||
|
from homeassistant.helpers.entity_registry import RegistryEntryHider
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
|
|
||||||
from tests.common import (
|
from tests.common import (
|
||||||
|
@ -83,6 +85,7 @@ async def test_get_conditions(
|
||||||
"type": condition,
|
"type": condition,
|
||||||
"device_id": device_entry.id,
|
"device_id": device_entry.id,
|
||||||
"entity_id": f"{DOMAIN}.test_5678",
|
"entity_id": f"{DOMAIN}.test_5678",
|
||||||
|
"metadata": {"secondary": False},
|
||||||
}
|
}
|
||||||
for condition in basic_condition_types
|
for condition in basic_condition_types
|
||||||
]
|
]
|
||||||
|
@ -93,6 +96,7 @@ async def test_get_conditions(
|
||||||
"type": condition,
|
"type": condition,
|
||||||
"device_id": device_entry.id,
|
"device_id": device_entry.id,
|
||||||
"entity_id": f"{DOMAIN}.test_5678",
|
"entity_id": f"{DOMAIN}.test_5678",
|
||||||
|
"metadata": {"secondary": False},
|
||||||
}
|
}
|
||||||
for condition in expected_condition_types
|
for condition in expected_condition_types
|
||||||
]
|
]
|
||||||
|
@ -102,6 +106,54 @@ async def test_get_conditions(
|
||||||
assert_lists_same(conditions, expected_conditions)
|
assert_lists_same(conditions, expected_conditions)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
"hidden_by,entity_category",
|
||||||
|
(
|
||||||
|
(RegistryEntryHider.INTEGRATION, None),
|
||||||
|
(RegistryEntryHider.USER, None),
|
||||||
|
(None, EntityCategory.CONFIG),
|
||||||
|
(None, EntityCategory.DIAGNOSTIC),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
async def test_get_conditions_hidden_auxiliary(
|
||||||
|
hass,
|
||||||
|
device_reg,
|
||||||
|
entity_reg,
|
||||||
|
hidden_by,
|
||||||
|
entity_category,
|
||||||
|
):
|
||||||
|
"""Test we get the expected conditions from a hidden or auxiliary entity."""
|
||||||
|
config_entry = MockConfigEntry(domain="test", data={})
|
||||||
|
config_entry.add_to_hass(hass)
|
||||||
|
device_entry = device_reg.async_get_or_create(
|
||||||
|
config_entry_id=config_entry.entry_id,
|
||||||
|
connections={(device_registry.CONNECTION_NETWORK_MAC, "12:34:56:AB:CD:EF")},
|
||||||
|
)
|
||||||
|
entity_reg.async_get_or_create(
|
||||||
|
DOMAIN,
|
||||||
|
"test",
|
||||||
|
"5678",
|
||||||
|
device_id=device_entry.id,
|
||||||
|
entity_category=entity_category,
|
||||||
|
hidden_by=hidden_by,
|
||||||
|
)
|
||||||
|
expected_conditions = [
|
||||||
|
{
|
||||||
|
"condition": "device",
|
||||||
|
"domain": DOMAIN,
|
||||||
|
"type": condition,
|
||||||
|
"device_id": device_entry.id,
|
||||||
|
"entity_id": f"{DOMAIN}.test_5678",
|
||||||
|
"metadata": {"secondary": True},
|
||||||
|
}
|
||||||
|
for condition in ["is_off", "is_on"]
|
||||||
|
]
|
||||||
|
conditions = await async_get_device_automations(
|
||||||
|
hass, DeviceAutomationType.CONDITION, device_entry.id
|
||||||
|
)
|
||||||
|
assert_lists_same(conditions, expected_conditions)
|
||||||
|
|
||||||
|
|
||||||
async def test_if_state(hass, calls):
|
async def test_if_state(hass, calls):
|
||||||
"""Test for turn_on and turn_off conditions."""
|
"""Test for turn_on and turn_off conditions."""
|
||||||
hass.states.async_set("humidifier.entity", STATE_ON, {ATTR_MODE: const.MODE_AWAY})
|
hass.states.async_set("humidifier.entity", STATE_ON, {ATTR_MODE: const.MODE_AWAY})
|
||||||
|
|
|
@ -9,11 +9,14 @@ from homeassistant.components.device_automation import DeviceAutomationType
|
||||||
from homeassistant.components.light import DOMAIN
|
from homeassistant.components.light import DOMAIN
|
||||||
from homeassistant.const import CONF_PLATFORM, STATE_OFF, STATE_ON
|
from homeassistant.const import CONF_PLATFORM, STATE_OFF, STATE_ON
|
||||||
from homeassistant.helpers import device_registry
|
from homeassistant.helpers import device_registry
|
||||||
|
from homeassistant.helpers.entity import EntityCategory
|
||||||
|
from homeassistant.helpers.entity_registry import RegistryEntryHider
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
import homeassistant.util.dt as dt_util
|
import homeassistant.util.dt as dt_util
|
||||||
|
|
||||||
from tests.common import (
|
from tests.common import (
|
||||||
MockConfigEntry,
|
MockConfigEntry,
|
||||||
|
assert_lists_same,
|
||||||
async_get_device_automation_capabilities,
|
async_get_device_automation_capabilities,
|
||||||
async_get_device_automations,
|
async_get_device_automations,
|
||||||
async_mock_service,
|
async_mock_service,
|
||||||
|
@ -54,17 +57,12 @@ async def test_get_conditions(hass, device_reg, entity_reg):
|
||||||
{
|
{
|
||||||
"condition": "device",
|
"condition": "device",
|
||||||
"domain": DOMAIN,
|
"domain": DOMAIN,
|
||||||
"type": "is_off",
|
"type": condition,
|
||||||
"device_id": device_entry.id,
|
"device_id": device_entry.id,
|
||||||
"entity_id": f"{DOMAIN}.test_5678",
|
"entity_id": f"{DOMAIN}.test_5678",
|
||||||
},
|
"metadata": {"secondary": False},
|
||||||
{
|
}
|
||||||
"condition": "device",
|
for condition in ["is_off", "is_on"]
|
||||||
"domain": DOMAIN,
|
|
||||||
"type": "is_on",
|
|
||||||
"device_id": device_entry.id,
|
|
||||||
"entity_id": f"{DOMAIN}.test_5678",
|
|
||||||
},
|
|
||||||
]
|
]
|
||||||
conditions = await async_get_device_automations(
|
conditions = await async_get_device_automations(
|
||||||
hass, DeviceAutomationType.CONDITION, device_entry.id
|
hass, DeviceAutomationType.CONDITION, device_entry.id
|
||||||
|
@ -72,6 +70,54 @@ async def test_get_conditions(hass, device_reg, entity_reg):
|
||||||
assert conditions == expected_conditions
|
assert conditions == expected_conditions
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
"hidden_by,entity_category",
|
||||||
|
(
|
||||||
|
(RegistryEntryHider.INTEGRATION, None),
|
||||||
|
(RegistryEntryHider.USER, None),
|
||||||
|
(None, EntityCategory.CONFIG),
|
||||||
|
(None, EntityCategory.DIAGNOSTIC),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
async def test_get_conditions_hidden_auxiliary(
|
||||||
|
hass,
|
||||||
|
device_reg,
|
||||||
|
entity_reg,
|
||||||
|
hidden_by,
|
||||||
|
entity_category,
|
||||||
|
):
|
||||||
|
"""Test we get the expected conditions from a hidden or auxiliary entity."""
|
||||||
|
config_entry = MockConfigEntry(domain="test", data={})
|
||||||
|
config_entry.add_to_hass(hass)
|
||||||
|
device_entry = device_reg.async_get_or_create(
|
||||||
|
config_entry_id=config_entry.entry_id,
|
||||||
|
connections={(device_registry.CONNECTION_NETWORK_MAC, "12:34:56:AB:CD:EF")},
|
||||||
|
)
|
||||||
|
entity_reg.async_get_or_create(
|
||||||
|
DOMAIN,
|
||||||
|
"test",
|
||||||
|
"5678",
|
||||||
|
device_id=device_entry.id,
|
||||||
|
entity_category=entity_category,
|
||||||
|
hidden_by=hidden_by,
|
||||||
|
)
|
||||||
|
expected_conditions = [
|
||||||
|
{
|
||||||
|
"condition": "device",
|
||||||
|
"domain": DOMAIN,
|
||||||
|
"type": condition,
|
||||||
|
"device_id": device_entry.id,
|
||||||
|
"entity_id": f"{DOMAIN}.test_5678",
|
||||||
|
"metadata": {"secondary": True},
|
||||||
|
}
|
||||||
|
for condition in ["is_off", "is_on"]
|
||||||
|
]
|
||||||
|
conditions = await async_get_device_automations(
|
||||||
|
hass, DeviceAutomationType.CONDITION, device_entry.id
|
||||||
|
)
|
||||||
|
assert_lists_same(conditions, expected_conditions)
|
||||||
|
|
||||||
|
|
||||||
async def test_get_condition_capabilities(hass, device_reg, entity_reg):
|
async def test_get_condition_capabilities(hass, device_reg, entity_reg):
|
||||||
"""Test we get the expected capabilities from a light condition."""
|
"""Test we get the expected capabilities from a light condition."""
|
||||||
config_entry = MockConfigEntry(domain="test", data={})
|
config_entry = MockConfigEntry(domain="test", data={})
|
||||||
|
|
|
@ -12,6 +12,8 @@ from homeassistant.const import (
|
||||||
STATE_UNLOCKING,
|
STATE_UNLOCKING,
|
||||||
)
|
)
|
||||||
from homeassistant.helpers import device_registry
|
from homeassistant.helpers import device_registry
|
||||||
|
from homeassistant.helpers.entity import EntityCategory
|
||||||
|
from homeassistant.helpers.entity_registry import RegistryEntryHider
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
|
|
||||||
from tests.common import (
|
from tests.common import (
|
||||||
|
@ -56,38 +58,72 @@ async def test_get_conditions(hass, device_reg, entity_reg):
|
||||||
{
|
{
|
||||||
"condition": "device",
|
"condition": "device",
|
||||||
"domain": DOMAIN,
|
"domain": DOMAIN,
|
||||||
"type": "is_locked",
|
"type": condition,
|
||||||
"device_id": device_entry.id,
|
"device_id": device_entry.id,
|
||||||
"entity_id": f"{DOMAIN}.test_5678",
|
"entity_id": f"{DOMAIN}.test_5678",
|
||||||
},
|
"metadata": {"secondary": False},
|
||||||
|
}
|
||||||
|
for condition in [
|
||||||
|
"is_locked",
|
||||||
|
"is_unlocked",
|
||||||
|
"is_unlocking",
|
||||||
|
"is_locking",
|
||||||
|
"is_jammed",
|
||||||
|
]
|
||||||
|
]
|
||||||
|
conditions = await async_get_device_automations(
|
||||||
|
hass, DeviceAutomationType.CONDITION, device_entry.id
|
||||||
|
)
|
||||||
|
assert_lists_same(conditions, expected_conditions)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
"hidden_by,entity_category",
|
||||||
|
(
|
||||||
|
(RegistryEntryHider.INTEGRATION, None),
|
||||||
|
(RegistryEntryHider.USER, None),
|
||||||
|
(None, EntityCategory.CONFIG),
|
||||||
|
(None, EntityCategory.DIAGNOSTIC),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
async def test_get_conditions_hidden_auxiliary(
|
||||||
|
hass,
|
||||||
|
device_reg,
|
||||||
|
entity_reg,
|
||||||
|
hidden_by,
|
||||||
|
entity_category,
|
||||||
|
):
|
||||||
|
"""Test we get the expected conditions from a hidden or auxiliary entity."""
|
||||||
|
config_entry = MockConfigEntry(domain="test", data={})
|
||||||
|
config_entry.add_to_hass(hass)
|
||||||
|
device_entry = device_reg.async_get_or_create(
|
||||||
|
config_entry_id=config_entry.entry_id,
|
||||||
|
connections={(device_registry.CONNECTION_NETWORK_MAC, "12:34:56:AB:CD:EF")},
|
||||||
|
)
|
||||||
|
entity_reg.async_get_or_create(
|
||||||
|
DOMAIN,
|
||||||
|
"test",
|
||||||
|
"5678",
|
||||||
|
device_id=device_entry.id,
|
||||||
|
entity_category=entity_category,
|
||||||
|
hidden_by=hidden_by,
|
||||||
|
)
|
||||||
|
expected_conditions = [
|
||||||
{
|
{
|
||||||
"condition": "device",
|
"condition": "device",
|
||||||
"domain": DOMAIN,
|
"domain": DOMAIN,
|
||||||
"type": "is_unlocked",
|
"type": condition,
|
||||||
"device_id": device_entry.id,
|
"device_id": device_entry.id,
|
||||||
"entity_id": f"{DOMAIN}.test_5678",
|
"entity_id": f"{DOMAIN}.test_5678",
|
||||||
},
|
"metadata": {"secondary": True},
|
||||||
{
|
}
|
||||||
"condition": "device",
|
for condition in [
|
||||||
"domain": DOMAIN,
|
"is_locked",
|
||||||
"type": "is_unlocking",
|
"is_unlocked",
|
||||||
"device_id": device_entry.id,
|
"is_unlocking",
|
||||||
"entity_id": f"{DOMAIN}.test_5678",
|
"is_locking",
|
||||||
},
|
"is_jammed",
|
||||||
{
|
]
|
||||||
"condition": "device",
|
|
||||||
"domain": DOMAIN,
|
|
||||||
"type": "is_locking",
|
|
||||||
"device_id": device_entry.id,
|
|
||||||
"entity_id": f"{DOMAIN}.test_5678",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"condition": "device",
|
|
||||||
"domain": DOMAIN,
|
|
||||||
"type": "is_jammed",
|
|
||||||
"device_id": device_entry.id,
|
|
||||||
"entity_id": f"{DOMAIN}.test_5678",
|
|
||||||
},
|
|
||||||
]
|
]
|
||||||
conditions = await async_get_device_automations(
|
conditions = await async_get_device_automations(
|
||||||
hass, DeviceAutomationType.CONDITION, device_entry.id
|
hass, DeviceAutomationType.CONDITION, device_entry.id
|
||||||
|
|
|
@ -12,6 +12,8 @@ from homeassistant.const import (
|
||||||
STATE_PLAYING,
|
STATE_PLAYING,
|
||||||
)
|
)
|
||||||
from homeassistant.helpers import device_registry
|
from homeassistant.helpers import device_registry
|
||||||
|
from homeassistant.helpers.entity import EntityCategory
|
||||||
|
from homeassistant.helpers.entity_registry import RegistryEntryHider
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
|
|
||||||
from tests.common import (
|
from tests.common import (
|
||||||
|
@ -56,38 +58,60 @@ async def test_get_conditions(hass, device_reg, entity_reg):
|
||||||
{
|
{
|
||||||
"condition": "device",
|
"condition": "device",
|
||||||
"domain": DOMAIN,
|
"domain": DOMAIN,
|
||||||
"type": "is_off",
|
"type": condition,
|
||||||
"device_id": device_entry.id,
|
"device_id": device_entry.id,
|
||||||
"entity_id": f"{DOMAIN}.test_5678",
|
"entity_id": f"{DOMAIN}.test_5678",
|
||||||
},
|
"metadata": {"secondary": False},
|
||||||
|
}
|
||||||
|
for condition in ["is_off", "is_on", "is_idle", "is_paused", "is_playing"]
|
||||||
|
]
|
||||||
|
conditions = await async_get_device_automations(
|
||||||
|
hass, DeviceAutomationType.CONDITION, device_entry.id
|
||||||
|
)
|
||||||
|
assert_lists_same(conditions, expected_conditions)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
"hidden_by,entity_category",
|
||||||
|
(
|
||||||
|
(RegistryEntryHider.INTEGRATION, None),
|
||||||
|
(RegistryEntryHider.USER, None),
|
||||||
|
(None, EntityCategory.CONFIG),
|
||||||
|
(None, EntityCategory.DIAGNOSTIC),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
async def test_get_conditions_hidden_auxiliary(
|
||||||
|
hass,
|
||||||
|
device_reg,
|
||||||
|
entity_reg,
|
||||||
|
hidden_by,
|
||||||
|
entity_category,
|
||||||
|
):
|
||||||
|
"""Test we get the expected conditions from a hidden or auxiliary entity."""
|
||||||
|
config_entry = MockConfigEntry(domain="test", data={})
|
||||||
|
config_entry.add_to_hass(hass)
|
||||||
|
device_entry = device_reg.async_get_or_create(
|
||||||
|
config_entry_id=config_entry.entry_id,
|
||||||
|
connections={(device_registry.CONNECTION_NETWORK_MAC, "12:34:56:AB:CD:EF")},
|
||||||
|
)
|
||||||
|
entity_reg.async_get_or_create(
|
||||||
|
DOMAIN,
|
||||||
|
"test",
|
||||||
|
"5678",
|
||||||
|
device_id=device_entry.id,
|
||||||
|
entity_category=entity_category,
|
||||||
|
hidden_by=hidden_by,
|
||||||
|
)
|
||||||
|
expected_conditions = [
|
||||||
{
|
{
|
||||||
"condition": "device",
|
"condition": "device",
|
||||||
"domain": DOMAIN,
|
"domain": DOMAIN,
|
||||||
"type": "is_on",
|
"type": condition,
|
||||||
"device_id": device_entry.id,
|
"device_id": device_entry.id,
|
||||||
"entity_id": f"{DOMAIN}.test_5678",
|
"entity_id": f"{DOMAIN}.test_5678",
|
||||||
},
|
"metadata": {"secondary": True},
|
||||||
{
|
}
|
||||||
"condition": "device",
|
for condition in ["is_off", "is_on", "is_idle", "is_paused", "is_playing"]
|
||||||
"domain": DOMAIN,
|
|
||||||
"type": "is_idle",
|
|
||||||
"device_id": device_entry.id,
|
|
||||||
"entity_id": f"{DOMAIN}.test_5678",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"condition": "device",
|
|
||||||
"domain": DOMAIN,
|
|
||||||
"type": "is_paused",
|
|
||||||
"device_id": device_entry.id,
|
|
||||||
"entity_id": f"{DOMAIN}.test_5678",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"condition": "device",
|
|
||||||
"domain": DOMAIN,
|
|
||||||
"type": "is_playing",
|
|
||||||
"device_id": device_entry.id,
|
|
||||||
"entity_id": f"{DOMAIN}.test_5678",
|
|
||||||
},
|
|
||||||
]
|
]
|
||||||
conditions = await async_get_device_automations(
|
conditions = await async_get_device_automations(
|
||||||
hass, DeviceAutomationType.CONDITION, device_entry.id
|
hass, DeviceAutomationType.CONDITION, device_entry.id
|
||||||
|
|
|
@ -9,11 +9,14 @@ from homeassistant.components.device_automation import DeviceAutomationType
|
||||||
from homeassistant.components.remote import DOMAIN
|
from homeassistant.components.remote import DOMAIN
|
||||||
from homeassistant.const import CONF_PLATFORM, STATE_OFF, STATE_ON
|
from homeassistant.const import CONF_PLATFORM, STATE_OFF, STATE_ON
|
||||||
from homeassistant.helpers import device_registry
|
from homeassistant.helpers import device_registry
|
||||||
|
from homeassistant.helpers.entity import EntityCategory
|
||||||
|
from homeassistant.helpers.entity_registry import RegistryEntryHider
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
import homeassistant.util.dt as dt_util
|
import homeassistant.util.dt as dt_util
|
||||||
|
|
||||||
from tests.common import (
|
from tests.common import (
|
||||||
MockConfigEntry,
|
MockConfigEntry,
|
||||||
|
assert_lists_same,
|
||||||
async_get_device_automation_capabilities,
|
async_get_device_automation_capabilities,
|
||||||
async_get_device_automations,
|
async_get_device_automations,
|
||||||
async_mock_service,
|
async_mock_service,
|
||||||
|
@ -54,22 +57,65 @@ async def test_get_conditions(hass, device_reg, entity_reg):
|
||||||
{
|
{
|
||||||
"condition": "device",
|
"condition": "device",
|
||||||
"domain": DOMAIN,
|
"domain": DOMAIN,
|
||||||
"type": "is_off",
|
"type": condition,
|
||||||
"device_id": device_entry.id,
|
"device_id": device_entry.id,
|
||||||
"entity_id": f"{DOMAIN}.test_5678",
|
"entity_id": f"{DOMAIN}.test_5678",
|
||||||
},
|
"metadata": {"secondary": False},
|
||||||
{
|
}
|
||||||
"condition": "device",
|
for condition in ["is_off", "is_on"]
|
||||||
"domain": DOMAIN,
|
|
||||||
"type": "is_on",
|
|
||||||
"device_id": device_entry.id,
|
|
||||||
"entity_id": f"{DOMAIN}.test_5678",
|
|
||||||
},
|
|
||||||
]
|
]
|
||||||
conditions = await async_get_device_automations(
|
conditions = await async_get_device_automations(
|
||||||
hass, DeviceAutomationType.CONDITION, device_entry.id
|
hass, DeviceAutomationType.CONDITION, device_entry.id
|
||||||
)
|
)
|
||||||
assert conditions == expected_conditions
|
assert_lists_same(conditions, expected_conditions)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
"hidden_by,entity_category",
|
||||||
|
(
|
||||||
|
(RegistryEntryHider.INTEGRATION, None),
|
||||||
|
(RegistryEntryHider.USER, None),
|
||||||
|
(None, EntityCategory.CONFIG),
|
||||||
|
(None, EntityCategory.DIAGNOSTIC),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
async def test_get_conditions_hidden_auxiliary(
|
||||||
|
hass,
|
||||||
|
device_reg,
|
||||||
|
entity_reg,
|
||||||
|
hidden_by,
|
||||||
|
entity_category,
|
||||||
|
):
|
||||||
|
"""Test we get the expected conditions from a hidden or auxiliary entity."""
|
||||||
|
config_entry = MockConfigEntry(domain="test", data={})
|
||||||
|
config_entry.add_to_hass(hass)
|
||||||
|
device_entry = device_reg.async_get_or_create(
|
||||||
|
config_entry_id=config_entry.entry_id,
|
||||||
|
connections={(device_registry.CONNECTION_NETWORK_MAC, "12:34:56:AB:CD:EF")},
|
||||||
|
)
|
||||||
|
entity_reg.async_get_or_create(
|
||||||
|
DOMAIN,
|
||||||
|
"test",
|
||||||
|
"5678",
|
||||||
|
device_id=device_entry.id,
|
||||||
|
entity_category=entity_category,
|
||||||
|
hidden_by=hidden_by,
|
||||||
|
)
|
||||||
|
expected_conditions = [
|
||||||
|
{
|
||||||
|
"condition": "device",
|
||||||
|
"domain": DOMAIN,
|
||||||
|
"type": condition,
|
||||||
|
"device_id": device_entry.id,
|
||||||
|
"entity_id": f"{DOMAIN}.test_5678",
|
||||||
|
"metadata": {"secondary": True},
|
||||||
|
}
|
||||||
|
for condition in ["is_off", "is_on"]
|
||||||
|
]
|
||||||
|
conditions = await async_get_device_automations(
|
||||||
|
hass, DeviceAutomationType.CONDITION, device_entry.id
|
||||||
|
)
|
||||||
|
assert_lists_same(conditions, expected_conditions)
|
||||||
|
|
||||||
|
|
||||||
async def test_get_condition_capabilities(hass, device_reg, entity_reg):
|
async def test_get_condition_capabilities(hass, device_reg, entity_reg):
|
||||||
|
|
|
@ -16,6 +16,7 @@ from homeassistant.helpers import (
|
||||||
device_registry,
|
device_registry,
|
||||||
entity_registry,
|
entity_registry,
|
||||||
)
|
)
|
||||||
|
from homeassistant.helpers.entity import EntityCategory
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
|
|
||||||
from tests.common import (
|
from tests.common import (
|
||||||
|
@ -66,6 +67,7 @@ async def test_get_conditions(
|
||||||
"type": "selected_option",
|
"type": "selected_option",
|
||||||
"device_id": device_entry.id,
|
"device_id": device_entry.id,
|
||||||
"entity_id": f"{DOMAIN}.test_5678",
|
"entity_id": f"{DOMAIN}.test_5678",
|
||||||
|
"metadata": {"secondary": False},
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
conditions = await async_get_device_automations(
|
conditions = await async_get_device_automations(
|
||||||
|
@ -74,6 +76,54 @@ async def test_get_conditions(
|
||||||
assert_lists_same(conditions, expected_conditions)
|
assert_lists_same(conditions, expected_conditions)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
"hidden_by,entity_category",
|
||||||
|
(
|
||||||
|
(entity_registry.RegistryEntryHider.INTEGRATION, None),
|
||||||
|
(entity_registry.RegistryEntryHider.USER, None),
|
||||||
|
(None, EntityCategory.CONFIG),
|
||||||
|
(None, EntityCategory.DIAGNOSTIC),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
async def test_get_conditions_hidden_auxiliary(
|
||||||
|
hass,
|
||||||
|
device_reg,
|
||||||
|
entity_reg,
|
||||||
|
hidden_by,
|
||||||
|
entity_category,
|
||||||
|
):
|
||||||
|
"""Test we get the expected conditions from a hidden or auxiliary entity."""
|
||||||
|
config_entry = MockConfigEntry(domain="test", data={})
|
||||||
|
config_entry.add_to_hass(hass)
|
||||||
|
device_entry = device_reg.async_get_or_create(
|
||||||
|
config_entry_id=config_entry.entry_id,
|
||||||
|
connections={(device_registry.CONNECTION_NETWORK_MAC, "12:34:56:AB:CD:EF")},
|
||||||
|
)
|
||||||
|
entity_reg.async_get_or_create(
|
||||||
|
DOMAIN,
|
||||||
|
"test",
|
||||||
|
"5678",
|
||||||
|
device_id=device_entry.id,
|
||||||
|
entity_category=entity_category,
|
||||||
|
hidden_by=hidden_by,
|
||||||
|
)
|
||||||
|
expected_conditions = [
|
||||||
|
{
|
||||||
|
"condition": "device",
|
||||||
|
"domain": DOMAIN,
|
||||||
|
"type": condition,
|
||||||
|
"device_id": device_entry.id,
|
||||||
|
"entity_id": f"{DOMAIN}.test_5678",
|
||||||
|
"metadata": {"secondary": True},
|
||||||
|
}
|
||||||
|
for condition in ["selected_option"]
|
||||||
|
]
|
||||||
|
conditions = await async_get_device_automations(
|
||||||
|
hass, DeviceAutomationType.CONDITION, device_entry.id
|
||||||
|
)
|
||||||
|
assert_lists_same(conditions, expected_conditions)
|
||||||
|
|
||||||
|
|
||||||
async def test_if_selected_option(
|
async def test_if_selected_option(
|
||||||
hass: HomeAssistant, calls: list[ServiceCall]
|
hass: HomeAssistant, calls: list[ServiceCall]
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
|
@ -7,10 +7,13 @@ from homeassistant.components.sensor import DOMAIN, SensorDeviceClass
|
||||||
from homeassistant.components.sensor.device_condition import ENTITY_CONDITIONS
|
from homeassistant.components.sensor.device_condition import ENTITY_CONDITIONS
|
||||||
from homeassistant.const import CONF_PLATFORM, PERCENTAGE, STATE_UNKNOWN
|
from homeassistant.const import CONF_PLATFORM, PERCENTAGE, STATE_UNKNOWN
|
||||||
from homeassistant.helpers import device_registry
|
from homeassistant.helpers import device_registry
|
||||||
|
from homeassistant.helpers.entity import EntityCategory
|
||||||
|
from homeassistant.helpers.entity_registry import RegistryEntryHider
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
|
|
||||||
from tests.common import (
|
from tests.common import (
|
||||||
MockConfigEntry,
|
MockConfigEntry,
|
||||||
|
assert_lists_same,
|
||||||
async_get_device_automation_capabilities,
|
async_get_device_automation_capabilities,
|
||||||
async_get_device_automations,
|
async_get_device_automations,
|
||||||
async_mock_service,
|
async_mock_service,
|
||||||
|
@ -68,6 +71,7 @@ async def test_get_conditions(hass, device_reg, entity_reg, enable_custom_integr
|
||||||
"type": condition["type"],
|
"type": condition["type"],
|
||||||
"device_id": device_entry.id,
|
"device_id": device_entry.id,
|
||||||
"entity_id": platform.ENTITIES[device_class].entity_id,
|
"entity_id": platform.ENTITIES[device_class].entity_id,
|
||||||
|
"metadata": {"secondary": False},
|
||||||
}
|
}
|
||||||
for device_class in SensorDeviceClass
|
for device_class in SensorDeviceClass
|
||||||
if device_class in UNITS_OF_MEASUREMENT
|
if device_class in UNITS_OF_MEASUREMENT
|
||||||
|
@ -78,7 +82,56 @@ async def test_get_conditions(hass, device_reg, entity_reg, enable_custom_integr
|
||||||
hass, DeviceAutomationType.CONDITION, device_entry.id
|
hass, DeviceAutomationType.CONDITION, device_entry.id
|
||||||
)
|
)
|
||||||
assert len(conditions) == 26
|
assert len(conditions) == 26
|
||||||
assert conditions == expected_conditions
|
assert_lists_same(conditions, expected_conditions)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
"hidden_by,entity_category",
|
||||||
|
(
|
||||||
|
(RegistryEntryHider.INTEGRATION, None),
|
||||||
|
(RegistryEntryHider.USER, None),
|
||||||
|
(None, EntityCategory.CONFIG),
|
||||||
|
(None, EntityCategory.DIAGNOSTIC),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
async def test_get_conditions_hidden_auxiliary(
|
||||||
|
hass,
|
||||||
|
device_reg,
|
||||||
|
entity_reg,
|
||||||
|
hidden_by,
|
||||||
|
entity_category,
|
||||||
|
):
|
||||||
|
"""Test we get the expected conditions from a hidden or auxiliary entity."""
|
||||||
|
config_entry = MockConfigEntry(domain="test", data={})
|
||||||
|
config_entry.add_to_hass(hass)
|
||||||
|
device_entry = device_reg.async_get_or_create(
|
||||||
|
config_entry_id=config_entry.entry_id,
|
||||||
|
connections={(device_registry.CONNECTION_NETWORK_MAC, "12:34:56:AB:CD:EF")},
|
||||||
|
)
|
||||||
|
entity_reg.async_get_or_create(
|
||||||
|
DOMAIN,
|
||||||
|
"test",
|
||||||
|
"5678",
|
||||||
|
device_id=device_entry.id,
|
||||||
|
entity_category=entity_category,
|
||||||
|
hidden_by=hidden_by,
|
||||||
|
unit_of_measurement="dogs",
|
||||||
|
)
|
||||||
|
expected_conditions = [
|
||||||
|
{
|
||||||
|
"condition": "device",
|
||||||
|
"domain": DOMAIN,
|
||||||
|
"type": condition,
|
||||||
|
"device_id": device_entry.id,
|
||||||
|
"entity_id": f"{DOMAIN}.test_5678",
|
||||||
|
"metadata": {"secondary": True},
|
||||||
|
}
|
||||||
|
for condition in ["is_value"]
|
||||||
|
]
|
||||||
|
conditions = await async_get_device_automations(
|
||||||
|
hass, DeviceAutomationType.CONDITION, device_entry.id
|
||||||
|
)
|
||||||
|
assert_lists_same(conditions, expected_conditions)
|
||||||
|
|
||||||
|
|
||||||
async def test_get_conditions_no_state(hass, device_reg, entity_reg):
|
async def test_get_conditions_no_state(hass, device_reg, entity_reg):
|
||||||
|
@ -109,6 +162,7 @@ async def test_get_conditions_no_state(hass, device_reg, entity_reg):
|
||||||
"type": condition["type"],
|
"type": condition["type"],
|
||||||
"device_id": device_entry.id,
|
"device_id": device_entry.id,
|
||||||
"entity_id": entity_ids[device_class],
|
"entity_id": entity_ids[device_class],
|
||||||
|
"metadata": {"secondary": False},
|
||||||
}
|
}
|
||||||
for device_class in SensorDeviceClass
|
for device_class in SensorDeviceClass
|
||||||
if device_class in UNITS_OF_MEASUREMENT
|
if device_class in UNITS_OF_MEASUREMENT
|
||||||
|
@ -118,7 +172,7 @@ async def test_get_conditions_no_state(hass, device_reg, entity_reg):
|
||||||
conditions = await async_get_device_automations(
|
conditions = await async_get_device_automations(
|
||||||
hass, DeviceAutomationType.CONDITION, device_entry.id
|
hass, DeviceAutomationType.CONDITION, device_entry.id
|
||||||
)
|
)
|
||||||
assert conditions == expected_conditions
|
assert_lists_same(conditions, expected_conditions)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
|
|
|
@ -9,11 +9,14 @@ from homeassistant.components.device_automation import DeviceAutomationType
|
||||||
from homeassistant.components.switch import DOMAIN
|
from homeassistant.components.switch import DOMAIN
|
||||||
from homeassistant.const import CONF_PLATFORM, STATE_OFF, STATE_ON
|
from homeassistant.const import CONF_PLATFORM, STATE_OFF, STATE_ON
|
||||||
from homeassistant.helpers import device_registry
|
from homeassistant.helpers import device_registry
|
||||||
|
from homeassistant.helpers.entity import EntityCategory
|
||||||
|
from homeassistant.helpers.entity_registry import RegistryEntryHider
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
import homeassistant.util.dt as dt_util
|
import homeassistant.util.dt as dt_util
|
||||||
|
|
||||||
from tests.common import (
|
from tests.common import (
|
||||||
MockConfigEntry,
|
MockConfigEntry,
|
||||||
|
assert_lists_same,
|
||||||
async_get_device_automation_capabilities,
|
async_get_device_automation_capabilities,
|
||||||
async_get_device_automations,
|
async_get_device_automations,
|
||||||
async_mock_service,
|
async_mock_service,
|
||||||
|
@ -54,22 +57,65 @@ async def test_get_conditions(hass, device_reg, entity_reg):
|
||||||
{
|
{
|
||||||
"condition": "device",
|
"condition": "device",
|
||||||
"domain": DOMAIN,
|
"domain": DOMAIN,
|
||||||
"type": "is_off",
|
"type": condition,
|
||||||
"device_id": device_entry.id,
|
"device_id": device_entry.id,
|
||||||
"entity_id": f"{DOMAIN}.test_5678",
|
"entity_id": f"{DOMAIN}.test_5678",
|
||||||
},
|
"metadata": {"secondary": False},
|
||||||
{
|
}
|
||||||
"condition": "device",
|
for condition in ["is_off", "is_on"]
|
||||||
"domain": DOMAIN,
|
|
||||||
"type": "is_on",
|
|
||||||
"device_id": device_entry.id,
|
|
||||||
"entity_id": f"{DOMAIN}.test_5678",
|
|
||||||
},
|
|
||||||
]
|
]
|
||||||
conditions = await async_get_device_automations(
|
conditions = await async_get_device_automations(
|
||||||
hass, DeviceAutomationType.CONDITION, device_entry.id
|
hass, DeviceAutomationType.CONDITION, device_entry.id
|
||||||
)
|
)
|
||||||
assert conditions == expected_conditions
|
assert_lists_same(conditions, expected_conditions)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
"hidden_by,entity_category",
|
||||||
|
(
|
||||||
|
(RegistryEntryHider.INTEGRATION, None),
|
||||||
|
(RegistryEntryHider.USER, None),
|
||||||
|
(None, EntityCategory.CONFIG),
|
||||||
|
(None, EntityCategory.DIAGNOSTIC),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
async def test_get_conditions_hidden_auxiliary(
|
||||||
|
hass,
|
||||||
|
device_reg,
|
||||||
|
entity_reg,
|
||||||
|
hidden_by,
|
||||||
|
entity_category,
|
||||||
|
):
|
||||||
|
"""Test we get the expected conditions from a hidden or auxiliary entity."""
|
||||||
|
config_entry = MockConfigEntry(domain="test", data={})
|
||||||
|
config_entry.add_to_hass(hass)
|
||||||
|
device_entry = device_reg.async_get_or_create(
|
||||||
|
config_entry_id=config_entry.entry_id,
|
||||||
|
connections={(device_registry.CONNECTION_NETWORK_MAC, "12:34:56:AB:CD:EF")},
|
||||||
|
)
|
||||||
|
entity_reg.async_get_or_create(
|
||||||
|
DOMAIN,
|
||||||
|
"test",
|
||||||
|
"5678",
|
||||||
|
device_id=device_entry.id,
|
||||||
|
entity_category=entity_category,
|
||||||
|
hidden_by=hidden_by,
|
||||||
|
)
|
||||||
|
expected_conditions = [
|
||||||
|
{
|
||||||
|
"condition": "device",
|
||||||
|
"domain": DOMAIN,
|
||||||
|
"type": condition,
|
||||||
|
"device_id": device_entry.id,
|
||||||
|
"entity_id": f"{DOMAIN}.test_5678",
|
||||||
|
"metadata": {"secondary": True},
|
||||||
|
}
|
||||||
|
for condition in ["is_off", "is_on"]
|
||||||
|
]
|
||||||
|
conditions = await async_get_device_automations(
|
||||||
|
hass, DeviceAutomationType.CONDITION, device_entry.id
|
||||||
|
)
|
||||||
|
assert_lists_same(conditions, expected_conditions)
|
||||||
|
|
||||||
|
|
||||||
async def test_get_condition_capabilities(hass, device_reg, entity_reg):
|
async def test_get_condition_capabilities(hass, device_reg, entity_reg):
|
||||||
|
|
|
@ -10,6 +10,8 @@ from homeassistant.components.vacuum import (
|
||||||
STATE_RETURNING,
|
STATE_RETURNING,
|
||||||
)
|
)
|
||||||
from homeassistant.helpers import device_registry
|
from homeassistant.helpers import device_registry
|
||||||
|
from homeassistant.helpers.entity import EntityCategory
|
||||||
|
from homeassistant.helpers.entity_registry import RegistryEntryHider
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
|
|
||||||
from tests.common import (
|
from tests.common import (
|
||||||
|
@ -54,17 +56,60 @@ async def test_get_conditions(hass, device_reg, entity_reg):
|
||||||
{
|
{
|
||||||
"condition": "device",
|
"condition": "device",
|
||||||
"domain": DOMAIN,
|
"domain": DOMAIN,
|
||||||
"type": "is_cleaning",
|
"type": condition,
|
||||||
"device_id": device_entry.id,
|
"device_id": device_entry.id,
|
||||||
"entity_id": f"{DOMAIN}.test_5678",
|
"entity_id": f"{DOMAIN}.test_5678",
|
||||||
},
|
"metadata": {"secondary": False},
|
||||||
|
}
|
||||||
|
for condition in ["is_cleaning", "is_docked"]
|
||||||
|
]
|
||||||
|
conditions = await async_get_device_automations(
|
||||||
|
hass, DeviceAutomationType.CONDITION, device_entry.id
|
||||||
|
)
|
||||||
|
assert_lists_same(conditions, expected_conditions)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
"hidden_by,entity_category",
|
||||||
|
(
|
||||||
|
(RegistryEntryHider.INTEGRATION, None),
|
||||||
|
(RegistryEntryHider.USER, None),
|
||||||
|
(None, EntityCategory.CONFIG),
|
||||||
|
(None, EntityCategory.DIAGNOSTIC),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
async def test_get_conditions_hidden_auxiliary(
|
||||||
|
hass,
|
||||||
|
device_reg,
|
||||||
|
entity_reg,
|
||||||
|
hidden_by,
|
||||||
|
entity_category,
|
||||||
|
):
|
||||||
|
"""Test we get the expected conditions from a hidden or auxiliary entity."""
|
||||||
|
config_entry = MockConfigEntry(domain="test", data={})
|
||||||
|
config_entry.add_to_hass(hass)
|
||||||
|
device_entry = device_reg.async_get_or_create(
|
||||||
|
config_entry_id=config_entry.entry_id,
|
||||||
|
connections={(device_registry.CONNECTION_NETWORK_MAC, "12:34:56:AB:CD:EF")},
|
||||||
|
)
|
||||||
|
entity_reg.async_get_or_create(
|
||||||
|
DOMAIN,
|
||||||
|
"test",
|
||||||
|
"5678",
|
||||||
|
device_id=device_entry.id,
|
||||||
|
entity_category=entity_category,
|
||||||
|
hidden_by=hidden_by,
|
||||||
|
)
|
||||||
|
expected_conditions = [
|
||||||
{
|
{
|
||||||
"condition": "device",
|
"condition": "device",
|
||||||
"domain": DOMAIN,
|
"domain": DOMAIN,
|
||||||
"type": "is_docked",
|
"type": condition,
|
||||||
"device_id": device_entry.id,
|
"device_id": device_entry.id,
|
||||||
"entity_id": f"{DOMAIN}.test_5678",
|
"entity_id": f"{DOMAIN}.test_5678",
|
||||||
},
|
"metadata": {"secondary": True},
|
||||||
|
}
|
||||||
|
for condition in ["is_cleaning", "is_docked"]
|
||||||
]
|
]
|
||||||
conditions = await async_get_device_automations(
|
conditions = await async_get_device_automations(
|
||||||
hass, DeviceAutomationType.CONDITION, device_entry.id
|
hass, DeviceAutomationType.CONDITION, device_entry.id
|
||||||
|
|
|
@ -45,6 +45,7 @@ async def test_get_conditions(hass, client, lock_schlage_be469, integration) ->
|
||||||
"domain": DOMAIN,
|
"domain": DOMAIN,
|
||||||
"type": "node_status",
|
"type": "node_status",
|
||||||
"device_id": device.id,
|
"device_id": device.id,
|
||||||
|
"metadata": {},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"condition": "device",
|
"condition": "device",
|
||||||
|
@ -53,12 +54,14 @@ async def test_get_conditions(hass, client, lock_schlage_be469, integration) ->
|
||||||
"device_id": device.id,
|
"device_id": device.id,
|
||||||
"value_id": value_id,
|
"value_id": value_id,
|
||||||
"subtype": f"{config_value.property_} ({name})",
|
"subtype": f"{config_value.property_} ({name})",
|
||||||
|
"metadata": {},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"condition": "device",
|
"condition": "device",
|
||||||
"domain": DOMAIN,
|
"domain": DOMAIN,
|
||||||
"type": "value",
|
"type": "value",
|
||||||
"device_id": device.id,
|
"device_id": device.id,
|
||||||
|
"metadata": {},
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
conditions = await async_get_device_automations(
|
conditions = await async_get_device_automations(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue