Need Help with Nodered & Adding Function

so i trying to make a keep live poll for another program i use
so it will send a MQTT yes every 10 min and when it sends it will then convert it to HA will see it as Connected… but if say after 50 min of not getting a Yes it will report its Offline… now the problem i having is at the point of the function the Trigger supposed to push 1 which it does but the function supposed to keep Adding it but its only receiving 1… its not +1 ive tried a few different ways… i tried my own i tried googling… so im stuck… here is the code

[{"id":"2eb58b0cb0c5ddd3","type":"trigger","z":"feb1b184abb55693","name":"Poll Every 10 min","op1":"1","op2":"0","op1type":"num","op2type":"str","duration":"-3","extend":false,"overrideDelay":false,"units":"s","reset":"stop","bytopic":"all","topic":"topic","outputs":1,"x":530,"y":1380,"wires":[["4371eea2659fb928"]]},{"id":"84a3c30b1ee4f3eb","type":"mqtt in","z":"feb1b184abb55693","name":"MQTT \"callerid/alive\"","topic":"alive","qos":"2","datatype":"auto-detect","broker":"12cbc2886c19b10a","nl":false,"rap":true,"rh":0,"inputs":0,"x":90,"y":1380,"wires":[["12fd9632d5a356c7"]]},{"id":"12fd9632d5a356c7","type":"ha-sensor","z":"feb1b184abb55693","name":"Callattendant Still Alive ","entityConfig":"645169a671b306dd","version":0,"state":"payload","stateType":"msg","attributes":[],"inputOverride":"allow","outputProperties":[],"x":300,"y":1380,"wires":[["f73dda6eb261e5f9","2eb58b0cb0c5ddd3"]]},{"id":"f73dda6eb261e5f9","type":"switch","z":"feb1b184abb55693","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"Yes","vt":"str"},{"t":"neq","v":"Yes","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":450,"y":1300,"wires":[["3adcaa432fd5e7e1"],[]]},{"id":"3adcaa432fd5e7e1","type":"change","z":"feb1b184abb55693","name":"Set To 0 If MQTT Msg Is Yes","rules":[{"t":"set","p":"payload","pt":"msg","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":1300,"wires":[["4371eea2659fb928"]]},{"id":"4371eea2659fb928","type":"function","z":"feb1b184abb55693","name":"function 4","func":"var value = value + msg.payload\n//value = value +1;\nmsg.payload = msg.payload + 1;\n\nmsg.value = value;\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":720,"y":1380,"wires":[["028ff549a780bfc7","4e7eb63c8f455a47"]]},{"id":"4e7eb63c8f455a47","type":"debug","z":"feb1b184abb55693","name":"debug 25","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":940,"y":1340,"wires":[]},{"id":"186cd3be6bfce81c","type":"inject","z":"feb1b184abb55693","name":"Yes","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"Yes","payloadType":"str","x":90,"y":1480,"wires":[["12fd9632d5a356c7"]]},{"id":"028ff549a780bfc7","type":"switch","z":"feb1b184abb55693","name":"","property":"value","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"num"},{"t":"gt","v":"5","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":750,"y":1440,"wires":[["4b7e7b663e31bb09","4e7eb63c8f455a47"],["fe8e06f7c086e424","4e7eb63c8f455a47"]]},{"id":"4b7e7b663e31bb09","type":"change","z":"feb1b184abb55693","name":"Set Connected","rules":[{"t":"set","p":"payload","pt":"msg","to":"Connected","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":940,"y":1420,"wires":[["eaf9054c35ddae85"]]},{"id":"fe8e06f7c086e424","type":"change","z":"feb1b184abb55693","name":"Set Offline","rules":[{"t":"set","p":"payload","pt":"msg","to":"Offline","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":930,"y":1460,"wires":[["eaf9054c35ddae85"]]},{"id":"eaf9054c35ddae85","type":"ha-sensor","z":"feb1b184abb55693","name":"Callattendant Status","entityConfig":"645169a671b306dd","version":0,"state":"payload","stateType":"msg","attributes":[],"inputOverride":"allow","outputProperties":[],"x":1160,"y":1420,"wires":[["4e7eb63c8f455a47"]]},{"id":"7dac54c00df1c86c","type":"inject","z":"feb1b184abb55693","name":"No","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"No","payloadType":"str","x":90,"y":1540,"wires":[["12fd9632d5a356c7"]]},{"id":"12cbc2886c19b10a","type":"mqtt-broker","name":"home assistant server","broker":"192.168.0.12","port":"1883","clientid":"","autoConnect":true,"usetls":false,"protocolVersion":"3","keepalive":"60","cleansession":true,"autoUnsubscribe":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"userProps":"","sessionExpiry":""},{"id":"645169a671b306dd","type":"ha-entity-config","server":"915baa48.9b1898","deviceConfig":"","name":"Callattendant Status","version":"6","entityType":"sensor","haConfig":[{"property":"name","value":"Callattendant Status"},{"property":"icon","value":""},{"property":"entity_picture","value":""},{"property":"entity_category","value":""},{"property":"device_class","value":""},{"property":"unit_of_measurement","value":""},{"property":"state_class","value":""}],"resend":false,"debugEnabled":false},{"id":"915baa48.9b1898","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}]

i tried changing the payloads… to msg.value on the trigger node and function but i get nan… as i figured maybe the payload is conflicting here is that code

[{"id":"2eb58b0cb0c5ddd3","type":"trigger","z":"feb1b184abb55693","name":"Poll Every 10 min","op1":"1","op2":"0","op1type":"num","op2type":"str","duration":"-3","extend":false,"overrideDelay":false,"units":"s","reset":"stop","bytopic":"all","topic":"topic","outputs":1,"x":530,"y":1380,"wires":[["4371eea2659fb928"]]},{"id":"84a3c30b1ee4f3eb","type":"mqtt in","z":"feb1b184abb55693","name":"MQTT \"callerid/alive\"","topic":"alive","qos":"2","datatype":"auto-detect","broker":"12cbc2886c19b10a","nl":false,"rap":true,"rh":0,"inputs":0,"x":90,"y":1380,"wires":[["12fd9632d5a356c7"]]},{"id":"12fd9632d5a356c7","type":"ha-sensor","z":"feb1b184abb55693","name":"Callattendant Still Alive ","entityConfig":"645169a671b306dd","version":0,"state":"payload","stateType":"msg","attributes":[],"inputOverride":"allow","outputProperties":[],"x":300,"y":1380,"wires":[["f73dda6eb261e5f9","2eb58b0cb0c5ddd3"]]},{"id":"f73dda6eb261e5f9","type":"switch","z":"feb1b184abb55693","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"Yes","vt":"str"},{"t":"neq","v":"Yes","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":450,"y":1300,"wires":[["3adcaa432fd5e7e1"],[]]},{"id":"3adcaa432fd5e7e1","type":"change","z":"feb1b184abb55693","name":"Set To 0 If MQTT Msg Is Yes","rules":[{"t":"set","p":"payload","pt":"msg","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":1300,"wires":[["4371eea2659fb928"]]},{"id":"4371eea2659fb928","type":"function","z":"feb1b184abb55693","name":"function 4","func":"var value = value + msg.payload\n//value = value +1;\nmsg.payload = msg.payload + 1;\n\nmsg.value = value;\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":720,"y":1380,"wires":[["028ff549a780bfc7","4e7eb63c8f455a47"]]},{"id":"4e7eb63c8f455a47","type":"debug","z":"feb1b184abb55693","name":"debug 25","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":940,"y":1340,"wires":[]},{"id":"186cd3be6bfce81c","type":"inject","z":"feb1b184abb55693","name":"Yes","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"Yes","payloadType":"str","x":90,"y":1480,"wires":[["12fd9632d5a356c7"]]},{"id":"028ff549a780bfc7","type":"switch","z":"feb1b184abb55693","name":"","property":"value","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"num"},{"t":"gt","v":"5","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":750,"y":1440,"wires":[["4b7e7b663e31bb09","4e7eb63c8f455a47"],["fe8e06f7c086e424","4e7eb63c8f455a47"]]},{"id":"4b7e7b663e31bb09","type":"change","z":"feb1b184abb55693","name":"Set Connected","rules":[{"t":"set","p":"payload","pt":"msg","to":"Connected","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":940,"y":1420,"wires":[["eaf9054c35ddae85"]]},{"id":"fe8e06f7c086e424","type":"change","z":"feb1b184abb55693","name":"Set Offline","rules":[{"t":"set","p":"payload","pt":"msg","to":"Offline","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":930,"y":1460,"wires":[["eaf9054c35ddae85"]]},{"id":"eaf9054c35ddae85","type":"ha-sensor","z":"feb1b184abb55693","name":"Callattendant Status","entityConfig":"645169a671b306dd","version":0,"state":"payload","stateType":"msg","attributes":[],"inputOverride":"allow","outputProperties":[],"x":1160,"y":1420,"wires":[["4e7eb63c8f455a47"]]},{"id":"7dac54c00df1c86c","type":"inject","z":"feb1b184abb55693","name":"No","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"No","payloadType":"str","x":90,"y":1540,"wires":[["12fd9632d5a356c7"]]},{"id":"12cbc2886c19b10a","type":"mqtt-broker","name":"home assistant server","broker":"192.168.0.12","port":"1883","clientid":"","autoConnect":true,"usetls":false,"protocolVersion":"3","keepalive":"60","cleansession":true,"autoUnsubscribe":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"userProps":"","sessionExpiry":""},{"id":"645169a671b306dd","type":"ha-entity-config","server":"915baa48.9b1898","deviceConfig":"","name":"Callattendant Status","version":"6","entityType":"sensor","haConfig":[{"property":"name","value":"Callattendant Status"},{"property":"icon","value":""},{"property":"entity_picture","value":""},{"property":"entity_category","value":""},{"property":"device_class","value":""},{"property":"unit_of_measurement","value":""},{"property":"state_class","value":""}],"resend":false,"debugEnabled":false},{"id":"915baa48.9b1898","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}]

This is how I handle checking to see if an mqtt entity is online and sending it to a sensor. I listen for any reply from the machine and use that with a trigger node. If nothing in 10 minutes it sets the sensor to offline. In the sensor config use connectivity as it’s device class for it to report online/offline

[{"id":"7fa0552efd563695","type":"mqtt in","z":"7d105d71.cc18e4","name":"blue/rpz/#","topic":"blue/rpz/#","qos":"0","datatype":"auto","broker":"601bef1.d5b981","nl":false,"rap":false,"inputs":0,"x":120,"y":2220,"wires":[["12e7e9333840f3a1","01c5c43be898200b"]]},{"id":"12e7e9333840f3a1","type":"change","z":"7d105d71.cc18e4","name":"set to on","rules":[{"t":"set","p":"payload","pt":"msg","to":"on","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":320,"y":2220,"wires":[["bf1b8671509a362c","e89be333519eeb2f","348ad26375d4af14"]]},{"id":"348ad26375d4af14","type":"trigger","z":"7d105d71.cc18e4","name":"base online sensor","op1":"true","op2":"false","op1type":"bool","op2type":"bool","duration":"10","extend":true,"overrideDelay":false,"units":"min","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":570,"y":2220,"wires":[["02c9bb9a71255093"]]},{"id":"02c9bb9a71255093","type":"ha-binary-sensor","z":"7d105d71.cc18e4","name":"base_pi","entityConfig":"5a0ec8b9225f4d49","version":0,"state":"payload","stateType":"msg","attributes":[],"inputOverride":"allow","outputProperties":[],"x":920,"y":2220,"wires":[[]],"server":""},{"id":"601bef1.d5b981","type":"mqtt-broker","name":"Mosquitto","broker":"127.0.0.1","port":"1883","clientid":"","autoConnect":true,"usetls":false,"protocolVersion":4,"keepalive":"60","cleansession":true,"autoUnsubscribe":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"5a0ec8b9225f4d49","type":"ha-entity-config","server":"","deviceConfig":"","name":"binary sensor config for base_pi","version":6,"entityType":"binary_sensor","haConfig":[{"property":"name","value":"base_pi"},{"property":"device_class","value":"connectivity"},{"property":"icon","value":""},{"property":"unit_of_measurement","value":""},{"property":"state_class","value":""},{"property":"last_reset","value":""}],"resend":true}]

edit for your original question

The value is likely a string for jsonata use $number(value) or JS Number(value) to convert

ok your code works…better then what i was doing… and shorter… now i just trying to alter the program i using the caller id. i googled… about the sched python to run a routine say every 10 min so i can mqtt to home assistant but it doesnt seem to work doesnt wanna run yet it compiles so that sucking at the moment lol not good enough at python or understanding where to put the code as i put it at the top