How to check state instead of state_change?

I have an automation that checks my door state, and alerts me if the sensor is in an unkown state (here: 4):

entity_id: sensor.door_state
for: '00:10:00'
platform: state
to: '4'

This works as long as a prior state has been properly registered by HA. But sometimes, eg after a HA restart, and if the state is already in “4”, the trigger will not be executed.

So instead, I’d like to check if the “door is in state 4 for 10 mins”, and not “changes its state to 4 for 10 mins”.
How is that possible? To check state existence, instead of state changes?