Save msg.payload and use it in function node

Hi,

want to frequently check the battery level of my iPad and want to use it in a voice message with the current batter level. I don’t get it to work to embed the the current battery level into the function node. Can someone please help me. I want to use the msg.payload where the debug node is and use the number in the function node within the brackets. (Debug node and the part in the bracket is only to understand where I need it)

[{"id":"51d6cfaaf8b956b7","type":"tab","label":"Flow 1","disabled":false,"info":"","env":[]},{"id":"184dfe86e2552bd9","type":"ttsultimate","z":"51d6cfaaf8b956b7","name":"Sonos Wohnzimmer","voice":"Hans#engineType:standard","ssml":false,"sonosipaddress":"192.168.178.31","sonosvolume":"30","sonoshailing":"Hailing_Schulglocke.mp3","config":"014de07df5901c80","property":"payload","propertyType":{},"rules":[],"playertype":"sonos","speakingrate":"1","speakingpitch":"0","unmuteIfMuted":true,"elevenlabsStability":"0.5","elevenlabsSimilarity_boost":"0.5","x":1060,"y":140,"wires":[[],[]]},{"id":"0a7e27f90281dbe5","type":"function","z":"51d6cfaaf8b956b7","name":"Sprachinhalt","func":"msg.payload = \"Achtung. Der Batteriezustand deines iPads beträgt nur noch {msg.payload debug 3}%.\";\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":850,"y":140,"wires":[["184dfe86e2552bd9"]]},{"id":"55f7aee6748aafc6","type":"inject","z":"51d6cfaaf8b956b7","name":"Alle 30 Minuten","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"1800","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":160,"y":140,"wires":[["5e027089e2297428"]]},{"id":"5e027089e2297428","type":"api-current-state","z":"51d6cfaaf8b956b7","name":"iPad Batterie <= 25%?","server":"d6e1a14d.333e1","version":3,"outputs":2,"halt_if":"25","halt_if_type":"num","halt_if_compare":"lte","entity_id":"sensor.dennis_ipad_air_4_battery_level","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":380,"y":140,"wires":[["d60d70444bf161aa","224fcb5f42dfa4db"],[]]},{"id":"d60d70444bf161aa","type":"api-current-state","z":"51d6cfaaf8b956b7","name":"iPad Batterie > 15%?","server":"d6e1a14d.333e1","version":3,"outputs":2,"halt_if":"15","halt_if_type":"num","halt_if_compare":"gt","entity_id":"sensor.dennis_ipad_air_4_battery_level","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":620,"y":140,"wires":[["0a7e27f90281dbe5"],[]]},{"id":"b312567bafc4a84d","type":"comment","z":"51d6cfaaf8b956b7","name":"Akku zwischen 15% und 25%","info":"","x":180,"y":80,"wires":[]},{"id":"224fcb5f42dfa4db","type":"debug","z":"51d6cfaaf8b956b7","name":"debug 4","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":600,"y":80,"wires":[]},{"id":"014de07df5901c80","type":"ttsultimate-config","name":"AWS Amazon Polly","noderedipaddress":"AUTODISCOVER","noderedport":"1980","purgediratrestart":"leave","ttsservice":"polly","TTSRootFolderPath":""},{"id":"d6e1a14d.333e1","type":"server","name":"Home Assistant","addon":true}]

Thanks.

The entire HA state machine should be available in the Node Red global values, so they can easily be accessed with a global.get call.