Trigger Variables are Giving Me a Headache

I’m taking on a pretty hefty challenge to add doorbell support to the Frigate notification blueprint, but am getting hung up on getting a variable to pass through for my automation. So I tried creating a simple automation example and this isn’t working either. Can someone take a look at this and help me figure out why the trigger variable isn’t working?

Blueprint

[trigger_variables:
  test_trigger_variable:
    - binary_sensor.office_entryway_door_sensor
variables:
  global_variable:
    - binary_sensor.office_entryway_door_sensor
  nested_variable:
    - binary_sensor.office_entryway_door_sensor
triggers:
  - trigger: state
    entity_id: input_boolean.trigger_1
  - trigger: state
    entity_id:
      "[object Object]": null
actions:
  - action: persistent_notification.create
    metadata: {}
    data:
      message: >-
        "Global Variable: {{global_variable}}" "Nested Variable:
        {{nested_variable}}"
alias: Blueprint Test
description: ""](https://my.home-assistant.io/redirect/blueprint_import/?blueprint_url=https%3A%2F%2Fraw.githubusercontent.com%2Fbroyuken%2Fhomeassistant-automations-and-scripts%2Frefs%2Fheads%2Fmain%2FBlueprints%2FAutomation%2Fblueprint_test.yaml)

Not sure about your variables, but there is clearly something wrong with this state trigger.

Sorry, that was after I was messing with it a bit, didn’t realized I copied the broken part in there. I fixed the original post and put a link to the test blueprint I’m trying to build.

The cause of the "[object Object]": null is that you tried to use a template in a State trigger, which is not supported. You can use inputs there, but not templates.

There is also a significant issue in the action… you are using both a multi-line quote indicator and double-quote marks. This keeps the the variables global_variable and nested_variable from being rendered. It should be:

actions:
  - action: persistent_notification.create
    metadata: {}
    data:
      message: >-
        Global Variable: {{global_variable}}
        Nested Variable: {{nested_variable}}

According to the docs you can. These are not templates, they are variables. Which is why I can’t figure out why this doesn’t work.

And this also works in the blueprint I am basing my work off of.

The way the values of YAML variables are rendered in HA is through templates. Anything in HA that includes double-curly bracket delimiters, {{ }}, is a Jinja template.

You can use templates in triggers that support templates and only where they are supported. State triggers only support templates in the for configuration variable.

Community Cookbook - What the Heck is a Template…? - Where Should I Use Templates?

That blueprint does not use templates in State triggers… its trigger section is composed exclusively of MQTT and Event triggers.

Ok thank you, that helps clarify things a little. So it seems I have 2 options here.

  1. Use an input instead of a variable/template
  2. Change the trigger from a state trigger to a template trigger that look
    {{ is_state(‘device_tracker.paulus’, ‘home’) }}

update, got it working with the template trigger, thank you so much!!!

1 Like