mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 20:27:08 +00:00
Improve generic event typing [google_pubsub] (#114731)
This commit is contained in:
parent
bf0309a722
commit
856567d674
@ -11,7 +11,7 @@ from google.cloud.pubsub_v1 import PublisherClient
|
|||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.const import EVENT_STATE_CHANGED, STATE_UNAVAILABLE, STATE_UNKNOWN
|
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
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.entityfilter import FILTER_SCHEMA
|
from homeassistant.helpers.entityfilter import FILTER_SCHEMA
|
||||||
from homeassistant.helpers.typing import ConfigType
|
from homeassistant.helpers.typing import ConfigType
|
||||||
@ -59,9 +59,9 @@ def setup(hass: HomeAssistant, yaml_config: ConfigType) -> bool:
|
|||||||
|
|
||||||
encoder = DateTimeJSONEncoder()
|
encoder = DateTimeJSONEncoder()
|
||||||
|
|
||||||
def send_to_pubsub(event: Event):
|
def send_to_pubsub(event: Event[EventStateChangedData]):
|
||||||
"""Send states to Pub/Sub."""
|
"""Send states to Pub/Sub."""
|
||||||
state = event.data.get("new_state")
|
state = event.data["new_state"]
|
||||||
if (
|
if (
|
||||||
state is None
|
state is None
|
||||||
or state.state in (STATE_UNKNOWN, "", STATE_UNAVAILABLE)
|
or state.state in (STATE_UNKNOWN, "", STATE_UNAVAILABLE)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user