Handle state is None in InfluxDB (#79609)

pull/79613/head^2
Mike Degatano 2022-10-04 14:43:57 -04:00 committed by GitHub
parent 9c97ebbcfe
commit 051374d73e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View File

@ -218,7 +218,7 @@ def _generate_event_to_json(conf: dict) -> Callable[[Event], dict[str, Any] | No
state: State | None = event.data.get(EVENT_NEW_STATE)
if (
state is None
or state.state in (STATE_UNKNOWN, "", STATE_UNAVAILABLE)
or state.state in (STATE_UNKNOWN, "", STATE_UNAVAILABLE, None)
or not entity_filter(state.entity_id)
):
return None

View File

@ -557,7 +557,7 @@ async def test_event_listener_states(
"""Test the event listener against ignored states."""
handler_method = await _setup(hass, mock_client, config_ext, get_write_api)
for state_state in (1, "unknown", "", "unavailable"):
for state_state in (1, "unknown", "", "unavailable", None):
state = MagicMock(
state=state_state,
domain="fake",