#Can’t use variable, undefined

1 messages · Page 1 of 1 (latest)

willow kettle
#

Hello!
I have a problem using a variable.
I have an automation that sets the variable as the first step with:

Variable:
feuchtigkeit: „{{states(‚sensor.feuchte‘)|float}}

I Never change this variable, it only gets set when the automation is called.
Then after some actions I call a wait for trigger with timeout with a check for this variable:

  • trigger: template
    value_template: >-
    {{states(‚sensor.feuchte‘)|float <= feuchtigkeit | float - 3.0 }}

However I get errors in the log of HA telling me „feuchtigkeit“ is undefined for that trigger step.
Not sure why?
Shouldn’t be a scope issue right? Right??

north birch
#

Hi @willow kettle,
Variables are not rendered until after the trigger.

#

That means they are empty until after the trigger happens, so they cannot be used as part of the trigger.

#

You need to use a trigger_variable if you want to put it into the trigger...

prisma grotto
#

If you can share your automation it would be easier to help.

If you are only using that variable in a wait_for_trigger section, and not in the automation’s trigger section, then it should work.

misty pastureBOT
#

Please use a code share site to share code or logs, for example:

Please don't use Pastebin, since it can randomly add spaces to the main view. Please also don't share text as images since it makes it harder for people to help you. Remember that others may have colour blindness, impaired vision, etc.

worn seal
#

You're using wrong quotes everywhere

#

"proper quotes"

#

'proper quotes'