/config/esphome/eh8266-panel.yaml: In function 'void setup()':
/config/esphome/eh8266-panel.yaml:1291:43: error: 'brightness' was not declared in this scope
*** [.pioenvs/eh8266-panel/src/main.cpp.o] Error 1
So far I tried:
Other variable name, other type, Assigning it in the lambda to a temporary variable first… All with the same outcome.
Hi, I was just working with parameters today and I was researching a different issue and saw your post.
You need to pass the arrays first, example is here:
Hi Ronnie(Last),
I am having a bit of trouble comprehending…
First of all I do not need an array, just a simple value. Then I do not have an issue with non-templatable IDs which seems to be the case in the post you linked.
Do you suggest to use an array instead of a simple float because the “pre-access” in a (helper) binary_sensor would make it work for my example? Or is the array not necessary for me and I only need to access the variable in a lambda somewhere before the actual script?
Sorry, seems to me as if I am not getting what you are trying to point me to.
Yes, the arrays confused me initially too, but as I’m not a programmer I just rolled with it.
To show my working example, this is a button on an ESP32:
When you press the button it passes two parameters - one a string called “text_content” with the word BOOST and the second an int called “duration_in_min” with the integer 60 , to the script called “upstairs_heating_generic”.
The script then takes in both “parameters:” and in my case I use (rightly or wrongly) index [0] of both parameters which I use in lambdas as I need. Index [0] is just the first and only object in the array.
- id: upstairs_heating_generic
mode: restart
parameters:
text_content: string[]
duration_in_min: int[]
then:
- switch.turn_on: brb_us_direct
- text_sensor.template.publish:
id: text_state_us_heating
state: !lambda return text_content[0];
- text_sensor.template.publish:
id: text_time_us_heating # When run, send a text string to HA with the boost completion time
state: !lambda |-
char str[17];
time_t currTime = id(ds1307_time).now().timestamp + (duration_in_min[0] * 60);
strftime(str, sizeof(str), "%H:%M", localtime(&currTime));
return { str };