Would someone have a tip for how to change a msg.payload?
For example the msg.payload going into the function block is Boolean True or False. Can I modify the payload to something different?
var payload = msg.payload
if (payload==True){
    
    // JSON PAYLOAD FOR MOTOR ON
    
    msg.payload = {
    "address": "12345:2",
    "object_type": "analogValue",
    "object_instance": "302",
    "value": "100",
    "priority": "11"
    }
}
if (payload==False){
    // JSON PAYLOAD FOR MOTOR OFF
    
    msg.payload = {
    "address": "12345:2",
    "object_type": "analogValue",
    "object_instance": "302",
    "value": "0",
    "priority": "11"
    }
}
return msg;
Ultimately this needs to be JSON, would I then feed this output into a JSON block? Thanks for any tips
             
            
              
            
           
          
            
            
              True is pyhton
             
            
              1 Like 
            
            
           
          
            
              
                E1cid  
              
                  
                    4 September 2021 19:56
                   
                  3 
               
             
            
              
Yes if you return an object, No if you return a string in json format.
    // string in JSON format PAYLOAD FOR MOTOR ON
    
    msg.payload = `{
    "address": "12345:2",
    "object_type": "analogValue",
    "object_instance": "302",
    "value": "100",
    "priority": "11"
    }`
 
            
              
            
           
          
            
              
                Gunner  
              
                  
                    4 September 2021 21:13
                   
                  4 
               
             
            
              Isn't this topic about the same thing as your previous one?   You started to ask the question there.
  
  
    Can someone give me a tip on how to incorporate using the UI scheduler node to send out different different JSON payloads that get rolled into the body of an HTTP GET requests? 
The equipment that I am scheduling through ui scheduler handles rest API. 
For example when UI scheduler node is True from the schedule or the slider I need this JSON payload to start a motor: 
{
    "address": "12345:2",
    "object_type": "analogValue",
    "object_instance": "302",
    "value": "100",
    "priority": …
   
 
             
            
              
            
           
          
            
            
              Yes, sorry newbie here. Not sure how ask good questions 
             
            
              
            
           
          
            
            
              thats make sense! Thanks for the Python insight I have learned that first now picking up javascript
             
            
              
            
           
          
            
              
                system  
              
                  
                    4 November 2021 12:26
                   
                  7 
               
             
            
              This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.