Cam captures blueiris - MQTT - Nodered

Je vous partage un petit flow pour les users ou FUTUR users de Blue Iris.

J´ai configuré mes cameras de façon à ce qu´elles renvoient une info MQTT au trigger.

Cette info est ensuite récupérée sur NodeRed et traitée.

En gros :
Je test si l´alarme est active et ensuite si je reçois l´info Motion_On (envoyée par défaut au trigger de la cam).

Les caméras sont definies dans HA comme ceci :

`#* camera
#**********************************************************

camera:

  - platform: mjpeg
    mjpeg_url: http://ip_blueiris:81/mjpg/Jardin
    name: BI_Jardin
    username: !secret bi_username
    password: !secret bi_password
    authentication: basic
  - platform: mjpeg
    mjpeg_url: http://ip_blueiris:81/mjpg/GarageM
    name: BI_GarageM
    username: !secret bi_username
    password: !secret bi_password
    authentication: basic`

Pour l’exemple et elles remontent sur HA comme ceci :

Vient ensuite le formatage des données et le snapshot aue je stock dans le dossier
/config/www/cam_captures/
A définir au préalable…
On balance ensuite la sauce dans le flow notif de Mad!

le flow en question :

[{"id":"711f44dc.b8379c","type":"subflow","name":"Notification","info":"","category":"","in":[{"x":40,"y":480,"wires":[{"id":"bb6496b6.c5fb38"}]}],"out":[],"env":[],"color":"#4A88C0","icon":"font-awesome/fa-comment","status":{"x":1740,"y":100,"wires":[{"id":"4e1a58dc.5faf88","port":0}]}},{"id":"11d2840b.c4c60c","type":"switch","z":"711f44dc.b8379c","name":"Redirect to dest","property":"dest","propertyType":"msg","rules":[{"t":"eq","v":"html5","vt":"str"},{"t":"cont","v":"tts_","vt":"str"},{"t":"cont","v":"tel_","vt":"str"},{"t":"cont","v":"mail_","vt":"str"},{"t":"cont","v":"discord_","vt":"str"},{"t":"cont","v":"awtrix_","vt":"str"},{"t":"cont","v":"telegram_","vt":"str"},{"t":"cont","v":"sms_","vt":"str"}],"checkall":"true","repair":false,"outputs":8,"x":720,"y":580,"wires":[["4fba970c.85c0c8"],["45b1fc9f.afafc4"],["4fa3a02b.4b12f"],["e8221.6da3addf8"],["efc0ec78.d962a"],["c16b5b24.539fa8"],["fe563f3b.27a4"],["a3064f17.e8a538"]],"outputLabels":["","","mobile_clement","email","discord","","",""]},{"id":"8b310362.7bd2d","type":"api-call-service","z":"711f44dc.b8379c","g":"5cda64bd.38daec","name":"html5","server":"ad02b86e.5ee9c8","version":1,"debugenabled":false,"service_domain":"notify","service":"html5","entityId":"","data":"{\"message\":\"{{message}}\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1410,"y":100,"wires":[["4e1a58dc.5faf88"]]},{"id":"4fba970c.85c0c8","type":"function","z":"711f44dc.b8379c","g":"5cda64bd.38daec","name":"Check Short Message","func":"if (msg.short_message !== 'undefined' ) {\n    msg.short_message = msg.message;\n}\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1000,"y":100,"wires":[["81b3a930.d07b08"]]},{"id":"21b0610e.4e7cbe","type":"function","z":"711f44dc.b8379c","g":"ecef5432.e60ef8","name":"Get Configuration","func":"dest = msg.dest ;\nconfig = global.get(\"notif.home_assistant.dest.\"+dest) || 'undefined'\nmsg.entity_id = config;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1330,"y":380,"wires":[["868b8ddb.892fa"]]},{"id":"4fa3a02b.4b12f","type":"function","z":"711f44dc.b8379c","g":"ecef5432.e60ef8","name":"Check Short Message","func":"if (msg.short_message !== 'undefined' ) {\n    msg.short_message = msg.message;\n}\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1000,"y":380,"wires":[["24afc5e8.8aadfa"]]},{"id":"868b8ddb.892fa","type":"api-call-service","z":"711f44dc.b8379c","g":"ecef5432.e60ef8","name":"Home Assistant ","server":"ad02b86e.5ee9c8","version":1,"debugenabled":false,"service_domain":"notify","service":"{{ entity_id }}","entityId":"","data":"{\"message\":\"{{message}}\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1520,"y":380,"wires":[["e9da4b4c.c20068"]]},{"id":"ecea9947.6e5848","type":"function","z":"711f44dc.b8379c","g":"57b5e8a3.37d5e8","name":"Get Configuration","func":"dest = msg.dest ;\nconfig = global.get(\"notif.email.dest.\"+dest) || 'undefined'\nmsg.to = config;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1290,"y":500,"wires":[["bb7809ff.a41588","7bedaa16.93eda4"]]},{"id":"e8221.6da3addf8","type":"change","z":"711f44dc.b8379c","g":"57b5e8a3.37d5e8","name":"Message2Payload","rules":[{"t":"set","p":"payload","pt":"msg","to":"message","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":990,"y":500,"wires":[["ecea9947.6e5848"]]},{"id":"bb7809ff.a41588","type":"e-mail","z":"711f44dc.b8379c","g":"57b5e8a3.37d5e8","server":"172.17.0.1","port":"25","secure":false,"tls":false,"name":"","dname":"","x":1550,"y":500,"wires":[]},{"id":"82df49fa.94fce8","type":"split","z":"711f44dc.b8379c","name":"","splt":";","spltType":"str","arraySplt":"1","arraySpltType":"len","stream":false,"addname":"","x":130,"y":580,"wires":[["b75dca3b.2834b8"]]},{"id":"bb6496b6.c5fb38","type":"change","z":"711f44dc.b8379c","name":"Convert dest2payload","rules":[{"t":"set","p":"payload","pt":"msg","to":"dest","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":190,"y":480,"wires":[["82df49fa.94fce8"]]},{"id":"b75dca3b.2834b8","type":"delay","z":"711f44dc.b8379c","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"2","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":280,"y":580,"wires":[["91588395.e426"]]},{"id":"91588395.e426","type":"change","z":"711f44dc.b8379c","name":"Convert payload2dest","rules":[{"t":"set","p":"dest","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":490,"y":580,"wires":[["11d2840b.c4c60c"]]},{"id":"8c9a6e88.26e9f","type":"comment","z":"711f44dc.b8379c","name":"========== DOCUMENTATION FR ==========","info":"# Information\n\nCe subflow va vous permettre de notifier plusieurs service en même temps.\n\nActuellement il gérée les services :\n- HTML5 (by Home Assistant)\n- Discord\n- Telegram\n- Email\n- TTS\n- Home Assistant (Mobile App)\n- SMS via JPI8\n\n# Pré-requis\n\n- node-red-contrib-chatbot\n- node-red-contrib-chatbot-discord\n- node-red-contrib-string\n- node-red-contrib-home-assistant-websocket\n- node-red-node-email\n\n\n# Entrée\n\nVoici la liste des inputs actuellement possible :\n\n```\nmsg.title = \"Home Assistant - New version available\"\nmsg.dest = \"tel_clement;mail_clement;tts_80_hall\"  \nmsg.message = \"Home Assistant : New version available => 0.113.0 \\n\nhttps://github.com/home-assistant/core/releases/tag/0.113.0\"\nmsg.short_message = \"Home Assistant : New version available (0.113.0)\"\nmsg.image = \"/data/image.jpeg\"\nmsg.document = \"/data/doc.js\"\nmsg.video = \"/data/video.mp4\"\n```\n> Tout les inputs ne sont pas forcement compatible avec les differents services.\n\n## Titre / `msg.title`\n\n_Disponible sur : Email_\n\nTitre du mail.\n\n_Exemple:_\n\n```\nmsg.title = \"Home Assistant - New version available\"\n```\n\n## Message / `msg.message`\n\n_Disponible sur : Email / Telegram / Discord_\n\nVersion longue du message.\n\n_Exemple:_\n\n```\nmsg.message = \"Home Assistant : New version available => 0.113.0 \\n https://github.com/home-assistant/core/releases/tag/0.113.0\"\n```\n\n## Message court / `msg.short_message`\n\n_Disponible sur : HTML5 / Home Assistant_\n\nMessage reduit pour les services type \"popup\".\n\n_Exemple:_\n```\nmsg.short_message = \"Home Assistant : New version available (0.113.0)\"\n```\n\n**ATTENTION : Les messages est `trim` et les `\\n` sont remplacer par des espace**\n> => Si il n'est pas défini, je reprend les `msg.message`\n\n## Image / `msg.image`\n\n_Disponible sur : Telegram_\n\n_Exemple:_\n```\nmsg.image = \"/data/image.jpeg\"\nmsg.image = \"https://cdn.pixabay.com/photo/2015/04/23/22/00/tree-736885__340.jpg\"\n```\n## Document / `msg.document`\n\n_Disponible sur : Telegram_\n\n_Exemple:_\n```\nmsg.document = \"/data/doc.js\"\n```\n## Video / `msg.video`\n\n_Disponible sur : Telegram_\n\n_Exemple:_\n```\nmsg.video = \"/data/video.mp4\"\n```\n\n## Destinatation / `msg.dest`\nUn string qui contient la liste des services que vous désirez notifier séparer par des \"`;`\"\n\n_Exemple:_\n\n```\nmsg.dest = \"tel_clement;mail_clement;tts_80_hall\"  \n```\n\nLe message sera envoyé à :\n- tel_clement \n- mail_clement\n- tts_80_hall       \n\n### HTML5\nLa totalité des messages passe par ce système par défaut, pas besoin de l'ajouter en destination.\n\n### Discord \ndest doit commencer par `discord_`\n\n_Exemple:_\n```\nmsg.dest = \"discord_communaute_news;discord_maison_information;discord_maison_network\"  \n```\n\n### Home Assistant \ndest doit commencer par `tel_`\n\n_Exemple:_\n```\nmsg.dest = \"tel_clement;tel_papa;tel_maman\n```\n### Email \ndest doit commencer par `mail_`\n\n_Exemple:_\n```\nmsg.dest = \"mail_clement;mail_thomas\"\n```\n### Telegram\ndest doit commencer par `telegram_`\n\n_Exemple:_\n```\nmsg.dest = \"telegram_smarthome;telegram_familly\"\n```\n### TTS\ndest doit commencer par `tts_`\n\nFormat : `tts_{VOLUME}_{ENTITY_ID_DU_MEDIA_PLAYER}`\n\n_Exemple:_\n```\nmsg.dest = \"tts_80_hall\"\n```\n### SMS\ndest doit commencer par `sms_`\n\n_Exemple:_\n```\nmsg.dest = \"sms_clement\"\n```\n\n# Configuration\n\nLe subflow récupére sa configuration via la variable Global `notif.`\n\n> TTS n'a besoin d'aucune configuration particulière\n\n_Exemple:_\n\n```\nvar configuration = \n{\n    \"discord\": {\n        \"dest\": {\n            \"discord_communaute_news\": \"https://discord.com/api/webhooks/XXXXXXXXXXXXXXXX\",\n            \"discord_communaute_zwave\": \"https://discord.com/api/webhooks/YYYYYYYYYYYYYYYY\",\n            \"discord_communaute_diy\": \"https://discord.com/api/webhooks/ZZZZZZZZZZZZZZZZZ\",\n        }\n    },\n    \"home_assistant\": {\n        \"dest\": {\n            \"tel_clement\": \"mobile_app_oneplus_a6010\",\n            \"tel_nathalie\": \"mobile_app_oneplus_a5000\"\n        }\n    },\n    \"email\": {\n        \"dest\": {\n            \"mail_clement\": \"email1@domain.fr\",\n            \"mail_john\": \"email2@domain.fr\",\n            \"mail_bibi\": \"email3@domain.fr\"        \n        }\n    },\n    \"telegram\": {\n        \"dest\": {\n            \"telegram_smarthome\": \"ID1\",\n            \"telegram_bot\": \"ID2\"        \n        }\n    },\n    \"mattermost\": {\n        \"dest\": {\n            \"mattermost_home\" : \"https://mattermost.domain.fr/hooks/XXXXXXXXXXXXXXXXXXXXXXXXX\",\n            \"mattermost_volets\" : \"https://mattermost.domain.fr/hooks/YYYYYYYYYYYYYYYYYYYYYYYY\",\n        }\n    },\n    \"jpi\": {\n        \"address\": \"192.168.1.1:8080\",\n        \"dest\": {\n            \"sms_clement\": \"06XXXXXXXXX\",\n            \"sms_nathalie\": \"06YYYYYYYYY\",\n        }\n    }\n}\nglobal.set(\"notif\",configuration)\n\nreturn msg;\n```\n\nPour vous aidez dans la configuration voici une function qui va vous permettres de pousser votre configuration à chaque deploiement.\n\nTout ce passe dans le node `Function`.\n\n\n```\n[{\"id\":\"bbda9cf1.ad8ba\",\"type\":\"inject\",\"z\":\"4787bdd6.9aa874\",\"name\":\"\",\"props\":[{\"p\":\"payload\"}],\"repeat\":\"\",\"crontab\":\"\",\"once\":true,\"onceDelay\":0.1,\"topic\":\"\",\"payload\":\"\",\"payloadType\":\"date\",\"x\":130,\"y\":130,\"wires\":[[\"513d2c9.069c3d4\"]]},{\"id\":\"dacca689.055138\",\"type\":\"function\",\"z\":\"4787bdd6.9aa874\",\"name\":\"Configurateur EXEMPLE\",\"func\":\"var configuration = \\n{\\n    \\\"discord\\\": {\\n        \\\"dest\\\": {\\n            \\\"discord_communaute_news\\\": \\\"https://discord.com/api/webhooks/XXXXXXXXXXXXXXXX\\\",\\n            \\\"discord_communaute_zwave\\\": \\\"https://discord.com/api/webhooks/YYYYYYYYYYYYYYYY\\\",\\n            \\\"discord_communaute_diy\\\": \\\"https://discord.com/api/webhooks/ZZZZZZZZZZZZZZZZZ\\\",\\n        }\\n    },\\n    \\\"home_assistant\\\": {\\n        \\\"dest\\\": {\\n            \\\"tel_clement\\\": \\\"mobile_app_oneplus_a6010\\\",\\n            \\\"tel_nathalie\\\": \\\"mobile_app_oneplus_a5000\\\"\\n        }\\n    },\\n    \\\"email\\\": {\\n        \\\"dest\\\": {\\n            \\\"mail_clement\\\": \\\"email1@domain.fr\\\",\\n            \\\"mail_john\\\": \\\"email2@domain.fr\\\",\\n            \\\"mail_bibi\\\": \\\"email3@domain.fr\\\"        \\n        }\\n    },\\n    \\\"telegram\\\": {\\n        \\\"dest\\\": {\\n            \\\"telegram_smarthome\\\": \\\"ID1\\\",\\n            \\\"telegram_bot\\\": \\\"ID2\\\"        \\n        }\\n    },\\n    \\\"mattermost\\\": {\\n        \\\"dest\\\": {\\n            \\\"mattermost_home\\\" : \\\"https://mattermost.domain.fr/hooks/XXXXXXXXXXXXXXXXXXXXXXXXX\\\",\\n            \\\"mattermost_volets\\\" : \\\"https://mattermost.domain.fr/hooks/YYYYYYYYYYYYYYYYYYYYYYYY\\\",\\n        }\\n    },\\n    \\\"jpi\\\": {\\n        \\\"address\\\": \\\"192.168.1.1:8080\\\",\\n        \\\"dest\\\": {\\n            \\\"sms_clement\\\": \\\"06XXXXXXXXX\\\",\\n            \\\"sms_nathalie\\\": \\\"06YYYYYYYYY\\\",\\n        }\\n    }\\n}\\nglobal.set(\\\"notif\\\",configuration)\\n\\nreturn msg;\",\"outputs\":1,\"noerr\":0,\"initialize\":\"\",\"finalize\":\"\",\"x\":540,\"y\":130,\"wires\":[[]]},{\"id\":\"513d2c9.069c3d4\",\"type\":\"change\",\"z\":\"4787bdd6.9aa874\",\"name\":\"Remove old config\",\"rules\":[{\"t\":\"delete\",\"p\":\"notif\",\"pt\":\"global\"}],\"action\":\"\",\"property\":\"\",\"from\":\"\",\"to\":\"\",\"reg\":false,\"x\":310,\"y\":130,\"wires\":[[\"dacca689.055138\"]]}]\n```\n\nEt voici un exemple de flow d'input :\n\n```\n[{\"id\":\"66da3fb7.1e4ff\",\"type\":\"change\",\"z\":\"8a8a63c5.0c3c2\",\"name\":\"\",\"rules\":[{\"t\":\"set\",\"p\":\"title\",\"pt\":\"msg\",\"to\":\"Coucou\",\"tot\":\"str\"},{\"t\":\"set\",\"p\":\"message\",\"pt\":\"msg\",\"to\":\"Long Message\",\"tot\":\"str\"},{\"t\":\"set\",\"p\":\"short_message\",\"pt\":\"msg\",\"to\":\"Short Message\",\"tot\":\"str\"},{\"t\":\"set\",\"p\":\"dest\",\"pt\":\"msg\",\"to\":\"tel_clement;mail_clement\",\"tot\":\"str\"}],\"action\":\"\",\"property\":\"\",\"from\":\"\",\"to\":\"\",\"reg\":false,\"x\":740,\"y\":1880,\"wires\":[[\"7300bcc2.c97c34\"]]}]\n```","x":300,"y":300,"wires":[]},{"id":"3804914.3e0396e","type":"api-call-service","z":"711f44dc.b8379c","g":"3ba17f01.1ad71","name":"Media Player : ON","server":"ad02b86e.5ee9c8","version":1,"debugenabled":false,"service_domain":"media_player","service":"turn_on","entityId":"media_player.{{dest}}","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1590,"y":260,"wires":[["50d5d992.12f778"]]},{"id":"9be43a39.86fb38","type":"api-current-state","z":"711f44dc.b8379c","g":"3ba17f01.1ad71","name":"Get Current Volume","server":"ad02b86e.5ee9c8","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"media_player.{{dest}}","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":1960,"y":260,"wires":[["ce050387.d13e9"]]},{"id":"50d5d992.12f778","type":"delay","z":"711f44dc.b8379c","g":"3ba17f01.1ad71","name":"","pauseType":"delay","timeout":"3","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1780,"y":260,"wires":[["9be43a39.86fb38"]]},{"id":"5d1f7d2d.00d694","type":"api-call-service","z":"711f44dc.b8379c","g":"3ba17f01.1ad71","name":"Set volume","server":"ad02b86e.5ee9c8","version":1,"debugenabled":true,"service_domain":"media_player","service":"volume_set","entityId":"media_player.{{dest}}","data":"{\"entity_id\":\"media_player.{{ dest }}\",\"volume_level\":\"{{ volume }}\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":2390,"y":260,"wires":[["b8f7a36e.3e1aa"]]},{"id":"ce050387.d13e9","type":"change","z":"711f44dc.b8379c","g":"3ba17f01.1ad71","name":"Save Current Volume","rules":[{"t":"set","p":"current_volume","pt":"msg","to":"data.attributes.volume_level","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":2180,"y":260,"wires":[["5d1f7d2d.00d694"]]},{"id":"eaee88f3.fe9138","type":"api-current-state","z":"711f44dc.b8379c","g":"3ba17f01.1ad71","name":"Get State","server":"ad02b86e.5ee9c8","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"media_player.{{dest}}","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":1260,"y":260,"wires":[["60a2789f.1842a8"]]},{"id":"45b1fc9f.afafc4","type":"function","z":"711f44dc.b8379c","g":"3ba17f01.1ad71","name":"Split Message","func":"dest = msg.dest.split('_');\nmsg.volume = dest[1]/100;\nmsg.dest = msg.dest.replace('tts_'+dest[1]+\"_\",\"\");\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":980,"y":260,"wires":[["4bbdd1c0.ff6a7"]]},{"id":"b8f7a36e.3e1aa","type":"api-call-service","z":"711f44dc.b8379c","g":"3ba17f01.1ad71","name":"Play TTS","server":"ad02b86e.5ee9c8","version":1,"debugenabled":false,"service_domain":"tts","service":"google_translate_say","entityId":"media_player.{{dest}}","data":"{\"entity_id\":\"media_player.{{ dest }}\",\"message\":\"{{ message }}\",\"language\":\"fr\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":2540,"y":260,"wires":[["3ed2b5a9.244f3a"]]},{"id":"5214f35f.538f4c","type":"api-call-service","z":"711f44dc.b8379c","g":"3ba17f01.1ad71","name":"Reset volume","server":"ad02b86e.5ee9c8","version":1,"debugenabled":true,"service_domain":"media_player","service":"volume_set","entityId":"media_player.{{dest}}","data":"{\"entity_id\":\"media_player.{{ dest }}\",\"volume_level\":\"{{ current_volume }}\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":3020,"y":260,"wires":[["1af7d6f3.9aaa19"]]},{"id":"3ed2b5a9.244f3a","type":"delay","z":"711f44dc.b8379c","g":"3ba17f01.1ad71","name":"","pauseType":"delay","timeout":"3","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":2700,"y":260,"wires":[["5d7f8264.16666c"]]},{"id":"5d7f8264.16666c","type":"api-current-state","z":"711f44dc.b8379c","g":"3ba17f01.1ad71","name":"Get State","server":"ad02b86e.5ee9c8","version":1,"outputs":2,"halt_if":"playing","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"media_player.{{dest}}","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":2840,"y":260,"wires":[["ca608072.a3c81"],["5214f35f.538f4c"]]},{"id":"1af7d6f3.9aaa19","type":"api-call-service","z":"711f44dc.b8379c","g":"3ba17f01.1ad71","name":"Media Player : OFF","server":"ad02b86e.5ee9c8","version":1,"debugenabled":false,"service_domain":"media_player","service":"turn_off","entityId":"media_player.{{dest}}","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":3210,"y":260,"wires":[["18cbe457.1dfa6c"]]},{"id":"ca608072.a3c81","type":"link out","z":"711f44dc.b8379c","g":"3ba17f01.1ad71","name":"OUT : Wait idle","links":[],"x":3020,"y":220,"wires":[],"l":true},{"id":"e5fe9d8c.96704","type":"link in","z":"711f44dc.b8379c","g":"3ba17f01.1ad71","name":"IN : Wait idle","links":[],"x":2530,"y":220,"wires":[["3ed2b5a9.244f3a"]],"l":true},{"id":"60a2789f.1842a8","type":"switch","z":"711f44dc.b8379c","g":"3ba17f01.1ad71","name":"Check status","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"off","vt":"str"},{"t":"eq","v":"idle","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":1410,"y":260,"wires":[["3804914.3e0396e"],["3804914.3e0396e"]]},{"id":"81b3a930.d07b08","type":"string","z":"711f44dc.b8379c","g":"5cda64bd.38daec","name":"","methods":[{"name":"replaceAll","params":[{"type":"str","value":"\\n"},{"type":"str","value":" "}]},{"name":"trim","params":[]}],"prop":"message","propout":"message","object":"msg","objectout":"msg","x":1210,"y":100,"wires":[["8b310362.7bd2d"]]},{"id":"24afc5e8.8aadfa","type":"string","z":"711f44dc.b8379c","g":"ecef5432.e60ef8","name":"","methods":[{"name":"replaceAll","params":[{"type":"str","value":"\\n"},{"type":"str","value":" "}]},{"name":"trim","params":[]}],"prop":"message","propout":"message","object":"msg","objectout":"msg","x":1170,"y":380,"wires":[["21b0610e.4e7cbe"]]},{"id":"4bbdd1c0.ff6a7","type":"string","z":"711f44dc.b8379c","g":"3ba17f01.1ad71","name":"","methods":[{"name":"replaceAll","params":[{"type":"str","value":"\\n"},{"type":"str","value":" "}]},{"name":"trim","params":[]}],"prop":"message","propout":"message","object":"msg","objectout":"msg","x":1130,"y":260,"wires":[["eaee88f3.fe9138"]]},{"id":"4e1a58dc.5faf88","type":"function","z":"711f44dc.b8379c","g":"5cda64bd.38daec","name":"Log","func":"node.log(\"NOTIF / HTML5 => OK\")\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1610,"y":100,"wires":[[]]},{"id":"e9da4b4c.c20068","type":"function","z":"711f44dc.b8379c","g":"ecef5432.e60ef8","name":"Log","func":"node.log(\"NOTIF / Home Assistant => OK\")\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1830,"y":380,"wires":[[]]},{"id":"7bedaa16.93eda4","type":"function","z":"711f44dc.b8379c","g":"57b5e8a3.37d5e8","name":"Log","func":"node.log(\"NOTIF / Email => OK\")\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1830,"y":500,"wires":[[]]},{"id":"18cbe457.1dfa6c","type":"function","z":"711f44dc.b8379c","g":"3ba17f01.1ad71","name":"Log","func":"node.log(\"NOTIF / TTS => OK\")\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":3370,"y":260,"wires":[[]]},{"id":"75261914.04f268","type":"http request","z":"711f44dc.b8379c","g":"53f4a8db.b4d4","name":"SMS via JPI","method":"use","ret":"txt","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","authType":"","x":1210,"y":1220,"wires":[["8dd71a85.f2d438"]]},{"id":"8dd71a85.f2d438","type":"function","z":"711f44dc.b8379c","g":"53f4a8db.b4d4","name":"Log","func":"node.log(\"NOTIF / SMS => OK\")\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1360,"y":1220,"wires":[[]]},{"id":"a3064f17.e8a538","type":"function","z":"711f44dc.b8379c","g":"53f4a8db.b4d4","name":"Get Configuration","func":"var dest = msg.dest ;\nvar jpi_address = global.get('notif.jpi.address');\nvar sms_number = global.get(\"notif.jpi.dest.\"+dest) || 'undefined'\nvar message = encodeURIComponent(msg.message);\n\nmsg.method = \"POST\"\nmsg.url = \"http://\"+jpi_address+\"/?action=sendSms&number=\"+sms_number+\"&message=\"+message\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1000,"y":1220,"wires":[["75261914.04f268"]]},{"id":"3a88bff2.0f885","type":"template","z":"711f44dc.b8379c","g":"92cd7bed.1088b8","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{\n \"name\":\"NodeRedNotification\",\n \"icon\":225,\n \"moveIcon\":true,\n \"lifetime\":999999,\n \"text\":\"{{payload}}\",\n \"repeat\":2,\n \"color\":[0,255,0]\n}","output":"str","x":1180,"y":720,"wires":[["ca7ad5a4.1f19e8"]]},{"id":"2106adfe.6f48b2","type":"http request","z":"711f44dc.b8379c","g":"92cd7bed.1088b8","name":"awtrix notify","method":"POST","ret":"txt","paytoqs":"ignore","url":"http://192.168.100.9:7000/api/v3/notify","tls":"","persist":false,"proxy":"","authType":"","x":1570,"y":720,"wires":[["bef8f932.7769a8"]]},{"id":"ca7ad5a4.1f19e8","type":"function","z":"711f44dc.b8379c","g":"92cd7bed.1088b8","name":"awtrix headers","func":"msg.headers = {}\nmsg.headers[\"content-type\"] = \"application/json\"\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1360,"y":720,"wires":[["2106adfe.6f48b2"]]},{"id":"bef8f932.7769a8","type":"function","z":"711f44dc.b8379c","g":"92cd7bed.1088b8","name":"Log","func":"node.log(\"NOTIF / Awtrix => OK\")\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1730,"y":720,"wires":[[]]},{"id":"c16b5b24.539fa8","type":"change","z":"711f44dc.b8379c","g":"92cd7bed.1088b8","name":"Message2Payload","rules":[{"t":"set","p":"payload","pt":"msg","to":"message","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":990,"y":720,"wires":[["3a88bff2.0f885"]]},{"id":"3cc4c002.98b36","type":"function","z":"711f44dc.b8379c","g":"ecdc435a.d458e","name":"Log","func":"node.log(\"NOTIF / Mattermost => OK\")\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1850,"y":620,"wires":[[]]},{"id":"efc0ec78.d962a","type":"function","z":"711f44dc.b8379c","g":"ecdc435a.d458e","name":"Get Configuration","func":"dest = msg.dest ;\nconfig = global.get(\"notif.discord.\"+dest) || 'undefined'\nmsg.webhook = config;\n\n// MESSAGE\nusername = msg.username || \"undefined\";\ncontent = msg.message || \"undefined\";\navatar_url = msg.avatar_url || \"undefined\";\n\n// AUHTOR\nembeds_author_name = msg.embeds_author_name || \"undefined\";\nembeds_author_icon_url = msg.embeds_author_icon_url || \"undefined\";\nembeds_author_url = msg.embeds_author_url || \"undefined\";\n\nembeds_title = msg.embeds_title || \"undefined\";\nembeds_description = msg.embeds_description || \"undefined\";\nembeds_image = msg.embeds_image || \"undefined\";\nembeds_color = msg.embeds_color || \"undefined\";\nembeds_url = msg.embeds_url || \"undefined\";\nembeds_thumbnail = msg.embeds_thumbnail || \"undefined\";\nembeds_footer = msg.embeds_footer || \"undefined\";\n\nmsg.data = {};\nembeds_data = [];\n\nif (content != \"undefined\") {\n    msg.data.content = content;\n}    \nif (username == \"undefined\") {\n    msg.data.username = \"Node-RED\";\n}    \nif (avatar_url == \"undefined\") {\n    msg.data.avatar_url = \"https://silanus.fr/sin/wp-content/uploads/2018/02/node-red-icon.png\";\n}  \n\nif (embeds_url != \"undefined\" || embeds_title != \"undefined\" || embeds_description != \"undefined\" || embeds_thumbnail != \"undefined\" || embeds_image != \"undefined\" || embeds_footer != \"undefined\") {\n    message = {}\n    \n    if (embeds_author_name != \"undefined\" || embeds_author_icon_url != \"undefined\" || embeds_author_url != \"undefined\") {\n        message.author = {}\n        \n        if(embeds_author_name != \"undefined\") {\n            message.author.name = embeds_author_name;\n        }\n        if(embeds_author_url != \"undefined\") {\n            message.author.url = embeds_author_url;\n        }\n        if(embeds_author_icon_url != \"undefined\") {\n            message.author.icon_url = embeds_author_icon_url;\n        }    \n    }\n    \n    if(embeds_title != \"undefined\") {\n        message.title = msg.embeds_title;\n    }\n    if(embeds_description != \"undefined\") {\n        message.description = msg.embeds_description;\n    }\n    if(embeds_color != \"undefined\") {\n        message.color = parseInt(msg.embeds_color,16);\n    }    \n    if(embeds_url != \"undefined\") {\n        message.url = msg.embeds_url;\n    }    \n    if(embeds_thumbnail != \"undefined\") {\n        message.thumbnail = {};\n        message.thumbnail.url = msg.embeds_thumbnail;\n    }\n    if(embeds_image != \"undefined\") {\n        message.image = {};\n        message.image.url = msg.embeds_image;\n    }\n    if(embeds_footer != \"undefined\") {\n        message.footer = {};\n        message.footer.text = msg.embeds_footer;\n    }\n\n    embeds_data.push(message);\n    msg.data.embeds = embeds_data;\n}  \n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":990,"y":620,"wires":[["d0d93d8a.89c1"]]},{"id":"3ba45a2.78467a6","type":"http request","z":"711f44dc.b8379c","g":"ecdc435a.d458e","name":"Post Request","method":"use","ret":"txt","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","authType":"","x":1660,"y":620,"wires":[["3cc4c002.98b36"]]},{"id":"164e3ff5.5371e","type":"function","z":"711f44dc.b8379c","g":"ecdc435a.d458e","name":"Format Query","func":"msg.url = msg.webhook\nmsg.method = \"POST\"\nmsg.headers = {};\nmsg.headers['Content-Type'] = 'application/json';\nmsg.payload = msg.data;\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1460,"y":620,"wires":[["3ba45a2.78467a6"]]},{"id":"d0d93d8a.89c1","type":"json","z":"711f44dc.b8379c","g":"ecdc435a.d458e","name":"Convert Data to String","property":"data","action":"","pretty":false,"x":1220,"y":620,"wires":[["164e3ff5.5371e"]]},{"id":"fe563f3b.27a4","type":"function","z":"711f44dc.b8379c","g":"286dba59.7ed416","name":"Get Configuration","func":"dest = msg.dest ;\nconfig = global.get(\"notif.telegram.dest.\"+dest) || 'undefined'\nvar retour = [];\n\n// Message\nif (msg.message !== \"\") {\n    payload = {\n      chatId: config,\n      type: 'message',\n      content: msg.message\n    }\n}else{\n    payload = {\"chatId\": none};\n}\nretour.push({payload});\n\n// Image\nif (msg.image !== \"\") {\n    payload = {\n      chatId: config,\n      type: 'photo',\n      content: msg.image\n    }        \n}else{\n    payload = {\"chatId\": none};\n}\nretour.push({payload})\n\n// Video\nif (msg.video !== \"\") {\n    payload = {\n      chatId: config,\n      type: 'video',\n      content: msg.video\n    }        \n}else{\n    payload = {\"chatId\": none};\n}\nretour.push({payload})\n\n// Audio\nif (msg.audio !== \"\") {\n    payload = {\n      chatId: config,\n      type: 'audio',\n      content: msg.audio\n    }        \n}else{\n    payload = {\"chatId\": none};\n}\nretour.push({payload})\n\n// Location\nif (msg.location !== \"\") {\n    payload = {\n      chatId: config,\n      type: 'location',\n      content: msg.location\n    }        \n}else{\n    payload = {\"chatId\": none};\n}\nretour.push({payload})\n\n\n// Animation\nif (msg.animation !== \"\") {\n    payload = {\n      chatId: config,\n      type: 'animation',\n      content: msg.animation\n    }        \n}else{\n    payload = {\"chatId\": none};\n}\nretour.push({payload})\n\n\n// Voice\nif (msg.voice !== \"\") {\n    payload = {\n      chatId: config,\n      type: 'voice',\n      content: msg.voice\n    }        \n}else{\n    payload = {\"chatId\": none};\n}\nretour.push({payload})\n\n// Contact\nif (msg.contact !== \"\") {\n    payload = {\n      chatId: config,\n      type: 'contact',\n      content: msg.contact\n    }        \n}else{\n    payload = {\"chatId\": none};\n}\nretour.push({payload})\n\n\nreturn retour;","outputs":8,"noerr":0,"initialize":"","finalize":"","x":990,"y":960,"wires":[["a1937b5e.f10f08"],["74de5d62.659ac4"],["6bccc1cf.04292"],["ba9c06f3.258228"],["fdc2c34.6b5b44"],["4adb3e12.c6031"],["8098137f.117d6"],["8c1c7eae.f4fe8"]]},{"id":"a5718a48.8221c8","type":"function","z":"711f44dc.b8379c","g":"286dba59.7ed416","name":"Log","func":"node.log(\"NOTIF / Telegram => OK\")\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1670,"y":960,"wires":[[]]},{"id":"a1937b5e.f10f08","type":"switch","z":"711f44dc.b8379c","g":"286dba59.7ed416","name":"Message ?","property":"payload.content","propertyType":"msg","rules":[{"t":"nnull"}],"checkall":"true","repair":false,"outputs":1,"x":1250,"y":820,"wires":[["10f56b1e.f606e5"]]},{"id":"74de5d62.659ac4","type":"switch","z":"711f44dc.b8379c","g":"286dba59.7ed416","name":"Image ?","property":"payload.content","propertyType":"msg","rules":[{"t":"nnull"}],"checkall":"true","repair":false,"outputs":1,"x":1240,"y":860,"wires":[["10f56b1e.f606e5"]]},{"id":"6bccc1cf.04292","type":"switch","z":"711f44dc.b8379c","g":"286dba59.7ed416","name":"Video ?","property":"payload.content","propertyType":"msg","rules":[{"t":"nnull"}],"checkall":"true","repair":false,"outputs":1,"x":1240,"y":900,"wires":[["10f56b1e.f606e5"]]},{"id":"ba9c06f3.258228","type":"switch","z":"711f44dc.b8379c","g":"286dba59.7ed416","name":"Audio ?","property":"payload.content","propertyType":"msg","rules":[{"t":"nnull"}],"checkall":"true","repair":false,"outputs":1,"x":1240,"y":940,"wires":[["10f56b1e.f606e5"]]},{"id":"8098137f.117d6","type":"switch","z":"711f44dc.b8379c","g":"286dba59.7ed416","name":"Voice ?","property":"payload.content","propertyType":"msg","rules":[{"t":"nnull"}],"checkall":"true","repair":false,"outputs":1,"x":1240,"y":1060,"wires":[["10f56b1e.f606e5"]]},{"id":"fdc2c34.6b5b44","type":"switch","z":"711f44dc.b8379c","g":"286dba59.7ed416","name":"Location ?","property":"payload.content","propertyType":"msg","rules":[{"t":"nnull"}],"checkall":"true","repair":false,"outputs":1,"x":1250,"y":980,"wires":[["10f56b1e.f606e5"]]},{"id":"4adb3e12.c6031","type":"switch","z":"711f44dc.b8379c","g":"286dba59.7ed416","name":"Animation ?","property":"payload.content","propertyType":"msg","rules":[{"t":"nnull"}],"checkall":"true","repair":false,"outputs":1,"x":1250,"y":1020,"wires":[["10f56b1e.f606e5"]]},{"id":"8c1c7eae.f4fe8","type":"switch","z":"711f44dc.b8379c","g":"286dba59.7ed416","name":"Contact ?","property":"payload.content","propertyType":"msg","rules":[{"t":"nnull"}],"checkall":"true","repair":false,"outputs":1,"x":1240,"y":1100,"wires":[["10f56b1e.f606e5"]]},{"id":"10f56b1e.f606e5","type":"telegram sender","z":"711f44dc.b8379c","g":"286dba59.7ed416","name":"","bot":"53d573c4.726a2c","x":1490,"y":960,"wires":[["a5718a48.8221c8"]]},{"id":"53d573c4.726a2c","type":"telegram bot","botname":"dcj4_bot","usernames":"","chatids":"","baseapiurl":"","updatemode":"polling","pollinterval":"300","usesocks":false,"sockshost":"","socksport":"6667","socksusername":"anonymous","sockspassword":"","bothost":"","localbotport":"8443","publicbotport":"8443","privatekey":"","certificate":"","useselfsignedcertificate":false,"sslterminated":false,"verboselogging":false},{"id":"231101b9.14c52e","type":"mqtt in","z":"797e40da.11773","name":"Motion Cam","topic":"Camera/#","qos":"2","datatype":"auto","broker":"946c71c6.9448b","x":150,"y":1020,"wires":[["43d3d842.5c6bf8"]]},{"id":"35d21b8e.bc7434","type":"switch","z":"797e40da.11773","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"Motion_ON","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":430,"y":1020,"wires":[["3e378c52.ab0284"]]},{"id":"3e378c52.ab0284","type":"function","z":"797e40da.11773","name":"","func":"var cam = { payload: msg.topic.replace('Camera/','camera.bi_')};\nreturn cam;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":560,"y":1020,"wires":[["4f14692c.dca3c8"]]},{"id":"e73655d9.c05998","type":"api-call-service","z":"797e40da.11773","name":"Snapshot","server":"ad02b86e.5ee9c8","version":1,"debugenabled":true,"service_domain":"camera","service":"snapshot","entityId":"","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":500,"y":1100,"wires":[["327ef443.83af0c"]]},{"id":"4f14692c.dca3c8","type":"function","z":"797e40da.11773","name":"get camera info","func":"const camera = msg.payload;\nconst filename = '/config/www/cam_captures/' + camera + '.jpg'\nmsg.payload = {\n    camera: camera,\n    filename: filename\n}\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":720,"y":1020,"wires":[["5c3183e8.cba4ac"]]},{"id":"5c3183e8.cba4ac","type":"function","z":"797e40da.11773","name":"prepare snap","func":"var camera_name = msg.camera;\nconst filename = msg.payload.filename\nconst name = '/config/www/cam_captures/' + camera_name + '.jpg'\n\nmsg.payload = {\n    data: {\n        entity_id: msg.payload.camera,\n        filename: filename\n    }\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":890,"y":1020,"wires":[["e73655d9.c05998"]]},{"id":"327ef443.83af0c","type":"function","z":"797e40da.11773","name":"prepare notifs","func":"//node.warn(msg);\nconst baseUrl = \"https://DNS_HA_A_CHANGER/local/cam_captures/\";\nconst imagePath = msg.payload.data.filename;\nconst imageFilename = imagePath.split(/[\\s\\/]+/).pop();\nconst imageUrl = baseUrl + imageFilename;\nmsg.dest = \"discord_notifications;telegram_jona\";\nmsg.message = \"Alarme\"\n\n//Telegram\nmsg.image = imageUrl;\n\n//Discord\nmsg.embeds_title = \"Effraction\";\nmsg.embeds_image = imageUrl;\nmsg.embeds_footer = \"By Dcjona\";\nmsg.embeds_color = \"FF0000\"\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":680,"y":1100,"wires":[["517d027f.1308ec"]]},{"id":"517d027f.1308ec","type":"subflow:711f44dc.b8379c","z":"797e40da.11773","name":"","env":[],"x":870,"y":1100,"wires":[]},{"id":"43d3d842.5c6bf8","type":"api-current-state","z":"797e40da.11773","name":"Armée?","server":"ad02b86e.5ee9c8","version":1,"outputs":2,"halt_if":"disarmed","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"alarm_control_panel.home_alarm","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":300,"y":1020,"wires":[["35d21b8e.bc7434"],[]]},{"id":"946c71c6.9448b","type":"mqtt-broker","name":"MQTT Docker 2","broker":"192.168.100.10","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"ad02b86e.5ee9c8","type":"server","name":"Home Assistant ip","legacy":false,"addon":false,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]

Ce qui donne au final en cas de détection de l´alarme une capture envoyée sur telegram et discord

Merci pour le’ partage, j’ai plus qu’a Passer sur blueiris …
Juste une petite remarque, tu pourrais référencer le github de Mad au lieu du flow lui même, ça permet d’avoir la doc et surtout le flow a jour :slight_smile:

https://github.com/m4dm4rtig4n/node-red-flow-notification

1 J'aime