Entity state changed by

Hi, i want to create automation based on how entity state was changed
Currently i can check if it was changed by user on dashboard or by automation using

trigger.to_state.context.user_id != none

im using this on thermostat, but there are also buttons on thermostat, and when i e.g. change heating to off on this thermostat, context.user_id is also none. Is there any possibility to check if state change was by automation or by button on thermostat (integration)?