   #endif
 
 
-  //Light 1 ACTIONS
+  //Light 1 ACTIONS **************************************************
   if (strncmp(topic,"home/light/1/action/", 20)==0) {
 
     byte lightId, lightCmd, lightMax, lightVal;

      return;
    }

    //Parsed JSON OK!
    #if DEBUG                
      Serial << "X10 Action: " << hashTable.getLong("H") << " " << hashTable.getLong("U") << " " << hashTable.getLong("A") << " " << hashTable.getLong("T") << endl;
    #endif

    //Execute X10 Command
    myHouse.write(hashTable.getLong("H"), hashTable.getLong("U"), hashTable.getLong("T"));
    myHouse.write(hashTable.getLong("H"), hashTable.getLong("A"), hashTable.getLong("T"));
     
    //Acknowledge X10 status by publishing the same message 
    Publish(STR_X10_STATUS, JsonACK, false);
  }

  //315 RF Switch ACTIONS
  if (strncmp(topic,"home/rfswitch/action", 20)==0) {

    //Copy payload first    
    char JsonACK[strlen(cpayload)+1];    
    strcpy (JsonACK,cpayload);

    //Parse JSON payload -- Format {"D":123456,"B":24}
    JsonHashTable hashTable = parser.parseHashTable(cpayload);

    //Failed (bigger then buffer?)
    if (!hashTable.success()) {
      #if DEBUG                
        Serial << "JSON Parser failed!" << endl;
      #endif
      return;
    }

    //Send RFSwitch command
    mySwitch.send(hashTable.getLong("D"), hashTable.getLong("B"));
    //mySwitch.send(1393741, 24);
    // mySwitch.send(1393777, 24);

    //Parsed JSON OK!
    #if DEBUG                

    }
  }


  //X10 ACTIONS ******************************************************
  if (strncmp(topic,"home/x10/action/", 16)==0) {

    //Split topic elements
    strcpy(buffer, topic);
    fillTopicElements();

    //Loop over all HOUSES
    for (uint8_t h = 0; h < 17; h++) {

      //Copy house codes from PROGMEM
      char b_topic_house[2] = {pgm_read_byte(topic_house + h)};
      byte b_constant_house = pgm_read_byte_near(constant_house + h);

      //Check house code match
      if (strcmp(topicElements[X10_HOUSE_N], b_topic_house)==0) {

        //Loop over all UNITS
        for (int u = 0; u < 16; u++) {

          //Create a UNIT_XX string based on the loop number
          char b_topic_unit[8] = "UNIT_";
          char b_topic_unit_numb[3];
          itoa(u + 1, b_topic_unit_numb, 10);
          strncat (b_topic_unit, b_topic_unit_numb, 2);

          //Copy unit codes from PROGMEM
          byte b_constant_unit = pgm_read_byte_near(constant_unit + u);
          
          //Check unit code match
          if (strcmp(topicElements[X10_UNIT_N], b_topic_unit)==0) {            

            //Loop over all HOUSES
            for (uint8_t c = 0; c < 16; c++) {

              //Copy command codes from PROGMEM              
              strcpy_P(buffer, (char*)pgm_read_word(&(topic_command[c])));    
              byte b_constant_command = pgm_read_byte_near(constant_command + c);              

              //Check command for match
              if (strcmp(topicElements[X10_CMD_N], buffer)==0) {          

                //Payload is the number of tries
                int bvalue = atoi(cpayload);     

                #if DEBUG                
                  Serial << "X10 Action: " << b_topic_house << ":" << b_constant_house << "/" << b_topic_unit << ":" << b_constant_unit << "/" << buffer << ":" << b_constant_command << " -- Try: " << bvalue << endl;
                #endif               

                //Execute X10 Command
                myHouse.write(b_constant_house, b_constant_unit, bvalue);
                myHouse.write(b_constant_house, b_constant_command, bvalue);
                
                //Acknowledge X10 status by publishing the received topic in a status message
                char X10ACK[26]; 
                sprintf(X10ACK, "%s", topic + 16);
                Publish(STR_X10_STATUS, X10ACK, false);

                //Stop checking
                return;
              }
            }
          }
        }       
      }
    }
  }


  //315 RF Switch ACTIONS ********************************************
  if (strncmp(topic,"home/rfswitch/action", 20)==0) {

    //Copy payload first    
    char JsonACK[strlen(cpayload)+1];    
    strcpy (JsonACK,cpayload);

    //Parse JSON payload -- Format {"D":123456,"B":24}
    JsonHashTable hashTable = parser.parseHashTable(cpayload);

    //Failed (bigger then buffer?)
