Automation: define variable

Hello,

i am relatively new to homeassistant and have got a simple test-automation, but i can’t figure out, why it is not working.

alias: Test Variables
description: ""
trigger: []
condition: []
action:
  - variables:
      testvar: "{{states('input_number.absenktemperatur') | float }}"
  - choose:
      - conditions:
          - condition: time
            after: "08:00:00"
        sequence:
          - variables:
              testvar: "{{states('input_number.komforttemperatur') | float }}"
  - service: notify.notify
    data:
      message: "TestVar: {{testvar}} °C"
mode: single

the initialization is working - so its set up to 16°C
th choose is true and in traces the used path - so it should be set up to 21°C

but as output, I always get this 16°C

This is just the notify automation. Can you post the one which sets the temperature?
And this automation confuses me. I see no trigger? And it sets testvar and then sends the value if its after 8:00. But you could just send the {{states('input_number.absenktemperatur') | float }} in the message.

Look at the documentation:

You can’t change the variable in the choose block. I don’t get it why, but that’s the way it is.

2 Likes

hi Dujith,

this automation was created for test purposes only.
I have deleted everything “useful” and just want to understand how variables are handled.

The actual goal is to automate my thermostats and assign all {{states('input_number.xxx') | float}} to variables once in the automations and then only use the variables.

ok, thanks - that makes it clear.
too bad :frowning: