Use "triggered by" as a condition?

I am trying to edit a light automation to stop turning on if I have “manually” turned it off via Google Assistant or any other specified trigger such as a user. Ideally I could allow the automation to run “IF NOT light turned off by Google Assistant in the last 1h” or something similar.

The screenshot (see highlighted) clearly shows me that this is being recorder, but how can I add it to a list of conditions?

To determine what triggered an automation, you have to check the context object.

Here’s an example:

The table explaining context object’s three properties is here:

Thanks for the response!

Oof this really the best we are working with? Its so non specific and lacks in so many ways if I understand it correctly. Looks like I essentially have 3 trigger options to work with?

Seems like an easy thing to support that mannny people would use.

Perhaps I misunderstood your initial request. What I suggested tells you what triggered the automation. Is that not what you requested?

Judging by your response you probably nailed it what I was looking for. I’ve actually come across your post before and had a hard time wrapping my head around it so it seems its just my ignorance :slight_smile:

For some reason the way I have interpreted it is that you can only retrieve values that tell you if it was one of three things; Physical, Automation, or UI and not any more granular than that. So if it does cover what I am looking for where I can specify granular triggers like specific users or my google assistant then amazing.

I’ll spend some more time digging into your method and hopefully get a grasp on it. Thanks!

I know it can be used to determine the specific Home Assistant user account but I don’t know about Google Assistant.

Circling back to this I found an alternative that is working great.

Within google home you can set automations. I set automations there so that when certain phrases such as “turn off bedroom lights” (and other similar variations of the phrase) are said, it is automated not to turn off the light but to turn off a bedroom override switch I made in HA ( more on that in a sec). The automation turns on the override switch via google home, then also sends the command to HA to turn off the light.

Override switch
The idea of my override switch is to allow me to add it as a condition to my main automation. Ex. “If bedroom override switch is on, do not trigger the bedroom light automation to turn on of off” essentially turning off the automation while the switch is active. First you need to set uo a helper

The Override Helper
Create a Helper, it needs to be a toggle. Name it “<room_name> override”

Override switch automation
Then create an automation that doesn’t allow the override switch to stay on forever, it will trigger the switch off after X time to resume automations that have the override toggle as part of their condition list.

The override switch automation, in words:
It essentially reads “If override switch turns on, delay for 4 hours, then call service: turn off override switch”

The override switch automation in code:

alias: "Helper: Living Room Light Override"
description: ""
  - platform: state
      - input_boolean.living_room_light_override
    to: "on"
condition: []
  - delay:
      hours: 4
      minutes: 0
      seconds: 0
      milliseconds: 0
  - service: input_boolean.turn_off
    data: {}
      entity_id: input_boolean.living_room_light_override
mode: single

Utilizing the override toggle in the main light automation
Add your override switch to the list of conditions within your light automation. If override switch is on, the automation does not match the required conditions to run. Just make sure you dont put it within an and statement otherwise the override toggle doesnt have the ability to shit everything down regardless of other condtions.

NOTE: Ensure you expose your override switche(s) to Google Assistant. Then Ensure you see them within Google Home app

Google Home Config
Within the google home app, navigate to Automations > Add > next option is up to you

  1. Name it
  2. Add Starter: Select “When I say to Google Assistant”. Be sure to add variations all to this one starter. If there is only one light, no need for the plural variation.
  3. Add Action: “Adjust Home Devices” > Select target override switch > Select turn on (remember HA the automation will turn it off automatically).

Google Home similar variation phrases
These are just variotions I came up with so that no matter how you say it, its still valid as long as its said on of these 8 ways.
turn <on/off> <room_name> light
turn <on/off> <room_name> lights
turn <on/off> the <room_name> light
turn <on/off> the <room_name> lights
turn the <room_name> light <on/off>
turn the <room_name> lights <on/off>
turn <room_name> light <on/off>
turn <room_name> lights <on/off>

Hope this helps someone in the future!