|
|
@@ -92,6 +92,40 @@ async def test_door_open_initially_none(hass, door_coord):
|
|
|
assert door_coord.data[LOCK_ENTITY_ID].door_open is None
|
|
|
|
|
|
|
|
|
+async def test_door_open_seeded_from_existing_state_at_startup(hass, mock_node):
|
|
|
+ """Sensor state already published before integration loads — no change event fires."""
|
|
|
+ hass.states.async_set(DOOR_SENSOR_ENTITY, "off")
|
|
|
+ entry = _door_config_entry()
|
|
|
+ entry.add_to_hass(hass)
|
|
|
+ with patch(_ZWAVE_HELPER, return_value=mock_node):
|
|
|
+ c = ZLockCoordinator(hass, entry)
|
|
|
+ await c.async_setup()
|
|
|
+ assert c.data[LOCK_ENTITY_ID].door_open is False
|
|
|
+ c.async_teardown()
|
|
|
+
|
|
|
+
|
|
|
+async def test_door_open_seeded_open_at_startup(hass, mock_node):
|
|
|
+ hass.states.async_set(DOOR_SENSOR_ENTITY, "on")
|
|
|
+ entry = _door_config_entry()
|
|
|
+ entry.add_to_hass(hass)
|
|
|
+ with patch(_ZWAVE_HELPER, return_value=mock_node):
|
|
|
+ c = ZLockCoordinator(hass, entry)
|
|
|
+ await c.async_setup()
|
|
|
+ assert c.data[LOCK_ENTITY_ID].door_open is True
|
|
|
+ c.async_teardown()
|
|
|
+
|
|
|
+
|
|
|
+async def test_door_unavailable_at_startup_not_seeded(hass, mock_node):
|
|
|
+ hass.states.async_set(DOOR_SENSOR_ENTITY, "unavailable")
|
|
|
+ entry = _door_config_entry()
|
|
|
+ entry.add_to_hass(hass)
|
|
|
+ with patch(_ZWAVE_HELPER, return_value=mock_node):
|
|
|
+ c = ZLockCoordinator(hass, entry)
|
|
|
+ await c.async_setup()
|
|
|
+ assert c.data[LOCK_ENTITY_ID].door_open is None
|
|
|
+ c.async_teardown()
|
|
|
+
|
|
|
+
|
|
|
async def test_door_sensor_not_tracked_without_config(hass, mock_node):
|
|
|
entry = MockConfigEntry(
|
|
|
domain=DOMAIN,
|