From 45ab9a3e33367d62715f656ae7a5c96bb19cf78e Mon Sep 17 00:00:00 2001 From: Amos Yuen Date: Mon, 27 Dec 2021 11:52:26 -0800 Subject: [PATCH] Init template trigger binary sensor to None instead of False (#62769) --- homeassistant/components/template/binary_sensor.py | 2 +- tests/components/template/test_binary_sensor.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/template/binary_sensor.py b/homeassistant/components/template/binary_sensor.py index c3557ba21f4..688c8e42973 100644 --- a/homeassistant/components/template/binary_sensor.py +++ b/homeassistant/components/template/binary_sensor.py @@ -324,7 +324,7 @@ class TriggerBinarySensorEntity(TriggerEntity, BinarySensorEntity): self._delay_cancel = None self._auto_off_cancel = None - self._state = False + self._state = None @property def is_on(self) -> bool: diff --git a/tests/components/template/test_binary_sensor.py b/tests/components/template/test_binary_sensor.py index 4ed4d59c124..344ae27fcaa 100644 --- a/tests/components/template/test_binary_sensor.py +++ b/tests/components/template/test_binary_sensor.py @@ -909,11 +909,11 @@ async def test_trigger_entity(hass, start_ha): await hass.async_block_till_done() state = hass.states.get("binary_sensor.hello_name") assert state is not None - assert state.state == OFF + assert state.state == STATE_UNKNOWN state = hass.states.get("binary_sensor.bare_minimum") assert state is not None - assert state.state == OFF + assert state.state == STATE_UNKNOWN context = Context() hass.bus.async_fire("test_event", {"beer": 2}, context=context) @@ -976,7 +976,7 @@ async def test_trigger_entity(hass, start_ha): async def test_template_with_trigger_templated_delay_on(hass, start_ha): """Test binary sensor template with template delay on.""" state = hass.states.get("binary_sensor.test") - assert state.state == OFF + assert state.state == STATE_UNKNOWN context = Context() hass.bus.async_fire("test_event", {"beer": 2}, context=context)