         if ( a == 0 && tvPowerStatus == 0) {
           irSendTv(1);
           tv_off_Mills = millis();
+          tv_on_Mills = millis();
           timerOnOff = 0;
           r = !r;
         }
     } else {
         if ( a == 1 ) {
           irSendTv(0);
+          tv_off_Mills = millis();
           tv_on_Mills = millis();
           timerOnOff = 1;
           r = !r;

        if ( a == 0 ) {
          irSendTv(1);
          tv_off_Mills = millis();
          timerOnOff = 0;
          r = !r;
        }      

    if ( o_pwrSrc == 0 ) {
        if ( a == 1 && tvPowerStatus == 1) {
          irSendTv(0);
          tv_off_Mills = millis();
          tv_on_Mills = millis();
          timerOnOff = 1;
          r = !r;
