Improve generic event typing [google_pubsub] (#114731)
This commit is contained in:
parent
bf0309a722
commit
856567d674
1 changed files with 3 additions and 3 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue