Im building a test automation which I just run and make sure the LED changes before I work on the trigger etc. I can send color to the LED. I plan to use some basic math to select a color in the next step, but im stuck on the math portion.
I set a numerical helper in order to observe the resulting value, the template debug is of limited use and doesnt seem to work with variables. As such I cannot find another method to monitor the result of my maffs.
Anyway, I want to get two random numbers from 0-4 and AVG them. Thus increasing my “randomness” espec given the limited range. I think ive got the random bit sorted.
What I cant seem to solve is how to combine the two integers. Really im just adding them as a proof of concept for now before i change the operation to an AVG.
Ive tried so many variations of syntax or set value service, or variable declaration. I cannot get the two local variables to add. Ive tried the template under the same service call thinking it was scope related, no dice.
so like
variables: number1,number2,result
value: 1,2,(1+2) works. the template shows 3
any version of:
value:1,2,{{number1 + number2 }} doesnt work.
I tried to call the set.variable service for the result separately thinking perhaps we need to finish the previous operation first. nope
Ive read a bunch of documentation, but nothing ive tried works. yamllint will say my code is clean etc etc and no help. YAML has to be the most frustrating language ive used. Syntax is difficult to understand, the debug environment is non existent. Id say im a novice at coding etc, but its usually not very hard. Compared to having an IDE or Webcore, this is just awful /rant portion.
Thanks very much
alias: LED Test
description: "Passing in a color from a Helper to set the LED color. This works thus far. I need to do some simple numerical manip for the next step, but i cannot get a simple add to even work properly"
trigger: []
condition: []
action:
#working
- service: input_text.set_value
target:
entity_id: input_text.holiday_color_one
data:
value: "{{ 'RED' }}"
#working
- service: variable.set_variable
data:
variables: number1,number2
value: 1,2
#NOTworking
- service: variable.set_variable
data:
variables: result
value_template: "{{ 'number1' |int + 'number2' |int }}"
#Cannot get to work or even try to fix as result of failure above
- service: input_number.set_value
target:
entity_id: input_number.variabletester
data:
value: "{{ result }}"
#working
- service: light.turn_on
data:
color_name: "{{ states('input_text.holiday_color_one') }}"
target:
device_id: xxxxxxxxxx
mode: single