I am fairly new to HA and Node Red, and working on setting up the home alarm integration, and creating notifications to email, MMS text, fire tv, mobile app, and TTS. I was wanting to add a way to prevent getting multiple alerts in a row by adding a “hold” time. You can create multiple message variables/properties that will pass through all the flow nodes if you don’t change them. Using your tips above, I came up with a slightly different way to compare 2 times, eliminating the join node. I set the Current Time, and other properties, in the initial state change node. Then I have an input_datetime entity that I check for the last alert sent time, and add a hold time to that. My compare time function uses the code:
if (msg.curtime >= msg.holdtime) {
msg.send = “True”;
} else {
msg.send = “False”;
}
return msg;
P.S. if you use the join node method, in scenario where comparing the 2 times for >= or <=, I would consider adding a 1 second delay somewhere before the 2nd time (hold time in my case) is passed to the join node to make sure it is added to the expected array position.
[{"id":"b31d60725fc9b033","type":"api-call-service","z":"3bec427eb6b0871d","name":"Set LLLA Time","server":"95c0ebe7.5d0aa8","version":3,"debugenabled":false,"service_domain":"input_datetime","service":"set_datetime","entityId":"input_datetime.lll_alerttime","data":"{\"datetime\":\"{{ curtime }}\"}","dataType":"json","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":920,"y":260,"wires":[[]]},{"id":"316815fe0cb06cb4","type":"function","z":"3bec427eb6b0871d","name":"Compare Times","func":"if (msg.curtime >= msg.holdtime) {\n msg.send = \"True\";\n} else {\n msg.send = \"False\";\n}\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":700,"y":260,"wires":[["1fb9bfd24f585dad"]]},{"id":"1fb9bfd24f585dad","type":"switch","z":"3bec427eb6b0871d","name":"Send Alert?","property":"send","propertyType":"msg","rules":[{"t":"eq","v":"True","vt":"str"}],"checkall":"true","repair":true,"outputs":1,"x":870,"y":200,"wires":[["b31d60725fc9b033","c64b2da127276469"]]},{"id":"530574acd39ea25e","type":"api-current-state","z":"3bec427eb6b0871d","name":"Get LLLA Time","server":"95c0ebe7.5d0aa8","version":2,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_datetime.lll_alerttime","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"LLLAtime","propertyType":"msg","value":"","valueType":"entityState"}],"x":480,"y":260,"wires":[["5e583d205daee41f"]]},{"id":"5e583d205daee41f","type":"moment","z":"3bec427eb6b0871d","name":"Add Hold Time","topic":"","input":"LLLAtime","inputType":"msg","inTz":"America/New_York","adjAmount":"10","adjType":"minutes","adjDir":"add","format":"YYYY-MM-DD HH:mm","locale":"en","output":"holdtime","outputType":"msg","outTz":"America/New_York","x":660,"y":200,"wires":[["316815fe0cb06cb4"]]},{"id":"c64b2da127276469","type":"debug","z":"3bec427eb6b0871d","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1050,"y":200,"wires":[]},{"id":"d1a269d1e712c403","type":"inject","z":"3bec427eb6b0871d","name":"Test Notify","props":[{"p":"topic","vt":"str"},{"p":"curtime","v":"( $now('[Y0001]-[M01]-[D01] [H01]:[m01]:[s01]', '-0400') )","vt":"jsonata"},{"p":"payload"},{"p":"image1","v":"/media/Garage01.jpg","vt":"str"},{"p":"image2","v":"/local/bi/Garage01.jpg","vt":"str"},{"p":"attachments","v":"{\"path\": \"/media/Garage01.jpg\"}","vt":"str"},{"p":"URL1","v":"/lovelace-security/cameras","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"Test Notification","payload":"(msg.topic & \" - \" & msg.curtime)","payloadType":"jsonata","x":300,"y":280,"wires":[["530574acd39ea25e"]]},{"id":"87e9435bbec191e0","type":"server-state-changed","z":"3bec427eb6b0871d","name":"Garage Door State","server":"95c0ebe7.5d0aa8","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.garage_door_opener","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"topic","propertyType":"msg","value":"Garage Door","valueType":"str"},{"property":"curtime","propertyType":"msg","value":"( $now('[Y0001]-[M01]-[D01] [H01]:[m01]:[s01]', '-0400') )","valueType":"jsonata"},{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"payload","propertyType":"msg","value":"(msg.payload & \" - \" & msg.curtime)","valueType":"jsonata"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"attachments","propertyType":"msg","value":"{\"path\": \"/media/Garage01.jpg\"}","valueType":"str"},{"property":"image1","propertyType":"msg","value":"/media/Garage01.jpg","valueType":"str"},{"property":"image2","propertyType":"msg","value":"/local/bi/Garage01.jpg","valueType":"str"},{"property":"URL1","propertyType":"msg","value":"/lovelace-security/cameras","valueType":"str"},{"property":"channel1","propertyType":"msg","value":"Win-Dr","valueType":"str"},{"property":"priority","propertyType":"msg","value":"high","valueType":"str"}],"x":270,"y":200,"wires":[["530574acd39ea25e"]]},{"id":"95c0ebe7.5d0aa8","type":"server","name":"Home Assistant","version":1,"legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]