Envoyer info payload dans un notify

Bonjour,

je me lance dans node-red, et j’essaye d’envoyer un message contenant la valeur payload, mais je ne la reçois pas.

voici le contenu du message :
{
« message »: « valeur payload : {{payload}} »
}
alors dans dans le debug, je vois bien le contenu du payload qui est a : « Capteur test »
et je ne reçois dans le notify que « valeur payload : »
j’ai du louper quelque chose, mais je ne vois pas quoi.
merci pour votre aide.

Salut,

Partager le flow par exemple ? :joy:

Bonsoir,

J’utilise cette syntaxe pour une notify sur mon portable :

{"message":"{{payload}}"}

Dans un autre cas je le fait comme ça avec une variable :

image

var datejour = global.get('datejour');
var dateexpir = global.get('dateexpir');
var tempsval = dateexpir - datejour;
tempsval = ((tempsval /3600) /24);
tempsval = parseFloat(tempsval).toFixed(0);
msg.payload = Number(tempsval);
global.set('datenewexpir', msg.payload);
return msg;

Je mets le flow complet :wink:

[{"id":"1c21385eb72b028f","type":"tab","label":"Certificat","disabled":false,"info":"","env":[]},{"id":"cba922d97d245edc","type":"debug","z":"1c21385eb72b028f","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":990,"y":60,"wires":[]},{"id":"f2b9ad5c95cf94bf","type":"api-current-state","z":"1c21385eb72b028f","name":"Expiration certificat","server":"443ff1c5.63d78","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"sensor.cert_expiry_timestamp_mondomaine_fr","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":0,"forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":410,"y":60,"wires":[["642f1eec7ca4c701"]]},{"id":"9b1e1efe9b9c8efa","type":"ui_date_picker","z":"1c21385eb72b028f","name":"","label":"date","group":"7581546f.42c224","order":2,"width":0,"height":0,"passthru":true,"topic":"topic","topicType":"msg","className":"","x":370,"y":180,"wires":[["ccc10d5dde56fc26"]]},{"id":"642f1eec7ca4c701","type":"function","z":"1c21385eb72b028f","name":"Expir","func":"msg.payload = msg.payload.substring(0,msg.payload.length -15);\nmsg.payload = Date.parse(msg.payload) /1000;\nglobal.set('dateexpir', msg.payload);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":630,"y":60,"wires":[["cba922d97d245edc","403ea73e67190e45"]]},{"id":"1cd3b498c4ccc80a","type":"debug","z":"1c21385eb72b028f","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":990,"y":180,"wires":[]},{"id":"ccc10d5dde56fc26","type":"function","z":"1c21385eb72b028f","name":"Jour","func":"msg.payload = msg.payload /1000 ;\nmsg.payload = parseFloat(msg.payload).toFixed(0);\nmsg.payload = Number(msg.payload);\nglobal.set('datejour', msg.payload);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":630,"y":180,"wires":[["1cd3b498c4ccc80a"]]},{"id":"403ea73e67190e45","type":"function","z":"1c21385eb72b028f","name":"DiffDate","func":"var datejour = global.get('datejour');\nvar dateexpir = global.get('dateexpir');\nvar tempsval = dateexpir - datejour;\ntempsval = ((tempsval /3600) /24);\ntempsval = parseFloat(tempsval).toFixed(0);\nmsg.payload = Number(tempsval);\nglobal.set('datenewexpir', msg.payload);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":380,"y":280,"wires":[["0cb5cb5bc50ed3d6","98e564e8e0240c5d"]]},{"id":"0cb5cb5bc50ed3d6","type":"debug","z":"1c21385eb72b028f","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":990,"y":400,"wires":[]},{"id":"98e564e8e0240c5d","type":"switch","z":"1c21385eb72b028f","name":"","property":"payload","propertyType":"msg","rules":[{"t":"lte","v":"3","vt":"str"},{"t":"gte","v":"85","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":630,"y":280,"wires":[["d35cac400d66e9f6","078994a9ad5dc476"],["ade0b09dc5933592"]]},{"id":"d35cac400d66e9f6","type":"api-call-service","z":"1c21385eb72b028f","name":"","server":"443ff1c5.63d78","version":5,"debugenabled":false,"domain":"script","service":"renouvellement_certificat","areaId":[],"deviceId":[],"entityId":[],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":930,"y":280,"wires":[[]]},{"id":"31743c2828fef00c","type":"inject","z":"1c21385eb72b028f","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"date","x":100,"y":60,"wires":[["f2b9ad5c95cf94bf","9b1e1efe9b9c8efa"]]},{"id":"031da89e7b5514d5","type":"server-state-changed","z":"1c21385eb72b028f","name":"Couché Soleil + 2 Min","server":"443ff1c5.63d78","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sun.sun","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"below_horizon","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":"2","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"date"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":120,"y":200,"wires":[["f2b9ad5c95cf94bf","9b1e1efe9b9c8efa"],[]]},{"id":"078994a9ad5dc476","type":"debug","z":"1c21385eb72b028f","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":990,"y":340,"wires":[]},{"id":"ade0b09dc5933592","type":"delay","z":"1c21385eb72b028f","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":480,"y":460,"wires":[["f29b6c0e74abdea6"]]},{"id":"92d9500488e8c070","type":"api-call-service","z":"1c21385eb72b028f","name":"","server":"443ff1c5.63d78","version":5,"debugenabled":false,"domain":"notify","service":"mobile_app_iphone_de_bob","areaId":[],"deviceId":[],"entityId":[],"data":"{\"message\":\"{{payload}}\"}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":940,"y":460,"wires":[[]]},{"id":"92a7bfa1e1960cd0","type":"server-state-changed","z":"1c21385eb72b028f","name":"Couché Soleil + 7 Min","server":"443ff1c5.63d78","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sun.sun","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"below_horizon","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":"7","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"date"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":120,"y":280,"wires":[["f2b9ad5c95cf94bf","9b1e1efe9b9c8efa"],[]]},{"id":"f29b6c0e74abdea6","type":"change","z":"1c21385eb72b028f","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"Certificat renouvellé pour xxx jours","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"xxx","fromt":"str","to":"datenewexpir","tot":"global"}],"action":"","property":"","from":"","to":"","reg":false,"x":660,"y":460,"wires":[["92d9500488e8c070","36299ebc5fe3f69f"]]},{"id":"36299ebc5fe3f69f","type":"debug","z":"1c21385eb72b028f","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":990,"y":540,"wires":[]},{"id":"443ff1c5.63d78","type":"server","name":"Home Assistant","version":2,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30},{"id":"7581546f.42c224","type":"ui_group","name":"Utilities","tab":"a577685a.d0bd48","order":3,"disp":true,"width":"6","collapse":false},{"id":"a577685a.d0bd48","type":"ui_tab","name":"Arbeitszimmer","icon":"dashboard","order":3}]

Bob

1 « J'aime »

Je ne sais toujours pas comment mettre le flows sur une ligne !!!
Bob

En respectant les sauts de lignes

  • 4 backquotes
  • flow
  • 4 backquotes

backquote = `

hello,

voici mon flow

[{« id »:« 15745c2870a38df9 »,« type »:« tab »,« label »:« Flow 1 »,« disabled »:false,« info »:"",« env »:[]},{« id »:« b5bb83b2d2cf2605 »,« type »:« server-state-changed »,« z »:« 15745c2870a38df9 »,« name »:« Ouverture Test »,« server »:« 5d89433.7a064bc »,« version »:4,« exposeToHomeAssistant »:false,« haConfig »:[{« property »:« name »,« value »:""},{« property »:« icon »,« value »:""}],« entityidfilter »:« binary_sensor.on_off_do_test »,« entityidfiltertype »:« exact »,« outputinitially »:false,« state_type »:« str »,« haltifstate »:« on »,« halt_if_type »:« str »,« halt_if_compare »:« is »,« outputs »:2,« output_only_on_state_change »:true,« for »:« 0 »,« forType »:« num »,« forUnits »:« minutes »,« 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 »:120,« y »:100,« wires »:[[« c6386d67ce559c14 »],[]]},{« id »:« e5e6ed89edcc79f7 »,« type »:« api-current-state »,« z »:« 15745c2870a38df9 »,« name »:« Test si alarme en marche »,« server »:« 5d89433.7a064bc »,« version »:3,« outputs »:2,« halt_if »:« disarmed »,« halt_if_type »:« str »,« halt_if_compare »:« is »,« entity_id »:« sensor.etat_alarme »,« state_type »:« str »,« blockInputOverrides »:false,« outputProperties »:[],« for »:« 0 »,« forType »:« num »,« forUnits »:« minutes »,« override_topic »:false,« state_location »:« payload »,« override_payload »:« msg »,« entity_location »:« data »,« override_data »:« msg »,« x »:370,« y »:300,« wires »:[[« 744a2a66e0fb7c82 »],[]]},{« id »:« 8ace0fdf21a3afed »,« type »:« api-call-service »,« z »:« 15745c2870a38df9 »,« name »:« Envoi Msg disarmed »,« server »:« 5d89433.7a064bc »,« version »:5,« debugenabled »:false,« domain »:« notify »,« service »:« mobile_app_iphonellf »,« areaId »:[],« deviceId »:[],« entityId »:[],« data »:"{\t « message »: « disarmed {{payload}} »\t}",« dataType »:« jsonata »,« mergeContext »:"",« mustacheAltTags »:false,« outputProperties »:[],« queue »:« none »,« x »:660,« y »:460,« wires »:[[« 22d25057cbc5b096 »]]},{« id »:« 744a2a66e0fb7c82 »,« type »:« template »,« z »:« 15745c2870a38df9 »,« name »:« Message intrusion »,« field »:« payload »,« fieldType »:« msg »,« format »:« handlebars »,« syntax »:« mustache »,« template »:« Alarme declenchée par : {{global.declencheur}} »,« x »:530,« y »:380,« wires »:[[« 8ace0fdf21a3afed »]]},{« id »:« c6386d67ce559c14 »,« type »:« change »,« z »:« 15745c2870a38df9 »,« name »:« Nom du déclencheur »,« rules »:[{« t »:« set »,« p »:« declencheur »,« pt »:« global »,« to »:« Capteur test »,« tot »:« str »}],« action »:"",« property »:"",« from »:"",« to »:"",« reg »:false,« x »:240,« y »:200,« wires »:[[« e5e6ed89edcc79f7 »]]},{« id »:« 22d25057cbc5b096 »,« type »:« debug »,« z »:« 15745c2870a38df9 »,« name »:« debug 2 »,« active »:true,« tosidebar »:true,« console »:false,« tostatus »:false,« complete »:« payload »,« targetType »:« msg »,« statusVal »:"",« statusType »:« auto »,« x »:760,« y »:540,« wires »:[]},{« id »:« 5d89433.7a064bc »,« type »:« server »,« name »:« Home Assistant »,« version »:2,« addon »:true,« rejectUnauthorizedCerts »:true,« ha_boolean »:« y|yes|true|on|home|open »,« connectionDelay »:true,« cacheJson »:true,« heartbeat »:false,« heartbeatInterval »:30}] 

moi non plus je n’ai pas réussis :slight_smile:

EDIT : après 6 essais… si si, ne vous moquez pas , j’ai réussis :slight_smile:

j’ai encore fait plus simple :

1

dans le timestamp, j’ai ajouté un msg perso

2

dans les messages, que se soit via telegram ou notify, j’ai ajouté l’envoi de ce msg perso

dans mes debug, j’affiche le msg

4

je le reçois bien en debug

5

mais sur telegram ou notify, je ne reçois rien… je n’ai que le début du message et pas la valeur du msg

6

en regardant sur le forum ou sur le net, je fais exactement comme tout le monde… une idée pourquoi chez moi cela ne fonctionne pas ?

le flow :

[{"id":"2de1e70c8a4936e5","type":"tab","label":"Flow 1","disabled":false,"info":"","env":[]},{"id":"76547e294f7689e0","type":"inject","z":"2de1e70c8a4936e5","name":"","props":[{"p":"payload"},{"p":"capteurname","v":"ceci est un test","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":160,"y":180,"wires":[["5244d6f570f0a609","1261ae99b3e90630"]]},{"id":"5244d6f570f0a609","type":"api-call-service","z":"2de1e70c8a4936e5","name":"Envoi Telegram","server":"5d89433.7a064bc","version":5,"debugenabled":false,"domain":"notify","service":"telegram","areaId":[],"deviceId":[],"entityId":[],"data":"{\t    \"message\": \"via telegram : {{capteurname}}\"\t}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":400,"y":160,"wires":[["81b9bff035c52658"]]},{"id":"1261ae99b3e90630","type":"api-call-service","z":"2de1e70c8a4936e5","name":"Envoi Notify","server":"5d89433.7a064bc","version":5,"debugenabled":false,"domain":"notify","service":"mobile_app_iphonellf","areaId":[],"deviceId":[],"entityId":[],"data":"{\t    \"message\": \"via notify : {{capteurname}}\"\t}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":390,"y":220,"wires":[["3d74ac7bf4f1dfc9"]]},{"id":"81b9bff035c52658","type":"debug","z":"2de1e70c8a4936e5","name":"debug 4","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"capteurname","targetType":"msg","statusVal":"","statusType":"auto","x":560,"y":120,"wires":[]},{"id":"3d74ac7bf4f1dfc9","type":"debug","z":"2de1e70c8a4936e5","name":"debug 5","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"capteurname","targetType":"msg","statusVal":"","statusType":"auto","x":560,"y":280,"wires":[]},{"id":"5d89433.7a064bc","type":"server","name":"Home Assistant","version":2,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":"30"}]

Merci pour votre aide.

Oui, je pense.
Dans le formatage du message perso tu as mis en format (espèce de) S: (soit du jsonata) et dans le texte, tu utilises la mauvaise syntaxe (mustache).

Avec "via telegram:" & capteurname ça devrait le faire.

1 « J'aime »

Merci Golfvert, trop fort.
cela fonctionne bien.