Thank you very much for taking the time to look at my code. However the issue does not seem to lie within the indentation. Your light example automation works well too by the way.
Perhaps I am missing something else?
I am using fritz.device tracker to scan my network, defined here https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/components/fritz/device_tracker.py . This method works well for presence detection.
I would assume that the fritz component also somehow triggers the device_tracker.see service?
Unfortunately, I don’t use any device_trackers so I’m not very familiar with the details of their operation. It makes sense that the tracker would use call_service. If it is not triggering your automation, maybe there is a remote possibility that the fritz device_tracker is not using this service? I realize this doesn’t sound plausible but you’ve already confirmed it works when you monitor call_service but for the light domain.
If you shutdown Home Assistant, you can use DB Browser to inspect Home Assistant’s database. The events table will contain a record of every call_service and you can confirm if any were logged for the fritz device_tracker (in the event_data field).
Thank you for that hint. Indeed searching the db file gave some insights. Also I dug into the device tracker logic which does imply that the see job is indeed fired.
I am wondering if this may be a bug?
The service is registered multiple times in the database: