Compare commits

..

3 Commits

Author SHA1 Message Date
Paul Bottein
df06a5878c Add windows 98 labs feature 2026-03-10 09:41:49 +01:00
Panda-NZ
a36733c4dc Add ambient temperature range controls to ToGrill integration (#165235) 2026-03-09 23:40:30 +01:00
Bram Kragten
bf846e0756 Validate reorder is only used when multiple is true (#165216) 2026-03-09 22:32:02 +01:00
18 changed files with 1924 additions and 414 deletions

View File

@@ -143,7 +143,6 @@ _EXPERIMENTAL_TRIGGER_PLATFORMS = {
"cover",
"device_tracker",
"door",
"event",
"fan",
"garage_door",
"humidifier",

View File

@@ -12,10 +12,5 @@
"motion": {
"default": "mdi:motion-sensor"
}
},
"triggers": {
"received": {
"trigger": "mdi:eye-check"
}
}
}

View File

@@ -21,17 +21,5 @@
"name": "Motion"
}
},
"title": "Event",
"triggers": {
"received": {
"description": "Triggers after one or more event entities receive a matching event.",
"fields": {
"event_type": {
"description": "The event types to trigger on.",
"name": "Event type"
}
},
"name": "Event received"
}
}
"title": "Event"
}

View File

@@ -1,53 +0,0 @@
"""Provides triggers for events."""
import voluptuous as vol
from homeassistant.const import CONF_OPTIONS
from homeassistant.core import HomeAssistant, State
from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.trigger import (
ENTITY_STATE_TRIGGER_SCHEMA,
EntityTriggerBase,
Trigger,
TriggerConfig,
)
from .const import ATTR_EVENT_TYPE, DOMAIN
CONF_EVENT_TYPE = "event_type"
EVENT_RECEIVED_TRIGGER_SCHEMA = ENTITY_STATE_TRIGGER_SCHEMA.extend(
{
vol.Required(CONF_OPTIONS): {
vol.Required(CONF_EVENT_TYPE): vol.All(
cv.ensure_list, vol.Length(min=1), [cv.string]
),
},
}
)
class EventReceivedTrigger(EntityTriggerBase):
"""Trigger for event entity when it receives a matching event."""
_domains = {DOMAIN}
_schema = EVENT_RECEIVED_TRIGGER_SCHEMA
def __init__(self, hass: HomeAssistant, config: TriggerConfig) -> None:
"""Initialize the event received trigger."""
super().__init__(hass, config)
self._event_types = set(self._options[CONF_EVENT_TYPE])
def is_valid_state(self, state: State) -> bool:
"""Check if the event type matches one of the configured types."""
return state.attributes.get(ATTR_EVENT_TYPE) in self._event_types
TRIGGERS: dict[str, type[Trigger]] = {
"received": EventReceivedTrigger,
}
async def async_get_triggers(hass: HomeAssistant) -> dict[str, type[Trigger]]:
"""Return the triggers for events."""
return TRIGGERS

View File

@@ -1,16 +0,0 @@
received:
target:
entity:
domain: event
fields:
event_type:
context:
filter_target: target
required: true
selector:
state:
attribute: event_type
hide_states:
- unavailable
- unknown
multiple: true

View File

@@ -19,7 +19,7 @@
],
"documentation": "https://www.home-assistant.io/integrations/frontend",
"integration_type": "system",
"preview_features": { "winter_mode": {} },
"preview_features": { "windows_98": {}, "winter_mode": {} },
"quality_scale": "internal",
"requirements": ["home-assistant-frontend==20260304.0"]
}

View File

