Automation for temperature value change and some more conditions

Hi all,
I’m trying to do the following automation handling activation of main A/C in the house both outside HA (with a dedicated IR remote ) and within HA.
so the automation should work with deviation in temperature with a zwave sensor that I have and should do like this:

  1. if the temperature changed by 2 degrees Celcius in the last half hour
    and
  2. the temperature is above or below a certain value
    and
  3. the switch didn’t change the value in last hour
    then
  4. change the state of the switch from off to on, or from on to off depends on the state it is currently without actually activating it off or on ( is this even possible??)

I think this might be some of your interest.

Thanks for that.
i now have smartir installed.
not sure i understand how to incorporate it into automation.
lets say i want to turn it on based on temp outside.
if the temp is between 25-27 Celsius, then turn on A/C on cool mode with 24 degrees and fan mode auto.
can someone give an example of what services do i call in this kind of automation?

I think that there might a mode to use the HA itself, if it is installed on a SBC (like RPi, NUC etc, etc) just get a IR LED plugged to the GPIO.
Otherwise there might another small MCU (Arduino or ESP) that will interface to send and receive the IR commands to AC, then inform HA about the situation.
The IR reception might necessary if someone thought to use the ordinary remote control to modify the setting. So the system will be aware of these changes.

i have broadlink rm mini to send the IR signals.
this is not the problem.
im trying to figure out the entities i call when turning on A/C on specific temp during automation scenario.