Tips on streamlining this function

As they say, be careful what you wish for! :smile:
Thanks for the help :+1:

When you need to do some json mapping you can always consider using a jsonata expression in a change node.

[ [ 
    /* Power */
    { "payload" : payload.power ? 1 : 0,
      "pin"     : 71 },
    /* Filter */
    { "payload" : payload.filter ? 1 : 0,
      "pin"     : 74 },
    /* Heat */ 
     { "payload" : ( payload.heat or payload.heater ) ? 1 : 0,
      "pin"      : 75 },   
    /* Celsius */
    { "payload" : payload.celsius ? 1 : 0,
      "pin"     : 76 },   
    /* Air */
    { "payload" : payload.air? 1 : 0,
      "pin"     : 77 },   
    /* Locked */
    { "payload" : payload.locked ? 1 : 0,
      "pin"     : 79 } 
] ]

You can validate this using:

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.