I have a water fountain for my cat which is controlled using a motion sensor. If the water fountain’s power was never “on” for 12h this means that something terrible is going on, so I added a “events:state” node which triggers if the power was off for 12 hours:
[{"id":"cf71d5e69f0612bd","type":"server-state-changed","z":"07a49424fd2285b2","g":"3ac64136848c0b47","name":"Water Fountain Off for >12h","server":"b59d18a8.44b6f8","version":5,"outputs":2,"exposeAsEntityConfig":"","entityId":"switch.water_fountain_power","entityIdType":"exact","outputInitially":false,"stateType":"str","ifState":"off","ifStateType":"str","ifStateOperator":"is","outputOnlyOnStateChange":true,"for":"12","forType":"num","forUnits":"hours","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":200,"y":940,"wires":[["63c192ba02c4d396","7838d1747e44a4c0"],[]]},{"id":"b59d18a8.44b6f8","type":"server","name":"Home Assistant","version":5,"addon":true,"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}]
The issue is that the node occasionally triggers even if this condition was not met. I logged such an event:
{
"payload": "off",
"data": {
"entity_id": "switch.water_fountain_power",
"old_state": {
"entity_id": "switch.water_fountain_power",
"state": "on",
"attributes": {
"raw_state": true,
"friendly_name": "Alimentare"
},
"last_changed": "2024-04-25T11:10:51.372065+00:00",
"last_reported": "2024-04-25T11:10:51.372065+00:00",
"last_updated": "2024-04-25T11:10:51.372065+00:00",
"context": {
"id": "01HWAF6XBGEP1GX8TW5CQMZ806",
"parent_id": null,
"user_id": "ab68d1be25df460989aef4e617528995"
}
},
"new_state": {
"entity_id": "switch.water_fountain_power",
"state": "off",
"attributes": {
"raw_state": false,
"friendly_name": "Alimentare"
},
"last_changed": "2024-04-25T11:12:54.703425+00:00",
"last_reported": "2024-04-25T11:12:54.703425+00:00",
"last_updated": "2024-04-25T11:12:54.703425+00:00",
"context": {
"id": "01HWAFANSS7YQHYZHZDE3XHJBB",
"parent_id": null,
"user_id": "ab68d1be25df460989aef4e617528995"
},
"timeSinceChangedMs": 43200010
}
},
"topic": "switch.water_fountain_power"
}
You can see that old_state
was on
at 2024-04-25T11:10:51.372065+00:00
, then the node triggered two minutes later at 2024-04-25T11:12:54.703425+00:00
, with timeSinceChangedMs
showing that there were 12 hours since the last change, which is incorrect. Am I misunderstanding what the “For” parameters in “events: state” node means or what’s going on here?