node-red-contrib-home-assistant-websocket icon indicating copy to clipboard operation
node-red-contrib-home-assistant-websocket copied to clipboard

ha-events-calendar Node Missing Events in Beta Version

Open EspElement opened this issue 8 months ago • 3 comments

Describe the bug

Problem:
The ha-events-calendar node (ID: d7bb0e52b9d7c47a) in Node-RED, configured for calendar.work_sync (Google Calendar sync), is intermittently missing events. Previously, it fired duplicate events for the same UID within a second (e.g., 12:22:00 PM CDT on 3/26/2025), but now some events don’t trigger at all.

I was able to repaste the flow that is shown below and it seems to be working again. But this is up and down, I am not sure if this is temporary or if this is going to work from here. I think there are bugs in here for it to detect the calendar event.

Home Assistant Version: Core 2025.3.4 Supervisor 2025.03.3 Operating System 15.0 Frontend 20250306.0

Node-RED Version: [Your version, e.g., 4.0.9

Node Version: ha-events-calendar beta (exact version unknown, assumed latest as of 3/27/2025)

Installation Type: Home Assistant Add-on

Actual Behavior:
Events don’t appear in the debug output (e.g., only "Test Event 1" triggers, "Test Event 2" and "3" are missed). Previously, duplicates occurred (e.g., two messages at 12:22:00 PM on 3/26/2025 for UID "[email protected]").

To Reproduce

  1. Set up ha-events-calendar with:
    • Entity ID: calendar.work_sync (Google Calendar sync)
    • Event Type: start
    • Offset: 4 minutes
  2. Create multiple events in calendar.work_sync:
    • "Test Event 1": 3/27/2025, 12:00 PM CDT
    • "Test Event 2": 3/27/2025, 12:05 PM CDT
    • "Test Event 3": 3/27/2025, 12:10 PM CDT
  3. Add a debug node after the trigger.
  4. Wait for triggers at ~11:56 AM CDT.

Expected behavior

One message per event at the 4-minute offset (e.g., 11:56, 12:01, 12:06 PM CDT).

Screenshots

No response

Example Flow

[
    {
        "id": "8c62e4ebbed8cc82",
        "type": "tab",
        "label": "WORKING WORK NOTIFICATIONS Segment",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "4fcc6ba75dba3263",
        "type": "ha-events-calendar",
        "z": "8c62e4ebbed8cc82",
        "name": "Event Notification Trigger",
        "version": 0,
        "server": "9e7df434.82fe88",
        "exposeAsEntityConfig": "",
        "entityId": "calendar.work_sync",
        "filter": "",
        "filterType": "str",
        "eventType": "start",
        "offset": "4",
        "offsetType": "num",
        "offsetUnits": "minutes",
        "outputProperties": [
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "",
                "valueType": "calendarItem"
            }
        ],
        "x": 210,
        "y": 160,
        "wires": [
            [
                "be0a47cd6d474a16"
            ]
        ]
    },
    {
        "id": "be0a47cd6d474a16",
        "type": "change",
        "z": "8c62e4ebbed8cc82",
        "name": "Set Event UID",
        "rules": [
            {
                "t": "set",
                "p": "active_events",
                "pt": "flow",
                "to": "$append($flowContext('active_events', []), payload.uid)",
                "tot": "jsonata"
            },
            {
                "t": "set",
                "p": "topic",
                "pt": "msg",
                "to": "payload.uid",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 500,
        "y": 160,
        "wires": [
            [
                "6ada5e5cd6019de3"
            ]
        ]
    },
    {
        "id": "6ada5e5cd6019de3",
        "type": "change",
        "z": "8c62e4ebbed8cc82",
        "name": "Store Events",
        "rules": [
            {
                "t": "set",
                "p": "events",
                "pt": "flow",
                "to": "$merge([$flowContext('events', {}), {payload.uid: payload}])",
                "tot": "jsonata"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 690,
        "y": 160,
        "wires": [
            [
                "00641f973ce9c097"
            ]
        ]
    },
    {
        "id": "00641f973ce9c097",
        "type": "function",
        "z": "8c62e4ebbed8cc82",
        "name": "Debounce 6 Hours",
        "func": "const uid = msg.topic || msg.payload.uid;\nconst now = Date.now();\nconst lastSent = context.get('lastSent') || {};\nconst debouncePeriod = 6 * 60 * 60 * 1000; // 6 hours in milliseconds\n\nif (!uid) {\n    node.warn('No UID found in message');\n    return null;\n}\n\nif (!lastSent[uid] || (now - lastSent[uid] >= debouncePeriod)) {\n    lastSent[uid] = now;\n    context.set('lastSent', lastSent);\n    return msg;\n} else {\n    node.warn(`Message for UID ${uid} blocked - within 6-hour debounce`);\n    return null;\n}",
        "outputs": 1,
        "timeout": "",
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 890,
        "y": 160,
        "wires": [
            [
                "972dbb8fdea234b5"
            ]
        ]
    },
    {
        "id": "972dbb8fdea234b5",
        "type": "api-call-service",
        "z": "8c62e4ebbed8cc82",
        "name": "Notify",
        "server": "9e7df434.82fe88",
        "version": 7,
        "debugenabled": false,
        "action": "notify.mobile_app_pixel_9",
        "floorId": [],
        "areaId": [],
        "deviceId": [],
        "entityId": [],
        "labelId": [],
        "data": "{\"title\":\"Upcoming Event\",\"message\":\"{{payload.summary}} is happening now\",\"data\":{\"summary\":\"{{payload.summary}}\",\"uid\":\"{{payload.uid}}\",\"actions\":[{\"action\":\"SNOOZE_15\",\"title\":\"Snooze 15 Min\"},{\"action\":\"SNOOZE_60\",\"title\":\"Snooze 1 Hour\"},{\"action\":\"DISMISS\",\"title\":\"Dismiss\"}]}}",
        "dataType": "json",
        "mergeContext": "",
        "mustacheAltTags": false,
        "outputProperties": [],
        "queue": "none",
        "blockInputOverrides": false,
        "domain": "notify",
        "service": "mobile_app_pixel_9",
        "x": 1060,
        "y": 160,
        "wires": [
            [
                "94fa065fba4dc2e0"
            ]
        ]
    },
    {
        "id": "94fa065fba4dc2e0",
        "type": "debug",
        "z": "8c62e4ebbed8cc82",
        "name": "Debug Active Events",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "x": 1260,
        "y": 160,
        "wires": []
    },
    {
        "id": "9e7df434.82fe88",
        "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
    }
]

Environment Information

Running inside Home Assistant

Additional context

  • Flow includes a 6-hour debounce downstream, but issue persists at the trigger level.
  • Beta version note: "Config should be stable and hopefully not too many bugs."

EspElement avatar Mar 27 '25 17:03 EspElement

My debounce prevented new messages coming, so you can see it seems to be reposting the same event multiple times.

Message for UID [email protected] blocked - within 6-hour debounce

Image

EspElement avatar Mar 27 '25 17:03 EspElement

I think error was coming from the new Node-Red Deploy options. I was editing this flow, but when I used the Deploy Modified Flows, for some reason this really messed with this node. I am not sure if this something that can be fixed? I imagine it was updating and somehow storing old data causing the repeat events somehow.

Image

EspElement avatar Mar 27 '25 18:03 EspElement

I have multiple nodes connected parallel to the calendar node and they all fire randomly. When I used the deploy "Modified Flows" only some of the connected nodes got the message, so I tried the "Full" deploy as @EspElement mentioned and now none of them got the message and the event was totally ignored.

InToSSH avatar May 27 '25 21:05 InToSSH

Test with the latest release — most issues with the calendar node should now be resolved.

zachowj avatar Sep 29 '25 22:09 zachowj

The latest release seems to have completely broken the node. Every single event for the day is firing every 15 minutes for me. Restarted node red, tweaked and redeployed nodes, reloaded calendar integration, restarted HA.

Extremely simple setup, I have 4 nodes with varying triggers. One at 5m, 2m, 0m, and -5m. Just send it to debug for troubleshooting and can confirm it resends the same messages over and over.

Image

veilofsecurity avatar Sep 30 '25 05:09 veilofsecurity

@veilofsecurity I’m not seeing this issue. Can you create a new issue so it can be tracked independently?

zachowj avatar Sep 30 '25 06:09 zachowj

@veilofsecurity I’m not seeing this issue. Can you create a new issue so it can be tracked independently?

Done #1870

veilofsecurity avatar Sep 30 '25 17:09 veilofsecurity

This issue has been automatically marked as abandoned because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Nov 22 '25 06:11 github-actions[bot]