Automation turn off with "timer"

I want to create an automation that:
If state of light pass from ‘unavailable’
stay in that state for x second
and after x second switch to on
then turn off that light
can someoune help me?
thanks

i answer myself…

- alias: 'turn light off' 
  trigger:
    - platform: state
      entity_id: light.xxx
      from: 'unavailable'
      to: 'on'
  condition:
    - condition: template
      value_template: >
        {{ (now() | as_timestamp) - (trigger.from_state.last_changed | as_timestamp) > 10 }}      
  action:
    - service: light.turn_off
      entity_id: light.xxx