From 051374d73e0f8ad8d7c70bf96bbb86451c30858f Mon Sep 17 00:00:00 2001 From: Mike Degatano Date: Tue, 4 Oct 2022 14:43:57 -0400 Subject: [PATCH] Handle state is None in InfluxDB (#79609) --- homeassistant/components/influxdb/__init__.py | 2 +- tests/components/influxdb/test_init.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/influxdb/__init__.py b/homeassistant/components/influxdb/__init__.py index 72871c75fc4..4fd6eb58fdd 100644 --- a/homeassistant/components/influxdb/__init__.py +++ b/homeassistant/components/influxdb/__init__.py @@ -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 diff --git a/tests/components/influxdb/test_init.py b/tests/components/influxdb/test_init.py index 27b9ac82ade..78648852803 100644 --- a/tests/components/influxdb/test_init.py +++ b/tests/components/influxdb/test_init.py @@ -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",