import RPi.GPIO as g
import time
g.setmode(g.BOARD)
g.setup(33, g.OUT)
while True:
  tempfile = open("/sys/devices/w1_bus_master1/28-00152c2631ee/w1_slave")
  thetext = tempfile.read()
  tempfile.close()
  tempdata = thetext.split("\n") [1].split(" ")[9]
  temperature = float(tempdata[2:])
  finaltemp = temperature / 1000
  time.sleep(1)
  if finaltemp > 22:
    g.output(33,g.LOW)
    time.sleep(0.3)
    g.output(33,g.HIGH)
  else:
    g.output(33,g.LOW)
    time.sleep(0.3)
    g.output(33,g.HIGH)
I have searched numerous sites including this one, but never found my solution.
As you can see, the code currently grabs the temperature from the system file and stores the temperature in the variable "finaltemp". 
The way I have my hardware setup is so that my relay switch is connected to the push button on AC remote control, which is why I have my GPIO set up to turn on and off very quickly (0.3 seconds), to mimic the push of the button on the remote. 
My goal is to 'blink' (push the button) the GPIO only once(!) when the temperature changes according to the condition.
For example:
The temperature in room is 20 and the AC is off at the moment. Therefore, the temperature is slowly rising, and right when the temperature goes above 22, I want to run the 3 lines of code to run. What is happening however, is that it keeps checking it every time. Since the condition meets everytime the while loop starts over, it keeps running the code over and over, so essentially what's happening is that my AC keeps turning on and off and on and off.
breakkeyword.