@@ -1,5 +1,11 @@
{
"preview_features": {
"windows_98": {
"description": "Transforms your dashboard with a nostalgic Windows 98 look.",
"disable_confirmation": "Your dashboard will return to its normal look. You can re-enable this at any time in Labs settings.",
"enable_confirmation": "Your dashboard will be transformed with a Windows 98 theme. You can turn this off at any time in Labs settings.",
"name": "Windows 98"
},
"winter_mode": {
"description": "Adds falling snowflakes on your screen. Get your home ready for winter! ❄️\n\nIf you have animations disabled in your device accessibility settings, this feature will not work.",
"disable_confirmation": "Snowflakes will no longer fall on your screen. You can re-enable this at any time in Labs settings.",

View File

@@ -790,7 +790,6 @@ edit_message:
filter:
domain: notify
integration: telegram_bot
reorder: true
message_id:
required: true
example: "{{ trigger.event.data.message.message_id }}"
@@ -843,7 +842,6 @@ edit_message_media:
filter:
domain: notify
integration: telegram_bot
reorder: true
message_id:
required: true
example: "{{ trigger.event.data.message.message_id }}"
@@ -922,7 +920,6 @@ edit_caption:
filter:
domain: notify
integration: telegram_bot
reorder: true
message_id:
required: true
example: "{{ trigger.event.data.message.message_id }}"
@@ -960,7 +957,6 @@ edit_replymarkup:
filter:
domain: notify
integration: telegram_bot
reorder: true
message_id:
required: true
example: "{{ trigger.event.data.message.message_id }}"
@@ -1015,7 +1011,6 @@ delete_message:
filter:
domain: notify
integration: telegram_bot
reorder: true
message_id:
required: true
example: "{{ trigger.event.data.message.message_id }}"
@@ -1042,7 +1037,6 @@ leave_chat:
filter:
domain: notify
integration: telegram_bot
reorder: true
advanced:
collapsed: true
fields:
@@ -1064,7 +1058,6 @@ set_message_reaction:
filter:
domain: notify
integration: telegram_bot
reorder: true
message_id:
required: true
example: 54321

View File

@@ -32,7 +32,7 @@ from homeassistant.helpers import device_registry as dr
from homeassistant.helpers.device_registry import CONNECTION_BLUETOOTH, DeviceInfo
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
from .const import CONF_PROBE_COUNT, DOMAIN
from .const import CONF_HAS_AMBIENT, CONF_PROBE_COUNT, DOMAIN
type ToGrillConfigEntry = ConfigEntry[ToGrillCoordinator]
@@ -213,6 +213,8 @@ class ToGrillCoordinator(DataUpdateCoordinator[dict[tuple[int, int | None], Pack
await client.request(PacketA1Notify)
for probe in range(1, self.config_entry.data[CONF_PROBE_COUNT] + 1):
await client.write(PacketA8Write(probe=probe))
if self.config_entry.data.get(CONF_HAS_AMBIENT):
await client.write(PacketA8Write(probe=0))
except BleakError as exc:
raise DeviceFailed(f"Device failed {exc}") from exc
return self.data

View File

@@ -27,7 +27,7 @@ from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
from . import ToGrillConfigEntry
from .const import CONF_PROBE_COUNT, MAX_PROBE_COUNT
from .const import CONF_HAS_AMBIENT, CONF_PROBE_COUNT, MAX_PROBE_COUNT
from .coordinator import ToGrillCoordinator
from .entity import ToGrillEntity
@@ -123,12 +123,64 @@ def _get_temperature_descriptions(
)
def _get_ambient_temperatures(
coordinator: ToGrillCoordinator, alarm_type: AlarmType
) -> tuple[float | None, float | None]:
if not (packet := coordinator.get_packet(PacketA8Notify, 0)):
return None, None
if packet.alarm_type != alarm_type:
return None, None
return packet.temperature_1, packet.temperature_2
ENTITY_DESCRIPTIONS = (
*[
description
for probe_number in range(1, MAX_PROBE_COUNT + 1)
for description in _get_temperature_descriptions(probe_number)
],
ToGrillNumberEntityDescription(
key="ambient_temperature_minimum",
translation_key="ambient_temperature_minimum",
device_class=NumberDeviceClass.TEMPERATURE,
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
native_min_value=0,
native_max_value=400,
mode=NumberMode.BOX,
icon="mdi:thermometer-chevron-down",
set_packet=lambda coordinator, value: PacketA300Write(
probe=0,
minimum=None if value == 0.0 else value,
maximum=_get_ambient_temperatures(coordinator, AlarmType.TEMPERATURE_RANGE)[
1
],
),
get_value=lambda x: _get_ambient_temperatures(x, AlarmType.TEMPERATURE_RANGE)[
0
],
entity_supported=lambda x: x.get(CONF_HAS_AMBIENT, False),
),
ToGrillNumberEntityDescription(
key="ambient_temperature_maximum",
translation_key="ambient_temperature_maximum",
device_class=NumberDeviceClass.TEMPERATURE,
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
native_min_value=0,
native_max_value=400,
mode=NumberMode.BOX,
icon="mdi:thermometer-chevron-up",
set_packet=lambda coordinator, value: PacketA300Write(
probe=0,
minimum=_get_ambient_temperatures(coordinator, AlarmType.TEMPERATURE_RANGE)[
0
],
maximum=None if value == 0.0 else value,
),
get_value=lambda x: _get_ambient_temperatures(x, AlarmType.TEMPERATURE_RANGE)[
1
],
entity_supported=lambda x: x.get(CONF_HAS_AMBIENT, False),
),
ToGrillNumberEntityDescription(
key="alarm_interval",
translation_key="alarm_interval",

View File

@@ -55,6 +55,12 @@
"alarm_interval": {
"name": "Alarm interval"
},
"ambient_temperature_maximum": {
"name": "Ambient maximum temperature"
},
"ambient_temperature_minimum": {
"name": "Ambient minimum temperature"
},
"temperature_maximum": {
"name": "Maximum temperature"
},

View File

@@ -19,6 +19,11 @@ LABS_PREVIEW_FEATURES = {
},
},
"frontend": {
"windows_98": {
"feedback_url": "",
"learn_more_url": "",
"report_issue_url": "",
},
"winter_mode": {
"feedback_url": "",
"learn_more_url": "",

View File

@@ -119,6 +119,13 @@ def _validate_supported_features(supported_features: list[str]) -> int:
return feature_mask
def _validate_selector_reorder_config(config: Any) -> Any:
"""Validate selectors with reorder option."""
if config.get("reorder") and not config.get("multiple"):
raise vol.Invalid("reorder can only be used when multiple is true")
return config
def make_selector_config_schema(schema_dict: dict | None = None) -> vol.Schema:
"""Make selector config schema."""
if schema_dict is None:
@@ -310,19 +317,22 @@ class AreaSelector(Selector[AreaSelectorConfig]):
selector_type = "area"
CONFIG_SCHEMA = make_selector_config_schema(
{
vol.Optional("entity"): vol.All(
cv.ensure_list,
[ENTITY_FILTER_SELECTOR_CONFIG_SCHEMA],
),
vol.Optional("device"): vol.All(
cv.ensure_list,
[DEVICE_FILTER_SELECTOR_CONFIG_SCHEMA],
),
vol.Optional("multiple", default=False): cv.boolean,
vol.Optional("reorder", default=False): cv.boolean,
}
CONFIG_SCHEMA = vol.All(
make_selector_config_schema(
{
vol.Optional("entity"): vol.All(
cv.ensure_list,
[ENTITY_FILTER_SELECTOR_CONFIG_SCHEMA],
),
vol.Optional("device"): vol.All(
cv.ensure_list,
[DEVICE_FILTER_SELECTOR_CONFIG_SCHEMA],
),
vol.Optional("multiple", default=False): cv.boolean,
vol.Optional("reorder", default=False): cv.boolean,
}
),
_validate_selector_reorder_config,
)
def __init__(self, config: AreaSelectorConfig | None = None) -> None:
@@ -894,18 +904,21 @@ class EntitySelector(Selector[EntitySelectorConfig]):
selector_type = "entity"
CONFIG_SCHEMA = make_selector_config_schema(
{
**_LEGACY_ENTITY_SELECTOR_CONFIG_SCHEMA_DICT,
vol.Optional("exclude_entities"): [str],
vol.Optional("include_entities"): [str],
vol.Optional("multiple", default=False): cv.boolean,
vol.Optional("reorder", default=False): cv.boolean,
vol.Optional("filter"): vol.All(
cv.ensure_list,
[ENTITY_FILTER_SELECTOR_CONFIG_SCHEMA],
),
}
CONFIG_SCHEMA = vol.All(
make_selector_config_schema(
{
**_LEGACY_ENTITY_SELECTOR_CONFIG_SCHEMA_DICT,
vol.Optional("exclude_entities"): [str],
vol.Optional("include_entities"): [str],
vol.Optional("multiple", default=False): cv.boolean,
vol.Optional("reorder", default=False): cv.boolean,
vol.Optional("filter"): vol.All(
cv.ensure_list,
[ENTITY_FILTER_SELECTOR_CONFIG_SCHEMA],
),
}
),
_validate_selector_reorder_config,
)
def __init__(self, config: EntitySelectorConfig | None = None) -> None:
@@ -1517,7 +1530,11 @@ class StateSelector(Selector[StateSelectorConfig]):
{
vol.Optional("entity_id"): cv.entity_id,
vol.Optional("hide_states"): [str],
vol.Optional("attribute"): str,
# The attribute to filter on, is currently deliberately not
# configurable/exposed. We are considering separating state
# selectors into two types: one for state and one for attribute.
# Limiting the public use, prevents breaking changes in the future.
# vol.Optional("attribute"): str,
vol.Optional("multiple", default=False): cv.boolean,
}
)

View File

@@ -1114,10 +1114,7 @@ async def _async_get_trigger_platform(
platform_and_sub_type = trigger_key.split(".")
platform = platform_and_sub_type[0]
# Only apply aliases for old-style triggers (no sub_type).
# New-style triggers (e.g. "event.received") use the integration domain directly.
if len(platform_and_sub_type) == 1:
platform = _PLATFORM_ALIASES.get(platform, platform)
platform = _PLATFORM_ALIASES.get(platform, platform)
if automation.is_disabled_experimental_trigger(hass, platform):
raise vol.Invalid(

View File

@@ -1,286 +0,0 @@
"""Test event trigger."""
import pytest
from homeassistant.components.event.const import ATTR_EVENT_TYPE
from homeassistant.const import (
ATTR_LABEL_ID,
CONF_ENTITY_ID,
STATE_UNAVAILABLE,
STATE_UNKNOWN,
)
from homeassistant.core import HomeAssistant, ServiceCall
from tests.components import (
TriggerStateDescription,
arm_trigger,
parametrize_target_entities,
set_or_remove_state,
target_entities,
)
@pytest.fixture
async def target_events(hass: HomeAssistant) -> list[str]:
"""Create multiple event entities associated with different targets."""
return (await target_entities(hass, "event"))["included"]
@pytest.mark.parametrize("trigger_key", ["event.received"])
async def test_event_triggers_gated_by_labs_flag(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, trigger_key: str
) -> None:
"""Test the event triggers are gated by the labs flag."""
await arm_trigger(hass, trigger_key, None, {ATTR_LABEL_ID: "test_label"})
assert (
"Unnamed automation failed to setup triggers and has been disabled: Trigger "
f"'{trigger_key}' requires the experimental 'New triggers and conditions' "
"feature to be enabled in Home Assistant Labs settings (feature flag: "
"'new_triggers_conditions')"
) in caplog.text
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("event"),
)
@pytest.mark.parametrize(
("trigger", "trigger_options", "states"),
[
# Event received with matching event_type
(
"event.received",
{"event_type": ["button_press"]},
[
{"included": {"state": None, "attributes": {}}, "count": 0},
{
"included": {
"state": "2026-01-01T00:00:00.000+00:00",
"attributes": {ATTR_EVENT_TYPE: "button_press"},
},
"count": 0,
},
{
"included": {
"state": "2026-01-01T00:00:01.000+00:00",
"attributes": {ATTR_EVENT_TYPE: "button_press"},
},
"count": 1,
},
],
),
# Event received with non-matching event_type then matching
(
"event.received",
{"event_type": ["button_press"]},
[
{"included": {"state": None, "attributes": {}}, "count": 0},
{
"included": {
"state": "2026-01-01T00:00:00.000+00:00",
"attributes": {ATTR_EVENT_TYPE: "other_event"},
},
"count": 0,
},
{
"included": {
"state": "2026-01-01T00:00:01.000+00:00",
"attributes": {ATTR_EVENT_TYPE: "button_press"},
},
"count": 1,
},
],
),
# Multiple event types configured
(
"event.received",
{"event_type": ["button_press", "button_long_press"]},
[
{
"included": {
"state": "2026-01-01T00:00:00.000+00:00",
"attributes": {ATTR_EVENT_TYPE: "button_press"},
},
"count": 0,
},
{
"included": {
"state": "2026-01-01T00:00:01.000+00:00",
"attributes": {ATTR_EVENT_TYPE: "button_long_press"},
},
"count": 1,
},
{
"included": {
"state": "2026-01-01T00:00:02.000+00:00",
"attributes": {ATTR_EVENT_TYPE: "other_event"},
},
"count": 0,
},
{
"included": {
"state": "2026-01-01T00:00:03.000+00:00",
"attributes": {ATTR_EVENT_TYPE: "button_press"},
},
"count": 1,
},
],
),
# From unavailable - first valid state after unavailable is not triggered
(
"event.received",
{"event_type": ["button_press"]},
[
{
"included": {
"state": STATE_UNAVAILABLE,
"attributes": {},
},
"count": 0,
},
{
"included": {
"state": "2026-01-01T00:00:00.000+00:00",
"attributes": {ATTR_EVENT_TYPE: "button_press"},
},
"count": 0,
},
{
"included": {
"state": "2026-01-01T00:00:01.000+00:00",
"attributes": {ATTR_EVENT_TYPE: "button_press"},
},
"count": 1,
},
],
),
# From unknown - first valid state after unknown is not triggered
(
"event.received",
{"event_type": ["button_press"]},
[
{
"included": {
"state": STATE_UNKNOWN,
"attributes": {},
},
"count": 0,
},
{
"included": {
"state": "2026-01-01T00:00:00.000+00:00",
"attributes": {ATTR_EVENT_TYPE: "button_press"},
},
"count": 0,
},
{
"included": {
"state": "2026-01-01T00:00:01.000+00:00",
"attributes": {ATTR_EVENT_TYPE: "button_press"},
},
"count": 1,
},
],
),
# Same event type fires again (different timestamps)
(
"event.received",
{"event_type": ["button_press"]},
[
{
"included": {
"state": "2026-01-01T00:00:00.000+00:00",
"attributes": {ATTR_EVENT_TYPE: "button_press"},
},
"count": 0,
},
{
"included": {
"state": "2026-01-01T00:00:01.000+00:00",
"attributes": {ATTR_EVENT_TYPE: "button_press"},
},
"count": 1,
},
{
"included": {
"state": "2026-01-01T00:00:02.000+00:00",
"attributes": {ATTR_EVENT_TYPE: "button_press"},
},
"count": 1,
},
],
),
# To unavailable - should not trigger, and first state after unavailable is skipped
(
"event.received",
{"event_type": ["button_press"]},
[
{
"included": {
"state": "2026-01-01T00:00:00.000+00:00",
"attributes": {ATTR_EVENT_TYPE: "button_press"},
},
"count": 0,
},
{
"included": {
"state": STATE_UNAVAILABLE,
"attributes": {},
},
"count": 0,
},
{
"included": {
"state": "2026-01-01T00:00:01.000+00:00",
"attributes": {ATTR_EVENT_TYPE: "button_press"},
},
"count": 0,
},
{
"included": {
"state": "2026-01-01T00:00:02.000+00:00",
"attributes": {ATTR_EVENT_TYPE: "button_press"},
},
"count": 1,
},
],
),
],
)
async def test_event_state_trigger_behavior_any(
hass: HomeAssistant,
service_calls: list[ServiceCall],
target_events: list[str],
trigger_target_config: dict,
entity_id: str,
entities_in_target: int,
trigger: str,
trigger_options: dict,
states: list[TriggerStateDescription],
) -> None:
"""Test that the event trigger fires when an event entity receives a matching event."""
other_entity_ids = set(target_events) - {entity_id}
# Set all events to the initial state
for eid in target_events:
set_or_remove_state(hass, eid, states[0]["included"])
await hass.async_block_till_done()
await arm_trigger(hass, trigger, trigger_options, trigger_target_config)
for state in states[1:]:
included_state = state["included"]
set_or_remove_state(hass, entity_id, included_state)
await hass.async_block_till_done()
assert len(service_calls) == state["count"]
for service_call in service_calls:
assert service_call.data[CONF_ENTITY_ID] == entity_id
service_calls.clear()
# Check if changing other events also triggers
for other_entity_id in other_entity_ids:
set_or_remove_state(hass, other_entity_id, included_state)
await hass.async_block_till_done()
assert len(service_calls) == (entities_in_target - 1) * state["count"]
service_calls.clear()

File diff suppressed because it is too large Load Diff

View File

@@ -77,6 +77,150 @@ async def test_setup(
await snapshot_platform(hass, entity_registry, snapshot, mock_entry.entry_id)
@pytest.mark.parametrize(
"packets",
[
pytest.param([], id="no_data"),
pytest.param(
[
PacketA8Notify(
probe=0,
alarm_type=PacketA8Notify.AlarmType.TEMPERATURE_RANGE,
temperature_1=5.0,
temperature_2=300.0,
),
],
id="ambient_with_range",
),
pytest.param(
[
PacketA8Notify(
probe=0,
alarm_type=None,
temperature_1=5.0,
temperature_2=300.0,
),
],
id="ambient_wrong_alarm_type",
),
],
)
async def test_setup_with_ambient(
hass: HomeAssistant,
entity_registry: er.EntityRegistry,
snapshot: SnapshotAssertion,
mock_entry_with_ambient: MockConfigEntry,
mock_client: Mock,
packets,
) -> None:
"""Test the numbers with ambient sensor enabled."""
inject_bluetooth_service_info(hass, TOGRILL_SERVICE_INFO)
await setup_entry(hass, mock_entry_with_ambient, [Platform.NUMBER])
for packet in packets:
mock_client.mocked_notify(packet)
await snapshot_platform(
hass, entity_registry, snapshot, mock_entry_with_ambient.entry_id
)
@pytest.mark.parametrize(
("packets", "entity_id", "value", "write_packet"),
[
pytest.param(
[
PacketA8Notify(
probe=0,
alarm_type=PacketA8Notify.AlarmType.TEMPERATURE_RANGE,
temperature_1=5.0,
temperature_2=300.0,
),
],
"number.pro_05_ambient_minimum_temperature",
10.0,
PacketA300Write(probe=0, minimum=10.0, maximum=300.0),
id="ambient_minimum",
),
pytest.param(
[
PacketA8Notify(
probe=0,
alarm_type=PacketA8Notify.AlarmType.TEMPERATURE_RANGE,
temperature_1=5.0,
temperature_2=300.0,
),
],
"number.pro_05_ambient_minimum_temperature",
0.0,
PacketA300Write(probe=0, minimum=None, maximum=300.0),
id="ambient_minimum_clear",
),
pytest.param(
[
PacketA8Notify(
probe=0,
alarm_type=PacketA8Notify.AlarmType.TEMPERATURE_RANGE,
temperature_1=5.0,
temperature_2=300.0,
),
],
"number.pro_05_ambient_maximum_temperature",
350.0,
PacketA300Write(probe=0, minimum=5.0, maximum=350.0),
id="ambient_maximum",
),
pytest.param(
[
PacketA8Notify(
probe=0,
alarm_type=PacketA8Notify.AlarmType.TEMPERATURE_RANGE,
temperature_1=5.0,
temperature_2=300.0,
),
],
"number.pro_05_ambient_maximum_temperature",
0.0,
PacketA300Write(probe=0, minimum=5.0, maximum=None),
id="ambient_maximum_clear",
),
],
)
async def test_set_ambient_number(
hass: HomeAssistant,
mock_entry_with_ambient: MockConfigEntry,
mock_client: Mock,
packets,
entity_id,
value,
write_packet,
) -> None:
"""Test setting ambient temperature numbers."""
inject_bluetooth_service_info(hass, TOGRILL_SERVICE_INFO)
await setup_entry(hass, mock_entry_with_ambient, [Platform.NUMBER])
for packet in packets:
mock_client.mocked_notify(packet)
await hass.services.async_call(
NUMBER_DOMAIN,
SERVICE_SET_VALUE,
service_data={
ATTR_VALUE: value,
},
target={
ATTR_ENTITY_ID: entity_id,
},
blocking=True,
)
mock_client.write.assert_any_call(write_packet)
@pytest.mark.parametrize(
("packets", "entity_id", "value", "write_packet"),
[

View File

@@ -319,6 +319,9 @@ def test_entity_selector_schema(schema, valid_selections, invalid_selections) ->
{"filter": [{"supported_features": ["light.LightEntityFeature.blah"]}]},
# supported_features should be used under the filter key
{"supported_features": ["light.LightEntityFeature.EFFECT"]},
# reorder can only be used when multiple is true
{"reorder": True},
{"reorder": True, "multiple": False},
],
)
def test_entity_selector_schema_error(schema) -> None:
@@ -394,6 +397,20 @@ def test_area_selector_schema(schema, valid_selections, invalid_selections) -> N
_test_selector("area", schema, valid_selections, invalid_selections)
@pytest.mark.parametrize(
"schema",
[
# reorder can only be used when multiple is true
{"reorder": True},
{"reorder": True, "multiple": False},
],
)
def test_area_selector_schema_error(schema) -> None:
"""Test area selector."""
with pytest.raises(vol.Invalid):
selector.validate_selector({"area": schema})
@pytest.mark.parametrize(
("schema", "valid_selections", "invalid_selections"),
[