Work with "Triggered by" in automations

If context.id is not null and context.user_id and context.parent_id are null then it’s (very likely) the physical device that was responsible for the trigger.