# Events: state with for condition does not trigger at startup

**URL:** <https://discourse.nodered.org/t/events-state-with-for-condition-does-not-trigger-at-startup/70702>\
**Category:** General\
**Created:** [16 November 2022 11:14 UTC](https://discourse.nodered.org/t/events-state-with-for-condition-does-not-trigger-at-startup/70702 "2022-11-16T11:14:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![robcos](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/robcos/32/35278_2.png) [@robcos](https://discourse.nodered.org/u/robcos)\
**Post date:** [16 November 2022 11:14 UTC](https://discourse.nodered.org/t/events-state-with-for-condition-does-not-trigger-at-startup/70702/1 "2022-11-16T11:14:33Z")

</div>

I use an _events: state_ node with a "for X minutes" condition to detect if the the value of a binary sensor has not flipped for at least X minutes.  
Works normally fine except that if I restart nodered, there is no state change in my binary sensor and therefore events:state never triggers.  
What could I do to workaround this? One idea is to flip back and forth my binary sensor at startup but that feels hacky.

```auto

[
    {
        "id": "5ca2060992b85578",
        "type": "server-state-changed",
        "z": "fd346cefa9967d42",
        "name": "A room is abandoned if unoccupied for 30 minutes",
        "server": "5911c68b.bbc568",
        "version": 4,
        "exposeToHomeAssistant": false,
        "haConfig": [
            {
                "property": "name",
                "value": ""
            },
            {
                "property": "icon",
                "value": ""
            }
        ],
        "entityidfilter": "${PRESENCE_SENSOR}",
        "entityidfiltertype": "exact",
        "outputinitially": true,
        "state_type": "str",
        "haltifstate": "off",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "outputs": 2,
        "output_only_on_state_change": true,
        "for": "30",
        "forType": "num",
        "forUnits": "minutes",
        "ignorePrevStateNull": false,
        "ignorePrevStateUnknown": false,
        "ignorePrevStateUnavailable": false,
        "ignoreCurrentStateUnknown": false,
        "ignoreCurrentStateUnavailable": false,
        "outputProperties": [
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "",
                "valueType": "entityState"
            },
            {
                "property": "data",
                "propertyType": "msg",
                "value": "",
                "valueType": "eventData"
            },
            {
                "property": "topic",
                "propertyType": "msg",
                "value": "",
                "valueType": "triggerId"
            }
        ],
        "x": 270,
        "y": 160,
        "wires": [
            [
                "d91c1fcebfab197d",
                "c30677e4d1ed6c19"
            ],
            []
        ]
    },
    {
        "id": "5911c68b.bbc568",
        "type": "server",
        "name": "Home Assistant",
        "version": 5,
        "addon": false,
        "rejectUnauthorizedCerts": true,
        "ha_boolean": "y|yes|true|on|home|open",
        "connectionDelay": true,
        "cacheJson": true,
        "heartbeat": false,
        "heartbeatInterval": "30",
        "areaSelector": "friendlyName",
        "deviceSelector": "friendlyName",
        "entitySelector": "friendlyName",
        "statusSeparator": "at: ",
        "statusYear": "hidden",
        "statusMonth": "short",
        "statusDay": "numeric",
        "statusHourCycle": "h23",
        "statusTimeFormat": "h:m",
        "enableGlobalContextStore": true
    }
]

```

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [16 November 2022 11:19 UTC](https://discourse.nodered.org/t/events-state-with-for-condition-does-not-trigger-at-startup/70702/2 "2022-11-16T11:19:44Z")

</div>

Seeing that that is a Home Assistant node, you might be better off asking on Home Assistant's forum

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [15 January 2023 11:20 UTC](https://discourse.nodered.org/t/events-state-with-for-condition-does-not-trigger-at-startup/70702/3 "2023-01-15T11:20:06Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
