For the platform Event, state_changed, how to access data in one of the

The following automation blasts out a list of any state change directly to a file:

- alias: Device Offline
  trigger: event
    platform: event
    event_type: state_changed
  action:
    service: notify.state_changed <--- this is a file notification to capture the output.
    data_template:
      message: "{{ trigger.event.data }}"

Here is an example of one of the results:

2018-10-05T06:39:17.546730+00:00 {'entity_id': 'sensor.sn1_connection', 'old_state': <state sensor.sn1_connection=Disconnected; friendly_name=Sensor Node 1, entity_picture=/local/images/icons/nodemcudisconnected.png @ 2018-10-04T22:45:56.331326-07:00>, 'new_state': <state sensor.sn1_connection=Connected; friendly_name=Sensor Node 1, entity_picture=/local/images/icons/nodemcuconnected.png @ 2018-10-04T23:39:17.440310-07:00>}

Question:

How do I tap into the new_state values to return only the state of the sensor.sn1_connection, which would be the value “Connected” ?

My goal was to create an automation that watched the event bus for any device that changed to “Disconnected” regardless of its entity_id, as I’m unable to create a state trigger without an entity.

I figured it out.

"{{ trigger.event.data.new_state.state }}"

… returns the new state of the entity.

Ya best option when trying to find things in the data section of a trigger is to have logger set to ‘info’. Then when events fire, you can see exactly what is in the event data section.

I need help from an expert. I need a condition for an event for an automation.
I have five cameras that I have integrated into Deepstack. The detection works quite well so far. However, if several cameras access the image_processing.scan service at the same time, an error message is displayed. I think I’d have to add a condition in automation to prevent that. The condition should relate to the image_processing.scan service that it is already running. The event is deepstack.object_detected. What could the condition for deepstack.object_detected be?