From 856567d67408b207940f4c8711a21310a8ac69d6 Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Sat, 6 Apr 2024 14:20:31 +0200 Subject: [PATCH] Improve generic event typing [google_pubsub] (#114731) --- homeassistant/components/google_pubsub/__init__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/google_pubsub/__init__.py b/homeassistant/components/google_pubsub/__init__.py index 74e2a297ff4..f289fae2456 100644 --- a/homeassistant/components/google_pubsub/__init__.py +++ b/homeassistant/components/google_pubsub/__init__.py @@ -11,7 +11,7 @@ from google.cloud.pubsub_v1 import PublisherClient import voluptuous as vol from homeassistant.const import EVENT_STATE_CHANGED, STATE_UNAVAILABLE, STATE_UNKNOWN -from homeassistant.core import Event, HomeAssistant +from homeassistant.core import Event, EventStateChangedData, HomeAssistant import homeassistant.helpers.config_validation as cv from homeassistant.helpers.entityfilter import FILTER_SCHEMA from homeassistant.helpers.typing import ConfigType @@ -59,9 +59,9 @@ def setup(hass: HomeAssistant, yaml_config: ConfigType) -> bool: encoder = DateTimeJSONEncoder() - def send_to_pubsub(event: Event): + def send_to_pubsub(event: Event[EventStateChangedData]): """Send states to Pub/Sub.""" - state = event.data.get("new_state") + state = event.data["new_state"] if ( state is None or state.state in (STATE_UNKNOWN, "", STATE_UNAVAILABLE)