Hi @Sean-McG
You can check if it exists using something like:
if (msg.payload.hasOwnProperty("S29cmnd_D15")) {
   msg.payload = msg.payload.S29cmnd_D15.STATE;
   return msg;
} else {
  // do something else because it does not exist
}
Note how this code updates and returns the existing msg object, rather than create a new message object - that's generally the best practise to follow.