Arduino thermostat safety

PeterH:
Seems as if the connection between your wireless sensor and the Arduino may not be very reliable. In order to understand why that is you'd need to know what the communication mechanism was, whether it was suitable for the way you're trying to use it and whether it was being used correctly.

The wireless sensor is fine. It's a purchased one. Most of the time the Arduino receives the temperature, just sometimes it appearantly doesn't.

Now that I think about it, it might be an error in the code. Could you check it for me?

unsigned long maxMillis = 1200000; // if the last temperature measurement was over 20 minutes (in milliseconds) ago, consider it unreliable and switch to the second thermostat.
unsigned long lastMillis = 4293767291; // millis() at the time of the last temperature measurement.

void thermostat(){
    if((millis() - lastMillis) > maxMillis){
      therm_override = false; //Consider the temperature measurement inaccurate, and fall back to following the other.
    }else{
      if(targetTemp - lastTemp >= tempOffset){
        digitalWrite(outputPin, heatOn);
        heating = true;
      }else{
        digitalWrite(outputPin, !heatOn);
        heating = false;
      }
    }
}

lastmillis is updated to millis() when the Arduino receives a temperature.