LUUP code not working...

Hi everyone,

I am trying to get a scene to run only when a virtual switch (device id 34) is set to on and when a dimmer (device id 14) is currently off. I am using the following code but it is saying that there is an error - can anyone see what I have done wrong?

Many thanks

Two ‘if’ statements and only one ‘end’?
Take care that the ‘else’ belongs to the right ‘if’ too.

----edit----

I personally would write this as:

return (lul_tmp == "1") and (dim_level == "0")

…but this may not be to everyone’s taste.

Ive experienced in the past where a variable value is “0” lua considers the variable undeclared because of its null value. I understand that setting a variable’s value to null is the same as un-declaring its existance. It might therefore render the statement inoperable as its referencing a non existent variable.
Can anyone confirm this or clarify, please?

If a variable has not been initialised it will return nil. This is not the same as “0” or 0. This is not necessarily an error - it depends what you are trying to do with it.