1
0
mirror of https://github.com/home-assistant/core.git synced 2026-05-08 17:49:37 +01:00

Remove number entity support from power triggers and conditions (#166597)

This commit is contained in:
Erik Montnemery
2026-03-26 16:05:21 +01:00
committed by Franck Nijhof
parent 2ea4d7913e
commit da9d1080d9
6 changed files with 0 additions and 221 deletions
-80
View File
@@ -26,12 +26,6 @@ async def target_sensors(hass: HomeAssistant) -> dict[str, list[str]]:
return await target_entities(hass, "sensor")
@pytest.fixture
async def target_numbers(hass: HomeAssistant) -> dict[str, list[str]]:
"""Create multiple number entities associated with different targets."""
return await target_entities(hass, "number")
@pytest.mark.parametrize(
"condition",
["power.is_value"],
@@ -117,80 +111,6 @@ async def test_power_sensor_condition_behavior_all(
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("number"),
)
@pytest.mark.parametrize(
("condition", "condition_options", "states"),
parametrize_numerical_condition_above_below_any(
"power.is_value",
device_class="power",
threshold_unit=UnitOfPower.WATT,
unit_attributes={ATTR_UNIT_OF_MEASUREMENT: UnitOfPower.WATT},
),
)
async def test_power_number_condition_behavior_any(
hass: HomeAssistant,
target_numbers: dict[str, list[str]],
condition_target_config: dict,
entity_id: str,
entities_in_target: int,
condition: str,
condition_options: dict[str, Any],
states: list[ConditionStateDescription],
) -> None:
"""Test the power number condition with 'any' behavior."""
await assert_condition_behavior_any(
hass,
target_entities=target_numbers,
condition_target_config=condition_target_config,
entity_id=entity_id,
entities_in_target=entities_in_target,
condition=condition,
condition_options=condition_options,
states=states,
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("condition_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("number"),
)
@pytest.mark.parametrize(
("condition", "condition_options", "states"),
parametrize_numerical_condition_above_below_all(
"power.is_value",
device_class="power",
threshold_unit=UnitOfPower.WATT,
unit_attributes={ATTR_UNIT_OF_MEASUREMENT: UnitOfPower.WATT},
),
)
async def test_power_number_condition_behavior_all(
hass: HomeAssistant,
target_numbers: dict[str, list[str]],
condition_target_config: dict,
entity_id: str,
entities_in_target: int,
condition: str,
condition_options: dict[str, Any],
states: list[ConditionStateDescription],
) -> None:
"""Test the power number condition with 'all' behavior."""
await assert_condition_behavior_all(
hass,
target_entities=target_numbers,
condition_target_config=condition_target_config,
entity_id=entity_id,
entities_in_target=entities_in_target,
condition=condition,
condition_options=condition_options,
states=states,
)
@pytest.mark.usefixtures("enable_labs_preview_features")
async def test_power_condition_unit_conversion_sensor(
hass: HomeAssistant,
-133
View File
@@ -4,7 +4,6 @@ from typing import Any
import pytest
from homeassistant.components.number import NumberDeviceClass
from homeassistant.components.sensor import SensorDeviceClass
from homeassistant.const import ATTR_UNIT_OF_MEASUREMENT, UnitOfPower
from homeassistant.core import HomeAssistant
@@ -24,12 +23,6 @@ from tests.components.common import (
_POWER_UNIT_ATTRIBUTES = {ATTR_UNIT_OF_MEASUREMENT: UnitOfPower.WATT}
@pytest.fixture
async def target_numbers(hass: HomeAssistant) -> dict[str, list[str]]:
"""Create multiple number entities associated with different targets."""
return await target_entities(hass, "number")
@pytest.fixture
async def target_sensors(hass: HomeAssistant) -> dict[str, list[str]]:
"""Create multiple sensor entities associated with different targets."""
@@ -171,129 +164,3 @@ async def test_power_trigger_sensor_crossed_threshold_behavior_last(
trigger_options=trigger_options,
states=states,
)
# --- Number entity tests ---
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("number"),
)
@pytest.mark.parametrize(
("trigger", "trigger_options", "states"),
[
*parametrize_numerical_state_value_changed_trigger_states(
"power.changed",
device_class=NumberDeviceClass.POWER,
threshold_unit=UnitOfPower.WATT,
unit_attributes=_POWER_UNIT_ATTRIBUTES,
),
*parametrize_numerical_state_value_crossed_threshold_trigger_states(
"power.crossed_threshold",
device_class=NumberDeviceClass.POWER,
threshold_unit=UnitOfPower.WATT,
unit_attributes=_POWER_UNIT_ATTRIBUTES,
),
],
)
async def test_power_trigger_number_behavior_any(
hass: HomeAssistant,
target_numbers: dict[str, list[str]],
trigger_target_config: dict,
entity_id: str,
entities_in_target: int,
trigger: str,
trigger_options: dict[str, Any],
states: list[TriggerStateDescription],
) -> None:
"""Test power trigger fires for number entities with device_class power."""
await assert_trigger_behavior_any(
hass,
target_entities=target_numbers,
trigger_target_config=trigger_target_config,
entity_id=entity_id,
entities_in_target=entities_in_target,
trigger=trigger,
trigger_options=trigger_options,
states=states,
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("number"),
)
@pytest.mark.parametrize(
("trigger", "trigger_options", "states"),
[
*parametrize_numerical_state_value_crossed_threshold_trigger_states(
"power.crossed_threshold",
device_class=NumberDeviceClass.POWER,
threshold_unit=UnitOfPower.WATT,
unit_attributes=_POWER_UNIT_ATTRIBUTES,
),
],
)
async def test_power_trigger_number_crossed_threshold_behavior_first(
hass: HomeAssistant,
target_numbers: dict[str, list[str]],
trigger_target_config: dict,
entity_id: str,
entities_in_target: int,
trigger: str,
trigger_options: dict[str, Any],
states: list[TriggerStateDescription],
) -> None:
"""Test power crossed_threshold trigger fires on the first number state change."""
await assert_trigger_behavior_first(
hass,
target_entities=target_numbers,
trigger_target_config=trigger_target_config,
entity_id=entity_id,
entities_in_target=entities_in_target,
trigger=trigger,
trigger_options=trigger_options,
states=states,
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger_target_config", "entity_id", "entities_in_target"),
parametrize_target_entities("number"),
)
@pytest.mark.parametrize(
("trigger", "trigger_options", "states"),
[
*parametrize_numerical_state_value_crossed_threshold_trigger_states(
"power.crossed_threshold",
device_class=NumberDeviceClass.POWER,
threshold_unit=UnitOfPower.WATT,
unit_attributes=_POWER_UNIT_ATTRIBUTES,
),
],
)
async def test_power_trigger_number_crossed_threshold_behavior_last(
hass: HomeAssistant,
target_numbers: dict[str, list[str]],
trigger_target_config: dict,
entity_id: str,
entities_in_target: int,
trigger: str,
trigger_options: dict[str, Any],
states: list[TriggerStateDescription],
) -> None:
"""Test power crossed_threshold trigger fires when the last number changes state."""
await assert_trigger_behavior_last(
hass,
target_entities=target_numbers,
trigger_target_config=trigger_target_config,
entity_id=entity_id,
entities_in_target=entities_in_target,
trigger=trigger,
trigger_options=trigger_options,
states=states,
)