Automation trigger, only if last change is not triggered by the Automation

Hi,

I have a automation for our air condition. It turn off and on, if some conditions are true (eg outdoor temp, indoor temp, pv production …

But I want to add a condition, who does not turn off the climate by automation, if last action is NOT from the automation. Is there a way to check the last change from logbook.