Automation condition

Hi,

Can anyone help me out.
I rebuild a tuya doorsensor for a build-in switch. ( solderd 2 wires on it to work with my switch ).
But when i restart or update my home assistant it wil “toggle” the sensor because it resends its state.

I like to make a condition that this automation won’t work if home assistant is up for les than 2 minutes.

alias: kantoorknop
description: lamp manueel bedienen
trigger:
  - type: opened
    platform: device
    device_id: 6d8efce951f8628aa7bcf45a4f72f79f
    entity_id: binary_sensor.kantoorknop_contact
    domain: binary_sensor
  - type: not_opened
    platform: device
    device_id: 6d8efce951f8628aa7bcf45a4f72f79f
    entity_id: binary_sensor.kantoorknop_contact
    domain: binary_sensor
condition: []
action:
  - service: light.toggle
    data:
      color_temp: 430
      brightness: 255
    target:
      entity_id: light.kantoorspot
mode: single

I have the “sensor.uptime” to show the latest restart.
So if anyone can help me make this conditions that would be great.

Thanks in favor.

Martijn

What about this:


  {% set up = states('sensor.uptime') |as_datetime |as_local %}
  {{ now() - up > timedelta(minutes=2) }}

This seems to work!! fantastic! thanks!