Hi, I am trying to setup some Lambda on a SIM800L, but for some reason I just cannot get the formatting or indentation right.
Can you please help me out with this,
Thanks
sim800l:
on_sms_received:
- lambda: |-
if id(sms_sender).state == "+12345678901": # Replace with the actual phone number
if id(sms_message).state == "turn_on":
id(my_output).turn_on()
elif id(sms_message).state == "turn_off":
id(my_output).turn_off()
Lambda is C++. This means your syntax must follow C++ rules. This is an example of if/else from W3Schools:
if (condition1) {
// block of code to be executed if condition1 is true
} else if (condition2) {
// block of code to be executed if the condition1 is false and condition2 is true
} else {
// block of code to be executed if the condition1 is false and condition2 is false
}
And from one of my projects:
if (speed<=11) { it.filled_circle(x, y, 7, light_blue); }
else {
if (speed>11 && speed<=30) { it.filled_circle(x, y, 7, green); }
else {
if (speed>30 && speed<=60) { it.filled_circle(x, y, 7, orange); }
else {
if (speed>60) { it.filled_circle(x, y, 7, red); }
} } }