Open ElVit opened 1 month ago
Can you share the Node-Red config? I use NR for all my automation and would love to keep this functionality!
Yes sure. Nice that this netdaemon app was actually usefull for you 😃
Here is the node red code:
[{"id":"480d998c98ab6485","type":"group","z":"24a64c4fef191855","style":{"stroke":"#2e333a","stroke-opacity":"1","fill":"#383c45","fill-opacity":"0.5","label":true,"label-position":"nw","color":"#dddddd"},"nodes":["d031ca501d710e55","db5ef2d697b72908","20770ad6eeeec522","c5eeaac585e61093","25f8403babf025de","e1cbaf3c4b980cfd","06f05fa14ac46759","cf7e79daa6eb18eb","1d3c54ba0c04f410","6d9200d56ac3326a"],"x":54,"y":1519,"w":992,"h":202},{"id":"d031ca501d710e55","type":"api-call-service","z":"24a64c4fef191855","g":"480d998c98ab6485","name":"Set notify on iPhone","server":"f56de91.b429118","version":5,"debugenabled":false,"domain":"notify","service":"mobile_app_all_iphones","areaId":[],"deviceId":[],"entityId":[],"data":"{\t \"message\": message,\t \"title\": title,\t \"data\":\t {\t \"tag\": notification_id,\t \"url\": \"/config/updates\",\t \"clickAction\": \"/config/updates\",\t \"actions\":\t [\t {\t \"action\": \"URI\", \t \"title\": \"Open Dashboard\",\t \"uri\": \"/config/dashboard\"\t },\t {\t \"action\": \"URI\", \t \"title\": \"Open Addons\",\t \"uri\": \"/hassio/dashboard\"\t },\t {\t \"action\": \"URI\", \t \"title\": \"Open HACS\",\t \"uri\": \"/hacs\"\t }\t ]\t }\t}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":840,"y":1560,"wires":[[]]},{"id":"db5ef2d697b72908","type":"api-call-service","z":"24a64c4fef191855","g":"480d998c98ab6485","name":"Set notify in Home Assistant","server":"f56de91.b429118","version":5,"debugenabled":false,"domain":"persistent_notification","service":"create","areaId":[],"deviceId":[],"entityId":[],"data":"{\t \"message\": message,\t \"title\": title,\t \"notification_id\": notification_id\t}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":860,"y":1640,"wires":[[]]},{"id":"20770ad6eeeec522","type":"api-call-service","z":"24a64c4fef191855","g":"480d998c98ab6485","name":"Remove notify on iPhone","server":"f56de91.b429118","version":5,"debugenabled":false,"domain":"notify","service":"mobile_app_all_iphones","areaId":[],"deviceId":[],"entityId":[],"data":"{\t \"message\":\"clear_notification\",\t \"data\":\t {\t \"tag\": notification_id\t }\t}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":850,"y":1600,"wires":[[]]},{"id":"c5eeaac585e61093","type":"api-call-service","z":"24a64c4fef191855","g":"480d998c98ab6485","name":"Remove notify in Home Assistant","server":"f56de91.b429118","version":5,"debugenabled":false,"domain":"persistent_notification","service":"dismiss","areaId":[],"deviceId":[],"entityId":[],"data":"{\t \"notification_id\": notification_id\t}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":880,"y":1680,"wires":[[]]},{"id":"25f8403babf025de","type":"ha-get-entities","z":"24a64c4fef191855","g":"480d998c98ab6485","name":"Get all active update entities","server":"f56de91.b429118","version":1,"rules":[{"property":"entity_id","logic":"is","value":"update\\..*","valueType":"re"},{"property":"state","logic":"is","value":"on","valueType":"str"}],"outputType":"array","outputEmptyResults":true,"outputLocationType":"msg","outputLocation":"payload","outputResultsCount":1,"x":380,"y":1580,"wires":[["06f05fa14ac46759","6d9200d56ac3326a"]]},{"id":"e1cbaf3c4b980cfd","type":"inject","z":"24a64c4fef191855","g":"480d998c98ab6485","name":"On start","props":[{"p":"payload"}],"repeat":"","crontab":"","once":true,"onceDelay":"60","topic":"","payload":"","payloadType":"date","x":160,"y":1580,"wires":[["25f8403babf025de"]]},{"id":"06f05fa14ac46759","type":"function","z":"24a64c4fef191855","g":"480d998c98ab6485","name":"setMessage","func":"msg.notification_id = \"updates_available\";\nmsg.message = \"[Updates](/config/updates)\\n\\n\";\nmsg.title = \"🎊 Updates available 🎊\";\n\nfor (var i = 0; i < msg.payload.length; i++)\n{\n var installed_version = msg.payload[i].attributes.installed_version;\n var latest_version = msg.payload[i].attributes.latest_version;\n var friendly_name = msg.payload[i].attributes.friendly_name;\n\n msg.message += \"• **\" + friendly_name + \"**: v\" + installed_version + \" ➤ v\" + latest_version + \"\\n\";\n}\n\nvar lastMessage = context.get(\"lastMessage\") || \"empty\";\ncontext.set(\"lastMessage\", msg.message);\n\nif (lastMessage === msg.message) return [ null, null];\nif (msg.payload.length === 0) return [ null, msg ];\nreturn [ msg, null ];","outputs":2,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":610,"y":1660,"wires":[["db5ef2d697b72908"],["c5eeaac585e61093"]],"outputLabels":["create message","delete message"]},{"id":"cf7e79daa6eb18eb","type":"server-state-changed","z":"24a64c4fef191855","g":"480d998c98ab6485","name":"On update change","server":"f56de91.b429118","version":5,"outputs":1,"exposeAsEntityConfig":"","entityId":"update\\..*","entityIdType":"regex","outputInitially":false,"stateType":"str","ifState":"","ifStateType":"str","ifStateOperator":"is","outputOnlyOnStateChange":true,"for":"1","forType":"num","forUnits":"seconds","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":true,"ignoreCurrentStateUnavailable":true,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":230,"y":1660,"wires":[["1d3c54ba0c04f410"]]},{"id":"1d3c54ba0c04f410","type":"rate-limiter","z":"24a64c4fef191855","g":"480d998c98ab6485","delay_action":"ratelimit","rate":"1","nbRateUnits":"2","rateUnits":"second","drop_select":"queue","addcurrentcount":false,"name":"","outputs":"1","buffer_size":"1","buffer_drop":"buffer_drop_old","emit_msg_2nd":false,"control_topic":"","version":0.0018,"x":330,"y":1620,"wires":[["25f8403babf025de"]]},{"id":"6d9200d56ac3326a","type":"function","z":"24a64c4fef191855","g":"480d998c98ab6485","name":"setMessage","func":"msg.notification_id = \"updates_available\";\nmsg.message = \"\";\nmsg.title = \"🎊 Updates available 🎊\";\n\nfor (var i = 0; i < msg.payload.length; i++)\n{\n var installed_version = msg.payload[i].attributes.installed_version;\n var latest_version = msg.payload[i].attributes.latest_version;\n var friendly_name = msg.payload[i].attributes.friendly_name;\n\n msg.message += \"• \" + friendly_name + \": v\" + installed_version + \" ➤ v\" + latest_version + \"\\n\"\n}\n\nvar lastMessage = context.get(\"lastMessage\") || \"empty\";\ncontext.set(\"lastMessage\", msg.message);\n\nif (lastMessage === msg.message) return [ null, null];\nif (msg.payload.length === 0) return [ null, msg ];\nreturn [ msg, null ];","outputs":2,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":610,"y":1580,"wires":[["d031ca501d710e55"],["20770ad6eeeec522"]],"outputLabels":["create message","delete message"]},{"id":"f56de91.b429118","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}]
Yes sure. Nice that this netdaemon app was actually usefull for you 😃
Here is the node red code:
[{"id":"480d998c98ab6485","type":"group","z":"24a64c4fef191855","style":{"stroke":"#2e333a","stroke-opacity":"1","fill":"#383c45","fill-opacity":"0.5","label":true,"label-position":"nw","color":"#dddddd"},"nodes":["d031ca501d710e55","db5ef2d697b72908","20770ad6eeeec522","c5eeaac585e61093","25f8403babf025de","e1cbaf3c4b980cfd","06f05fa14ac46759","cf7e79daa6eb18eb","1d3c54ba0c04f410","6d9200d56ac3326a"],"x":54,"y":1519,"w":992,"h":202},{"id":"d031ca501d710e55","type":"api-call-service","z":"24a64c4fef191855","g":"480d998c98ab6485","name":"Set notify on iPhone","server":"f56de91.b429118","version":5,"debugenabled":false,"domain":"notify","service":"mobile_app_all_iphones","areaId":[],"deviceId":[],"entityId":[],"data":"{\t \"message\": message,\t \"title\": title,\t \"data\":\t {\t \"tag\": notification_id,\t \"url\": \"/config/updates\",\t \"clickAction\": \"/config/updates\",\t \"actions\":\t [\t {\t \"action\": \"URI\", \t \"title\": \"Open Dashboard\",\t \"uri\": \"/config/dashboard\"\t },\t {\t \"action\": \"URI\", \t \"title\": \"Open Addons\",\t \"uri\": \"/hassio/dashboard\"\t },\t {\t \"action\": \"URI\", \t \"title\": \"Open HACS\",\t \"uri\": \"/hacs\"\t }\t ]\t }\t}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":840,"y":1560,"wires":[[]]},{"id":"db5ef2d697b72908","type":"api-call-service","z":"24a64c4fef191855","g":"480d998c98ab6485","name":"Set notify in Home Assistant","server":"f56de91.b429118","version":5,"debugenabled":false,"domain":"persistent_notification","service":"create","areaId":[],"deviceId":[],"entityId":[],"data":"{\t \"message\": message,\t \"title\": title,\t \"notification_id\": notification_id\t}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":860,"y":1640,"wires":[[]]},{"id":"20770ad6eeeec522","type":"api-call-service","z":"24a64c4fef191855","g":"480d998c98ab6485","name":"Remove notify on iPhone","server":"f56de91.b429118","version":5,"debugenabled":false,"domain":"notify","service":"mobile_app_all_iphones","areaId":[],"deviceId":[],"entityId":[],"data":"{\t \"message\":\"clear_notification\",\t \"data\":\t {\t \"tag\": notification_id\t }\t}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":850,"y":1600,"wires":[[]]},{"id":"c5eeaac585e61093","type":"api-call-service","z":"24a64c4fef191855","g":"480d998c98ab6485","name":"Remove notify in Home Assistant","server":"f56de91.b429118","version":5,"debugenabled":false,"domain":"persistent_notification","service":"dismiss","areaId":[],"deviceId":[],"entityId":[],"data":"{\t \"notification_id\": notification_id\t}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":880,"y":1680,"wires":[[]]},{"id":"25f8403babf025de","type":"ha-get-entities","z":"24a64c4fef191855","g":"480d998c98ab6485","name":"Get all active update entities","server":"f56de91.b429118","version":1,"rules":[{"property":"entity_id","logic":"is","value":"update\\..*","valueType":"re"},{"property":"state","logic":"is","value":"on","valueType":"str"}],"outputType":"array","outputEmptyResults":true,"outputLocationType":"msg","outputLocation":"payload","outputResultsCount":1,"x":380,"y":1580,"wires":[["06f05fa14ac46759","6d9200d56ac3326a"]]},{"id":"e1cbaf3c4b980cfd","type":"inject","z":"24a64c4fef191855","g":"480d998c98ab6485","name":"On start","props":[{"p":"payload"}],"repeat":"","crontab":"","once":true,"onceDelay":"60","topic":"","payload":"","payloadType":"date","x":160,"y":1580,"wires":[["25f8403babf025de"]]},{"id":"06f05fa14ac46759","type":"function","z":"24a64c4fef191855","g":"480d998c98ab6485","name":"setMessage","func":"msg.notification_id = \"updates_available\";\nmsg.message = \"[Updates](/config/updates)\\n\\n\";\nmsg.title = \"🎊 Updates available 🎊\";\n\nfor (var i = 0; i < msg.payload.length; i++)\n{\n var installed_version = msg.payload[i].attributes.installed_version;\n var latest_version = msg.payload[i].attributes.latest_version;\n var friendly_name = msg.payload[i].attributes.friendly_name;\n\n msg.message += \"• **\" + friendly_name + \"**: v\" + installed_version + \" ➤ v\" + latest_version + \"\\n\";\n}\n\nvar lastMessage = context.get(\"lastMessage\") || \"empty\";\ncontext.set(\"lastMessage\", msg.message);\n\nif (lastMessage === msg.message) return [ null, null];\nif (msg.payload.length === 0) return [ null, msg ];\nreturn [ msg, null ];","outputs":2,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":610,"y":1660,"wires":[["db5ef2d697b72908"],["c5eeaac585e61093"]],"outputLabels":["create message","delete message"]},{"id":"cf7e79daa6eb18eb","type":"server-state-changed","z":"24a64c4fef191855","g":"480d998c98ab6485","name":"On update change","server":"f56de91.b429118","version":5,"outputs":1,"exposeAsEntityConfig":"","entityId":"update\\..*","entityIdType":"regex","outputInitially":false,"stateType":"str","ifState":"","ifStateType":"str","ifStateOperator":"is","outputOnlyOnStateChange":true,"for":"1","forType":"num","forUnits":"seconds","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":true,"ignoreCurrentStateUnavailable":true,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":230,"y":1660,"wires":[["1d3c54ba0c04f410"]]},{"id":"1d3c54ba0c04f410","type":"rate-limiter","z":"24a64c4fef191855","g":"480d998c98ab6485","delay_action":"ratelimit","rate":"1","nbRateUnits":"2","rateUnits":"second","drop_select":"queue","addcurrentcount":false,"name":"","outputs":"1","buffer_size":"1","buffer_drop":"buffer_drop_old","emit_msg_2nd":false,"control_topic":"","version":0.0018,"x":330,"y":1620,"wires":[["25f8403babf025de"]]},{"id":"6d9200d56ac3326a","type":"function","z":"24a64c4fef191855","g":"480d998c98ab6485","name":"setMessage","func":"msg.notification_id = \"updates_available\";\nmsg.message = \"\";\nmsg.title = \"🎊 Updates available 🎊\";\n\nfor (var i = 0; i < msg.payload.length; i++)\n{\n var installed_version = msg.payload[i].attributes.installed_version;\n var latest_version = msg.payload[i].attributes.latest_version;\n var friendly_name = msg.payload[i].attributes.friendly_name;\n\n msg.message += \"• \" + friendly_name + \": v\" + installed_version + \" ➤ v\" + latest_version + \"\\n\"\n}\n\nvar lastMessage = context.get(\"lastMessage\") || \"empty\";\ncontext.set(\"lastMessage\", msg.message);\n\nif (lastMessage === msg.message) return [ null, null];\nif (msg.payload.length === 0) return [ null, msg ];\nreturn [ msg, null ];","outputs":2,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":610,"y":1580,"wires":[["d031ca501d710e55"],["20770ad6eeeec522"]],"outputLabels":["create message","delete message"]},{"id":"f56de91.b429118","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}]
Thank you! Yeah, I loved it! It helped me keep things updated and made it nice and easy to get to where I needed to go to see them.
@ElVit which npm package contains the rate-limiter node in your code?
EDIT: It appears to be https://flows.nodered.org/node/@cameo69/node-red-ratelimit. Is this correct?
Yes that's the correct package.
NetDaemon apps are deprecated and will be removed in version 2.0.0 of HACS. Note that apps that use current V3 version of the NetDaemon runtime is not supported at all.
See https://hacs.xyz/docs/categories/netdaemon_apps/
For this reason this app will no longer be maintained. For personal use I ported this app to node-red.
If someone is still interested in updated notifications for home assistant, I can post here my node red code.