Break/Stop loop with MQTT payload/message

OK... I think I'm getting a bit of a handle on this code, but I also think you are making assumptions that are causing you some confusion. Correct me if any of MY assumptions are wrong.

First...

void loop() {
  client.loop();
}

Will be called over and over again, right? Which means that you will be getting something every time you press a button on your remote, and from the sound of it, more than one code being received is normal operation. So this calls the MQTT broker, and that returns something.

Questions:
It is important that you check for the presence of the string "skulltronics.net/hive/floor/optimus-prime/IR-SonyTV" ?
If not, don't even bother with it... just check for the presence of any payload that you are interested in.
If it is important, ie. if it is something you need to check to determine if there is a new payload, try something like this (assuming that the payload contents you are interested in have a maximum length of 20).

char message[ 21 ]; // assuming all message payloads will be 20 characters or fewer

// MQTT Callback
void callback(char* topic, byte* payload, unsigned int length) {

  // replace your Serial prints here for debugging

  // IR Remote Sony TV
  if (strcmp(topic,"skulltronics.net/hive/floor/optimus-prime/IR-SonyTV")==0) {
    strncpy(message, (char *)payload, 20);
  }
  // Volume Up
  if (strcmp((char*)payload,"volume-ups")==0) {
    Serial.println("up");
    delay(50);
  }
  // Stop Volume Up
  if (strncmp(message,"volume-stop")==0) {
    // do whatever you need to stop the volume-up
    Serial.println("stop volume-up");
    message[0] = '\0';
  }
} // End MQTT Callback

Now, remembering that client.loop() is called VERY often, you will see that callback will be called often as well.

With this code, you should keep entering the if statement for volume-up until you receive a colume-stop. At that point, you NULL terminate message[], and stop entering either if block.

Now if you want to still set a maximum number of volume-up events, you could use a static variable in callback() and limit the number by incrementing it and making the value of it part of the volume-up if conditions.

What do you think?