I want to use context information as explained here
How to use context - Community Guides
and here
Background: I want to find out who switched on or off an entity, e.g. light or thermostat etc.
In the current case I use the scheduler extension to switch thermostats on and off and set the temperature. But of course, sometimes a person changes a thermostat physically at the device itself. In that case I want to pause the scheduled actions for a while and then resume later.
However the scheduler extension does not provide a context_id which is why I submitted a feature request at github: scheduler-component
Further testing with a helper schedule and also a calendar entry showed, that it is important how you retrieve the context information while keeping in mind that for some automation triggers there is no identifiable parent as listed here
Here is an example that shows how you get a parent_id and how you don’t with the same calendar event - even though calendar trigger has a green check mark (maybe I am doing it wrong)
This is automation code resulting in a valid trigger.to_state.context.parent_id
alias: TL1 press button by calendar state trigger
description: ""
triggers:
- trigger: state
entity_id:
- calendar.calendar_push_button
from:
- "off"
to:
- "on"
enabled: true
conditions: []
actions:
- action: input_button.press
metadata: {}
data: {}
target:
entity_id: input_button.tl1
mode: single
in traces clicking on the action button press and reading changed variables
context:
id: 01K9H5C6J59KJ6RDZSM53CEN89
parent_id: 01K9H5C6J5JYAW6T60TKGYGAVH
user_id: null
however this automation code results in null as parent_id
alias: TL1 push button by calendar trigger
description: ""
triggers:
- trigger: calendar
entity_id: calendar.calendar_push_button
event: start
offset: "0:0:0"
enabled: true
conditions: []
actions:
- action: input_button.press
metadata: {}
data: {}
target:
entity_id: input_button.tl1
mode: single
context:
id: 01K9H5C581HGJ21PH3N62ZTFTK
parent_id: null
user_id: null
so the state trigger works and the calendar trigger does not.
Question 1: is that a bug? Or am I doing something wrong with the calendar trigger?
Question 2: can I get the context information directly from the entity as well? The logs of the entity show the context information too somehow:
the green dot entry shows the
parent_id as state of the calendar calendar push buttonthe blue dot entry is missing the information that the trigger was caused by the calendar
and here the log shows with purple dot my user when I click the button on the dashboard:
and pink is when the scheduler extension pushes the button with no
parent_id resulting in no information where the push came from - sadly 
