Understanding delay note: rate limit

Hi All,

So i’m working on an automation, simple, check if its hotter outside than inside, if it is, send me a message a few times and then no more. I saw that there is a ‘delay node’ where I could set a “rate limit” to only send something like 10msg’s per 1 day.

When I try this, everything executes one time, and after that, it stops running. even my “events: state node” stops updating after one message. I have to re-deploy in order for it to work again. I currently have it set to 10 messages per day but at most I can only get 1 before the whole automation just kinda dies. Maybe im misunderstanding?

Logic: Office temperature hotter than backyard temp, is it between 5pm and 11:59PM, limit messages to only 10 per 1 day, check to make sure I’m home, send me a message.


[
    {
        "id": "204f7f3cdd61d953",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": ""
    },
    {
        "id": "7d4e29941beb6835",
        "type": "server-state-changed",
        "z": "204f7f3cdd61d953",
        "name": "Backyard Temperature",
        "server": "70ffd67b.7b6ef8",
        "version": 3,
        "exposeToHomeAssistant": false,
        "haConfig": [
            {
                "property": "name",
                "value": ""
            },
            {
                "property": "icon",
                "value": ""
            }
        ],
        "entityidfilter": "sensor.acurite_tower_a_6432_t_side",
        "entityidfiltertype": "exact",
        "outputinitially": false,
        "state_type": "num",
        "haltifstate": " $number($entities(\"sensor.office_temperature_2\").state) > $number($entities(\"sensor.acurite_tower_a_6432_t_side\").state)",
        "halt_if_type": "jsonata",
        "halt_if_compare": "jsonata",
        "outputs": 2,
        "output_only_on_state_change": false,
        "for": "1",
        "forType": "num",
        "forUnits": "seconds",
        "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": 160,
        "y": 300,
        "wires": [
            [
                "5de61fe7b305601c"
            ],
            []
        ]
    },
    {
        "id": "7bd52af737c555f6",
        "type": "api-call-service",
        "z": "204f7f3cdd61d953",
        "name": "Message Jon",
        "server": "70ffd67b.7b6ef8",
        "version": 3,
        "debugenabled": false,
        "service_domain": "notify",
        "service": "mobile_app_lephono13dejon",
        "entityId": "",
        "data": "{\"message\":\"It's currently {{payload}}F in the backyard.\",\"title\":\"Open the Office Window\"}",
        "dataType": "json",
        "mergecontext": "",
        "mustacheAltTags": false,
        "outputProperties": [],
        "queue": "none",
        "x": 870,
        "y": 300,
        "wires": [
            []
        ]
    },
    {
        "id": "acc5a6bbc68b4114",
        "type": "api-current-state",
        "z": "204f7f3cdd61d953",
        "name": "Jon's Home",
        "server": "70ffd67b.7b6ef8",
        "version": 2,
        "outputs": 2,
        "halt_if": "home",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "entity_id": "device_tracker.lephono13dejon",
        "state_type": "str",
        "blockInputOverrides": false,
        "outputProperties": [],
        "override_topic": false,
        "state_location": "payload",
        "override_payload": "msg",
        "entity_location": "data",
        "override_data": "msg",
        "x": 710,
        "y": 300,
        "wires": [
            [
                "7bd52af737c555f6"
            ],
            []
        ]
    },
    {
        "id": "5de61fe7b305601c",
        "type": "time-range-switch",
        "z": "204f7f3cdd61d953",
        "name": "",
        "lat": "",
        "lon": "",
        "startTime": "17:00",
        "endTime": "23:59",
        "startOffset": 0,
        "endOffset": 0,
        "x": 360,
        "y": 300,
        "wires": [
            [
                "5c56fe969000a39e"
            ],
            []
        ]
    },
    {
        "id": "5c56fe969000a39e",
        "type": "delay",
        "z": "204f7f3cdd61d953",
        "name": "",
        "pauseType": "rate",
        "timeout": "5",
        "timeoutUnits": "seconds",
        "rate": "10",
        "nbRateUnits": "1",
        "rateUnits": "day",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": true,
        "allowrate": true,
        "x": 540,
        "y": 300,
        "wires": [
            [
                "acc5a6bbc68b4114"
            ]
        ]
    },
    {
        "id": "70ffd67b.7b6ef8",
        "type": "server",
        "name": "Home Assistant",
        "version": 1,
        "addon": true,
        "rejectUnauthorizedCerts": true,
        "ha_boolean": "y|yes|true|on|home|open",
        "connectionDelay": true,
        "cacheJson": true
    }
]

I appreciate the help
Jon

Are you sure the Backyard temperature sends a message?
Usually the trigger only happens when you cross the threshold, which generally is only once when it’s temperature

It does, I see it in the node-red interface when it changes temp, and if I dont do the delay mode I get spammed every decimal point it drops!

It seems it averages it out for you.
So 10 per day means 1 every 2.4 hours.

Setting it like this and it can trigger every second.

I believe you need to create a counter (flow counter) that you compare against and block when above 10.

This is not how an event state node should function, I assume this is because the comparison is being made in jsonata. What if you just use > $entities("sensor.office_temperature_2").state

Ill give that a shot, im still new to node-red, how does it normally function?

It should fire once when the threshold is crossed. Then it would need to fall below and then pass it for it to fire a second time.