Replace EventType with Event [l-s] (#112741)
parent
8f1e2f1a7b
commit
84c44c1835
|
@ -28,7 +28,6 @@ from homeassistant.helpers.event import (
|
|||
EventStateChangedData,
|
||||
async_track_state_change_event,
|
||||
)
|
||||
from homeassistant.helpers.typing import EventType
|
||||
|
||||
from .const import ALWAYS_CONTINUOUS_DOMAINS, AUTOMATION_EVENTS, BUILT_IN_EVENTS, DOMAIN
|
||||
from .models import LogbookConfig
|
||||
|
@ -189,7 +188,7 @@ def async_subscribe_events(
|
|||
return
|
||||
|
||||
@callback
|
||||
def _forward_state_events_filtered(event: EventType[EventStateChangedData]) -> None:
|
||||
def _forward_state_events_filtered(event: Event[EventStateChangedData]) -> None:
|
||||
if (old_state := event.data["old_state"]) is None or (
|
||||
new_state := event.data["new_state"]
|
||||
) is None:
|
||||
|
|
|
@ -28,7 +28,7 @@ from homeassistant.const import (
|
|||
STATE_ALARM_PENDING,
|
||||
STATE_ALARM_TRIGGERED,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.core import Event, HomeAssistant, callback
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
@ -37,7 +37,7 @@ from homeassistant.helpers.event import (
|
|||
async_track_point_in_time,
|
||||
async_track_state_change_event,
|
||||
)
|
||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType, EventType
|
||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||
import homeassistant.util.dt as dt_util
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
@ -483,7 +483,7 @@ class ManualMQTTAlarm(alarm.AlarmControlPanelEntity):
|
|||
)
|
||||
|
||||
async def _async_state_changed_listener(
|
||||
self, event: EventType[EventStateChangedData]
|
||||
self, event: Event[EventStateChangedData]
|
||||
) -> None:
|
||||
"""Publish state change to MQTT."""
|
||||
if (new_state := event.data["new_state"]) is None:
|
||||
|
|
|
@ -23,7 +23,7 @@ from homeassistant.const import (
|
|||
STATE_UNAVAILABLE,
|
||||
STATE_UNKNOWN,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.core import Event, HomeAssistant, callback
|
||||
from homeassistant.helpers import config_validation as cv, entity_registry as er
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.event import (
|
||||
|
@ -31,12 +31,7 @@ from homeassistant.helpers.event import (
|
|||
async_track_state_change_event,
|
||||
)
|
||||
from homeassistant.helpers.reload import async_setup_reload_service
|
||||
from homeassistant.helpers.typing import (
|
||||
ConfigType,
|
||||
DiscoveryInfoType,
|
||||
EventType,
|
||||
StateType,
|
||||
)
|
||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType, StateType
|
||||
|
||||
from . import PLATFORMS
|
||||
from .const import CONF_ENTITY_IDS, CONF_ROUND_DIGITS, DOMAIN
|
||||
|
@ -258,7 +253,7 @@ class MinMaxSensor(SensorEntity):
|
|||
# Replay current state of source entities
|
||||
for entity_id in self._entity_ids:
|
||||
state = self.hass.states.get(entity_id)
|
||||
state_event: EventType[EventStateChangedData] = EventType(
|
||||
state_event: Event[EventStateChangedData] = Event(
|
||||
"", {"entity_id": entity_id, "new_state": state, "old_state": None}
|
||||
)
|
||||
self._async_min_max_sensor_state_listener(state_event, update_state=False)
|
||||
|
@ -293,7 +288,7 @@ class MinMaxSensor(SensorEntity):
|
|||
|
||||
@callback
|
||||
def _async_min_max_sensor_state_listener(
|
||||
self, event: EventType[EventStateChangedData], update_state: bool = True
|
||||
self, event: Event[EventStateChangedData], update_state: bool = True
|
||||
) -> None:
|
||||
"""Handle the sensor state changes."""
|
||||
new_state = event.data["new_state"]
|
||||
|
|
|
@ -17,14 +17,14 @@ from homeassistant.const import (
|
|||
STATE_UNKNOWN,
|
||||
UnitOfTemperature,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant, State, callback
|
||||
from homeassistant.core import Event, HomeAssistant, State, callback
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.event import (
|
||||
EventStateChangedData,
|
||||
async_track_state_change_event,
|
||||
)
|
||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType, EventType
|
||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||
from homeassistant.util.unit_conversion import TemperatureConverter
|
||||
from homeassistant.util.unit_system import METRIC_SYSTEM
|
||||
|
||||
|
@ -122,7 +122,7 @@ class MoldIndicator(SensorEntity):
|
|||
|
||||
@callback
|
||||
def mold_indicator_sensors_state_listener(
|
||||
event: EventType[EventStateChangedData],
|
||||
event: Event[EventStateChangedData],
|
||||
) -> None:
|
||||
"""Handle for state changes for dependent sensors."""
|
||||
new_state = event.data["new_state"]
|
||||
|
|
|
@ -30,7 +30,7 @@ from homeassistant.const import (
|
|||
CONF_UNIQUE_ID,
|
||||
CONF_VALUE_TEMPLATE,
|
||||
)
|
||||
from homeassistant.core import CALLBACK_TYPE, HomeAssistant, callback
|
||||
from homeassistant.core import CALLBACK_TYPE, Event, HomeAssistant, callback
|
||||
from homeassistant.helpers import (
|
||||
config_validation as cv,
|
||||
device_registry as dr,
|
||||
|
@ -873,7 +873,7 @@ class MqttDiscoveryDeviceUpdate(ABC):
|
|||
return
|
||||
|
||||
async def _async_device_removed(
|
||||
self, event: EventType[EventDeviceRegistryUpdatedData]
|
||||
self, event: Event[EventDeviceRegistryUpdatedData]
|
||||
) -> None:
|
||||
"""Handle the manual removal of a device."""
|
||||
if self._skip_device_removal or not async_removed_from_device(
|
||||
|
@ -1344,7 +1344,7 @@ def update_device(
|
|||
@callback
|
||||
def async_removed_from_device(
|
||||
hass: HomeAssistant,
|
||||
event: EventType[EventDeviceRegistryUpdatedData],
|
||||
event: Event[EventDeviceRegistryUpdatedData],
|
||||
mqtt_device_id: str,
|
||||
config_entry_id: str,
|
||||
) -> bool:
|
||||
|
|
|
@ -54,7 +54,7 @@ from homeassistant.helpers.event import (
|
|||
)
|
||||
from homeassistant.helpers.restore_state import RestoreEntity
|
||||
from homeassistant.helpers.storage import Store
|
||||
from homeassistant.helpers.typing import ConfigType, EventType
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
from homeassistant.loader import bind_hass
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
@ -518,9 +518,7 @@ class Person(collection.CollectionEntity, RestoreEntity):
|
|||
self._update_state()
|
||||
|
||||
@callback
|
||||
def _async_handle_tracker_update(
|
||||
self, event: EventType[EventStateChangedData]
|
||||
) -> None:
|
||||
def _async_handle_tracker_update(self, event: Event[EventStateChangedData]) -> None:
|
||||
"""Handle the device tracker state changes."""
|
||||
self._update_state()
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ from homeassistant.const import (
|
|||
STATE_UNKNOWN,
|
||||
UnitOfTemperature,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant, State, callback
|
||||
from homeassistant.core import Event, HomeAssistant, State, callback
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity import Entity
|
||||
|
@ -29,7 +29,7 @@ from homeassistant.helpers.event import (
|
|||
EventStateChangedData,
|
||||
async_track_state_change_event,
|
||||
)
|
||||
from homeassistant.helpers.typing import ConfigType, EventType
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
from homeassistant.util import dt as dt_util
|
||||
|
||||
from .const import (
|
||||
|
@ -180,7 +180,7 @@ class Plant(Entity):
|
|||
self._brightness_history = DailyHistory(self._conf_check_days)
|
||||
|
||||
@callback
|
||||
def _state_changed_event(self, event: EventType[EventStateChangedData]) -> None:
|
||||
def _state_changed_event(self, event: Event[EventStateChangedData]) -> None:
|
||||
"""Sensor state change event."""
|
||||
self.state_changed(event.data["entity_id"], event.data["new_state"])
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ from homeassistant.const import (
|
|||
STATE_UNKNOWN,
|
||||
UnitOfTemperature,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant, State
|
||||
from homeassistant.core import Event, HomeAssistant, State
|
||||
from homeassistant.helpers import entityfilter, state as state_helper
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity_registry import (
|
||||
|
@ -58,7 +58,7 @@ from homeassistant.helpers.entity_registry import (
|
|||
)
|
||||
from homeassistant.helpers.entity_values import EntityValues
|
||||
from homeassistant.helpers.event import EventStateChangedData
|
||||
from homeassistant.helpers.typing import ConfigType, EventType
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
from homeassistant.util.dt import as_timestamp
|
||||
from homeassistant.util.unit_conversion import TemperatureConverter
|
||||
|
||||
|
@ -180,9 +180,7 @@ class PrometheusMetrics:
|
|||
self._metrics: dict[str, MetricWrapperBase] = {}
|
||||
self._climate_units = climate_units
|
||||
|
||||
def handle_state_changed_event(
|
||||
self, event: EventType[EventStateChangedData]
|
||||
) -> None:
|
||||
def handle_state_changed_event(self, event: Event[EventStateChangedData]) -> None:
|
||||
"""Handle new messages from the bus."""
|
||||
if (state := event.data.get("new_state")) is None:
|
||||
return
|
||||
|
@ -232,7 +230,7 @@ class PrometheusMetrics:
|
|||
last_updated_time_seconds.labels(**labels).set(state.last_updated.timestamp())
|
||||
|
||||
def handle_entity_registry_updated(
|
||||
self, event: EventType[EventEntityRegistryUpdatedData]
|
||||
self, event: Event[EventEntityRegistryUpdatedData]
|
||||
) -> None:
|
||||
"""Listen for deleted, disabled or renamed entities and remove them from the Prometheus Registry."""
|
||||
if event.data["action"] in (None, "create"):
|
||||
|
|
|
@ -25,7 +25,7 @@ from homeassistant.const import (
|
|||
CONF_LONGITUDE,
|
||||
CONF_SHOW_ON_MAP,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.core import Event, HomeAssistant, callback
|
||||
from homeassistant.helpers import (
|
||||
aiohttp_client,
|
||||
config_validation as cv,
|
||||
|
@ -42,7 +42,6 @@ from homeassistant.helpers.selector import (
|
|||
SelectSelectorConfig,
|
||||
SelectSelectorMode,
|
||||
)
|
||||
from homeassistant.helpers.typing import EventType
|
||||
|
||||
from .const import CONF_SENSOR_INDICES, DOMAIN, LOGGER
|
||||
|
||||
|
@ -436,7 +435,7 @@ class PurpleAirOptionsFlowHandler(OptionsFlow):
|
|||
|
||||
@callback
|
||||
def async_device_entity_state_changed(
|
||||
_: EventType[EventStateChangedData],
|
||||
_: Event[EventStateChangedData],
|
||||
) -> None:
|
||||
"""Listen and respond when all device entities are removed."""
|
||||
if all(
|
||||
|
|
|
@ -34,6 +34,7 @@ from homeassistant.const import (
|
|||
)
|
||||
from homeassistant.core import (
|
||||
CALLBACK_TYPE,
|
||||
Event,
|
||||
HomeAssistant,
|
||||
State,
|
||||
callback,
|
||||
|
@ -48,12 +49,7 @@ from homeassistant.helpers.event import (
|
|||
)
|
||||
from homeassistant.helpers.reload import async_setup_reload_service
|
||||
from homeassistant.helpers.start import async_at_start
|
||||
from homeassistant.helpers.typing import (
|
||||
ConfigType,
|
||||
DiscoveryInfoType,
|
||||
EventType,
|
||||
StateType,
|
||||
)
|
||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType, StateType
|
||||
from homeassistant.util import dt as dt_util
|
||||
from homeassistant.util.enum import try_parse_enum
|
||||
|
||||
|
@ -335,7 +331,7 @@ class StatisticsSensor(SensorEntity):
|
|||
|
||||
@callback
|
||||
def async_stats_sensor_state_listener(
|
||||
event: EventType[EventStateChangedData],
|
||||
event: Event[EventStateChangedData],
|
||||
) -> None:
|
||||
"""Handle the sensor state changes."""
|
||||
if (new_state := event.data["new_state"]) is None:
|
||||
|
|
|
@ -16,7 +16,7 @@ from homeassistant.const import (
|
|||
STATE_ON,
|
||||
STATE_UNAVAILABLE,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.core import Event, HomeAssistant, callback
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
@ -24,7 +24,7 @@ from homeassistant.helpers.event import (
|
|||
EventStateChangedData,
|
||||
async_track_state_change_event,
|
||||
)
|
||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType, EventType
|
||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||
|
||||
from .const import DOMAIN as SWITCH_DOMAIN
|
||||
|
||||
|
@ -98,7 +98,7 @@ class LightSwitch(LightEntity):
|
|||
|
||||
@callback
|
||||
def async_state_changed_listener(
|
||||
event: EventType[EventStateChangedData] | None = None,
|
||||
event: Event[EventStateChangedData] | None = None,
|
||||
) -> None:
|
||||
"""Handle child updates."""
|
||||
if (
|
||||
|
|
|
@ -18,11 +18,10 @@ from homeassistant.const import (
|
|||
SERVICE_TURN_ON,
|
||||
STATE_ON,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.core import Event, HomeAssistant, callback
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.event import EventStateChangedData
|
||||
from homeassistant.helpers.typing import EventType
|
||||
|
||||
from .const import CONF_INVERT
|
||||
from .entity import BaseInvertableEntity
|
||||
|
@ -80,7 +79,7 @@ class CoverSwitch(BaseInvertableEntity, CoverEntity):
|
|||
|
||||
@callback
|
||||
def async_state_changed_listener(
|
||||
self, event: EventType[EventStateChangedData] | None = None
|
||||
self, event: Event[EventStateChangedData] | None = None
|
||||
) -> None:
|
||||
"""Handle child updates."""
|
||||
super().async_state_changed_listener(event)
|
||||
|
|
|
@ -13,7 +13,7 @@ from homeassistant.const import (
|
|||
STATE_ON,
|
||||
STATE_UNAVAILABLE,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.core import Event, HomeAssistant, callback
|
||||
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
||||
from homeassistant.helpers.device_registry import DeviceInfo
|
||||
from homeassistant.helpers.entity import Entity, ToggleEntity
|
||||
|
@ -21,7 +21,6 @@ from homeassistant.helpers.event import (
|
|||
EventStateChangedData,
|
||||
async_track_state_change_event,
|
||||
)
|
||||
from homeassistant.helpers.typing import EventType
|
||||
|
||||
from .const import DOMAIN as SWITCH_AS_X_DOMAIN
|
||||
|
||||
|
@ -70,7 +69,7 @@ class BaseEntity(Entity):
|
|||
|
||||
@callback
|
||||
def async_state_changed_listener(
|
||||
self, event: EventType[EventStateChangedData] | None = None
|
||||
self, event: Event[EventStateChangedData] | None = None
|
||||
) -> None:
|
||||
"""Handle child updates."""
|
||||
if (
|
||||
|
@ -86,7 +85,7 @@ class BaseEntity(Entity):
|
|||
|
||||
@callback
|
||||
def _async_state_changed_listener(
|
||||
event: EventType[EventStateChangedData] | None = None,
|
||||
event: Event[EventStateChangedData] | None = None,
|
||||
) -> None:
|
||||
"""Handle child updates."""
|
||||
self.async_state_changed_listener(event)
|
||||
|
@ -173,7 +172,7 @@ class BaseToggleEntity(BaseEntity, ToggleEntity):
|
|||
|
||||
@callback
|
||||
def async_state_changed_listener(
|
||||
self, event: EventType[EventStateChangedData] | None = None
|
||||
self, event: Event[EventStateChangedData] | None = None
|
||||
) -> None:
|
||||
"""Handle child updates."""
|
||||
super().async_state_changed_listener(event)
|
||||
|
|
|
@ -14,11 +14,10 @@ from homeassistant.const import (
|
|||
SERVICE_TURN_ON,
|
||||
STATE_ON,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.core import Event, HomeAssistant, callback
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.event import EventStateChangedData
|
||||
from homeassistant.helpers.typing import EventType
|
||||
|
||||
from .const import CONF_INVERT
|
||||
from .entity import BaseInvertableEntity
|
||||
|
@ -74,7 +73,7 @@ class LockSwitch(BaseInvertableEntity, LockEntity):
|
|||
|
||||
@callback
|
||||
def async_state_changed_listener(
|
||||
self, event: EventType[EventStateChangedData] | None = None
|
||||
self, event: Event[EventStateChangedData] | None = None
|
||||
) -> None:
|
||||
"""Handle child updates."""
|
||||
super().async_state_changed_listener(event)
|
||||
|
|
|
@ -18,11 +18,10 @@ from homeassistant.const import (
|
|||
SERVICE_TURN_ON,
|
||||
STATE_ON,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.core import Event, HomeAssistant, callback
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.event import EventStateChangedData
|
||||
from homeassistant.helpers.typing import EventType
|
||||
|
||||
from .const import CONF_INVERT
|
||||
from .entity import BaseInvertableEntity
|
||||
|
@ -81,7 +80,7 @@ class ValveSwitch(BaseInvertableEntity, ValveEntity):
|
|||
|
||||
@callback
|
||||
def async_state_changed_listener(
|
||||
self, event: EventType[EventStateChangedData] | None = None
|
||||
self, event: Event[EventStateChangedData] | None = None
|
||||
) -> None:
|
||||
"""Handle child updates."""
|
||||
super().async_state_changed_listener(event)
|
||||
|
|
Loading…
Reference in New Issue