1
0
mirror of https://github.com/home-assistant/core.git synced 2026-04-02 08:26:41 +01:00

Remove number entity support from moisture triggers and conditions (#166596)

This commit is contained in:
Erik Montnemery
2026-03-26 14:40:56 +01:00
committed by Franck Nijhof
parent 16999e3707
commit 2ea4d7913e
6 changed files with 0 additions and 219 deletions

View File

@@ -6,7 +6,6 @@ from homeassistant.components.binary_sensor import (
DOMAIN as BINARY_SENSOR_DOMAIN,
BinarySensorDeviceClass,
)
from homeassistant.components.number import DOMAIN as NUMBER_DOMAIN, NumberDeviceClass
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN, SensorDeviceClass
from homeassistant.const import PERCENTAGE, STATE_OFF, STATE_ON
from homeassistant.core import HomeAssistant
@@ -25,7 +24,6 @@ _MOISTURE_BINARY_DOMAIN_SPECS = {
_MOISTURE_NUMERICAL_DOMAIN_SPECS = {
SENSOR_DOMAIN: DomainSpec(device_class=SensorDeviceClass.MOISTURE),
NUMBER_DOMAIN: DomainSpec(device_class=NumberDeviceClass.MOISTURE),
}
CONDITIONS: dict[str, type[Condition]] = {

View File

@@ -19,8 +19,6 @@
unit_of_measurement: "%"
- domain: sensor
device_class: moisture
- domain: number
device_class: moisture
.moisture_threshold_number: &moisture_threshold_number
min: 0
@@ -37,8 +35,6 @@ is_value:
entity:
- domain: sensor
device_class: moisture
- domain: number
device_class: moisture
fields:
behavior: *condition_behavior
threshold:

View File

@@ -6,7 +6,6 @@ from homeassistant.components.binary_sensor import (
DOMAIN as BINARY_SENSOR_DOMAIN,
BinarySensorDeviceClass,
)
from homeassistant.components.number import DOMAIN as NUMBER_DOMAIN, NumberDeviceClass
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN, SensorDeviceClass
from homeassistant.const import PERCENTAGE, STATE_OFF, STATE_ON
from homeassistant.core import HomeAssistant
@@ -23,7 +22,6 @@ MOISTURE_BINARY_DOMAIN_SPECS: dict[str, DomainSpec] = {
}
MOISTURE_NUMERICAL_DOMAIN_SPECS: dict[str, DomainSpec] = {
NUMBER_DOMAIN: DomainSpec(device_class=NumberDeviceClass.MOISTURE),
SENSOR_DOMAIN: DomainSpec(device_class=SensorDeviceClass.MOISTURE),
}

View File

@@ -13,8 +13,6 @@
.moisture_threshold_entity: &moisture_threshold_entity
- domain: input_number
unit_of_measurement: "%"
- domain: number
device_class: moisture
- domain: sensor
device_class: moisture
@@ -31,8 +29,6 @@
.trigger_numerical_target: &trigger_numerical_target
entity:
- domain: number
device_class: moisture
- domain: sensor
device_class: moisture

View File

@@ -40,12 +40,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",
[
@@ -221,75 +215,3 @@ async def test_moisture_sensor_condition_behavior_all(
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_any(
"moisture.is_value",
device_class="moisture",
unit_attributes=_MOISTURE_UNIT_ATTRS,
),
)
async def test_moisture_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 moisture 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(
"moisture.is_value",
device_class="moisture",
unit_attributes=_MOISTURE_UNIT_ATTRS,
),
)
async def test_moisture_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 moisture 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,
)

View File

@@ -5,7 +5,6 @@ from typing import Any
import pytest
from homeassistant.components.binary_sensor import BinarySensorDeviceClass
from homeassistant.components.number import NumberDeviceClass
from homeassistant.components.sensor import SensorDeviceClass
from homeassistant.const import (
ATTR_DEVICE_CLASS,
@@ -36,12 +35,6 @@ async def target_binary_sensors(hass: HomeAssistant) -> dict[str, list[str]]:
return await target_entities(hass, "binary_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.fixture
async def target_sensors(hass: HomeAssistant) -> dict[str, list[str]]:
"""Create multiple sensor entities associated with different targets."""
@@ -336,128 +329,6 @@ async def test_moisture_trigger_sensor_crossed_threshold_behavior_last(
)
# --- 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(
"moisture.changed",
device_class=NumberDeviceClass.MOISTURE,
unit_attributes={ATTR_UNIT_OF_MEASUREMENT: "%"},
),
*parametrize_numerical_state_value_crossed_threshold_trigger_states(
"moisture.crossed_threshold",
device_class=NumberDeviceClass.MOISTURE,
unit_attributes={ATTR_UNIT_OF_MEASUREMENT: "%"},
),
],
)
async def test_moisture_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 moisture trigger fires for number entities with device_class moisture."""
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(
"moisture.crossed_threshold",
device_class=NumberDeviceClass.MOISTURE,
unit_attributes={ATTR_UNIT_OF_MEASUREMENT: "%"},
),
],
)
async def test_moisture_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 moisture 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(
"moisture.crossed_threshold",
device_class=NumberDeviceClass.MOISTURE,
unit_attributes={ATTR_UNIT_OF_MEASUREMENT: "%"},
),
],
)
async def test_moisture_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 moisture 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,
)
@pytest.mark.usefixtures("enable_labs_preview_features")
@pytest.mark.parametrize(
("trigger", "trigger_options", "limit_entities"),