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

Remove _get_tracked_value from base class

This commit is contained in:
Erik
2026-03-23 07:53:02 +01:00
parent 4fc68b0adf
commit b3c8fd7249

View File

@@ -5,7 +5,7 @@ from __future__ import annotations
import abc
import asyncio
from collections import defaultdict
from collections.abc import Callable, Coroutine, Hashable, Iterable, Mapping
from collections.abc import Callable, Coroutine, Iterable, Mapping
from dataclasses import dataclass, field
from enum import StrEnum
import functools
@@ -337,9 +337,7 @@ ENTITY_STATE_TRIGGER_SCHEMA_FIRST_LAST = ENTITY_STATE_TRIGGER_SCHEMA.extend(
)
class EntityTriggerBase[DomainSpecT: DomainSpec = DomainSpec, StateT: Hashable = str](
Trigger
):
class EntityTriggerBase[DomainSpecT: DomainSpec = DomainSpec](Trigger):
"""Trigger for entity state changes."""
_domain_specs: Mapping[str, DomainSpecT]
@@ -365,10 +363,6 @@ class EntityTriggerBase[DomainSpecT: DomainSpec = DomainSpec, StateT: Hashable =
"""Filter entities matching any of the domain specs."""
return filter_by_domain_specs(self._hass, self._domain_specs, entities)
@abc.abstractmethod
def _get_tracked_value(self, state: State) -> StateT | None:
"""Get the tracked value from a state based on the DomainSpec."""
@abc.abstractmethod
def is_valid_transition(self, from_state: State, to_state: State) -> bool:
"""Check if the origin state is valid and the state has changed."""
@@ -452,7 +446,7 @@ class EntityTriggerBase[DomainSpecT: DomainSpec = DomainSpec, StateT: Hashable =
class StringEntityTriggerBase[DomainSpecT: DomainSpec = DomainSpec](
EntityTriggerBase[DomainSpecT, str]
EntityTriggerBase[DomainSpecT]
):
"""Trigger for string based entity state changes."""
@@ -614,9 +608,7 @@ NUMERICAL_ATTRIBUTE_CHANGED_TRIGGER_SCHEMA = ENTITY_STATE_TRIGGER_SCHEMA.extend(
)
class EntityNumericalStateTriggerBase(
EntityTriggerBase[NumericalDomainSpec, float | None]
):
class EntityNumericalStateTriggerBase(EntityTriggerBase[NumericalDomainSpec]):
"""Base class for numerical state and state attribute triggers."""
def _get_numerical_value(self, entity_or_float: float | str) -> float | None: