diff --git a/homeassistant/components/tasmota/device_automation.py b/homeassistant/components/tasmota/device_automation.py index ef05585dd87..af14efbd65c 100644 --- a/homeassistant/components/tasmota/device_automation.py +++ b/homeassistant/components/tasmota/device_automation.py @@ -1,7 +1,6 @@ """Provides device automations for Tasmota.""" -from collections.abc import Mapping -from typing import Any +from __future__ import annotations from hatasmota.const import AUTOMATION_TYPE_TRIGGER from hatasmota.models import DiscoveryHashType @@ -9,7 +8,10 @@ from hatasmota.trigger import TasmotaTrigger from homeassistant.config_entries import ConfigEntry from homeassistant.core import Event, HomeAssistant, callback -from homeassistant.helpers.device_registry import EVENT_DEVICE_REGISTRY_UPDATED +from homeassistant.helpers.device_registry import ( + EVENT_DEVICE_REGISTRY_UPDATED, + EventDeviceRegistryUpdatedData, +) from homeassistant.helpers.dispatcher import async_dispatcher_connect from . import device_trigger @@ -25,12 +27,16 @@ async def async_remove_automations(hass: HomeAssistant, device_id: str) -> None: async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> None: """Set up Tasmota device automation dynamically through discovery.""" - async def async_device_removed(event: Event) -> None: + async def async_device_removed( + event: Event[EventDeviceRegistryUpdatedData], + ) -> None: """Handle the removal of a device.""" await async_remove_automations(hass, event.data["device_id"]) @callback - def _async_device_removed_filter(event_data: Mapping[str, Any]) -> bool: + def _async_device_removed_filter( + event_data: EventDeviceRegistryUpdatedData, + ) -> bool: """Filter device registry events.""" return event_data["action"] == "remove"