Automation template condition trouble

Hi there!

I have a Unifi camera that I’m automating to turn on recording overnight. I’m trying to set up a second automation that when I manually turn on recording myself, it will turn off after 2.5 hours (trying to capture baby nap patterns during the day!).

I’m having trouble with a template condition I found on the forums that would only activate turning it off after 2.5 hours if myself or my wife were the one who manually made the change - not the automation for the overnight.

I switched out ‘is’ for ==, tried using ‘null’ with ==, tried using ‘or’ with my user IDs, no luck. Each time (whether manually or via automation), it will kick it back to ‘no recording’.

I’m currently using 5 seconds to test, here’s the code.

alias: "* Nursery Nap Auto-Disable Record"
description: ""
trigger:
  - platform: state
    entity_id:
      - select.g3_instant_recording_mode_2
    to: Always
    id: nurseryrecordon
condition:
  - condition: not
    conditions:
      - condition: template
        value_template: |-
          >
                  {{trigger.to_state.context.user_id is none}}
action:
  - delay:
      hours: 0
      minutes: 0
      seconds: 5
      milliseconds: 0
  - service: select.select_option
    data:
      option: Never
    target:
      entity_id: select.g3_instant_recording_mode_2
mode: single

Thanks for your help!

condition:
  - condition: template
    value_template: "{{trigger.to_state.context.user_id is not none}}"

Thanks for this! Gave it a try and it didn’t work. It would still run through the change even if the other automation made the initial change.

Would a look at the trace help?

Did you test the automation by changing the Input Select’s value to ‘Always’?

Yes, I’m testing two ways:

  1. changing it via my dashboard to ‘always’
  2. using the current automation for overnight, changing the start time to current and letting it fire

Refer to the table in this post explaining how to identify the trigger source:

Example employing three conditions to identify a manually operated switch as the trigger source:

1 Like

Excellent, the chart + example did it. I’m all set. Thanks for your time!

1 Like

You’re welcome!

Please consider marking my post above with the Solution tag. It will automatically place a check-mark next to the topic’s title which signals to other users that this topic has been resolved. This helps users find answers to similar questions.

For more information about the Solution tag, refer to guideline 21 in the FAQ.