I was also thinking that but got compile error. Tried with brackets and same thing.
Compiling /data/frontdoorledsrip/.pioenvs/frontdoorledsrip/src/main.cpp.o
src/main.cpp: In lambda function:
src/main.cpp:475:14: error: invalid conversion from 'const char*' to 'uint8_t {aka unsigned char}' [-fpermissive]
return "1";
^
*** [/data/frontdoorledsrip/.pioenvs/frontdoorledsrip/src/main.cpp.o] Error 1
========================= [FAILED] Took 11.01 seconds =========================
KTibow
(Kendell R)
December 29, 2020, 6:51pm
22
What about
!lambda: |
uint8_t amount = "1";
return amount;
Had to change your syntax to the following so it would compile,
red: !lambda
'uint8_t amount = 1;
return amount;'
With quote got the following,
src/main.cpp: In lambda function:
src/main.cpp:475:24: error: invalid conversion from 'const char*' to 'uint8_t {aka unsigned char}' [-fpermissive]
uint8_t amount = "1"; return amount;
^
*** [/data/frontdoorledsrip/.pioenvs/frontdoorledsrip/src/main.cpp.o] Error 1
========================= [FAILED] Took 10.86 seconds =========================
Without quote around the 1 it compiled but unfortunately did not work.
lmamakos
(Louis Mamakos)
December 29, 2020, 7:08pm
24
Looks like you are doing integer math, not floats. Maybe that’s related to your problem.
I am starting to think this might be a defect. Nothing I put in the return actually delivers a result. Hardcoding the value works. The documentation has an example which implies it should work.
Being new to ESPHome how do we get someone to look at it?
KTibow
(Kendell R)
December 30, 2020, 3:13pm
26
lmamakos
(Louis Mamakos)
December 30, 2020, 7:25pm
27
When I look at https://esphome.io/guides/automations.html#config-templatable it seems like the value returned by the lambda should be a floating point number between zero and one, based on the example there.
So it seems like you should have the lambda return a floating point number (e.g., do arithmetic in the expressing using a floating point constant like 100.0
) between 0 and 1.0.
To test this, just write a lambda that returns 0.5
and see if that does the expected with a 50% brightness.
I did try that, didn’t turn on. So I decided to pursue a different path, going to see if I can use partitions and effect to code what I what.