Hi,
When testing a device variable in a scene trigger, is not possible to use variables in the conditional expression?
Thanks
Hi,
When testing a device variable in a scene trigger, is not possible to use variables in the conditional expression?
Thanks
It is Lua code , so things like Luup API like “get variable” should work inside the expression. If you do use the blockly editor I think it is proposed as a block.
Wow didn’t know this was possible. Indeed the blocky shows you exactly the syntax. I’ll do some more tests to validate it works
Thanks
I need to use the tonumber function in my conditional expression but it seems I cannot use tonumber directly with a variable_get
(old < tonumber(tonumber(luup.variable_get(“urn:upnp-org:serviceId:VContainer1”, “Variable4”, 24)) generates a “base out of range”
when testing
local get = tonumber(luup.variable_get(“urn:upnp-org:serviceId:VContainer1”, “Variable4”, 24)) it will generate an error “base out of range”
though if I put
local get = luup.variable_get(“urn:upnp-org:serviceId:VContainer1”, “Variable4”, 24)
local get = tonumber(get)
it passes
What is the difference?
[quote=“delle, post:4, topic:193573”]I need to use the tonumber function in my conditional expression but it seems I cannot use tonumber directly with a variable_get
(old < tonumber(tonumber(luup.variable_get(“urn:upnp-org:serviceId:VContainer1”, “Variable4”, 24)) generates a “base out of range”
when testing
local get = tonumber(luup.variable_get(“urn:upnp-org:serviceId:VContainer1”, “Variable4”, 24)) it will generate an error “base out of range”
though if I put
local get = luup.variable_get(“urn:upnp-org:serviceId:VContainer1”, “Variable4”, 24)
local get = tonumber(get)
it passes
What is the difference?[/quote]
I think this is some weirdness of lua because of the multiple number of returned values of functions. in your first example probably tonumber() expects more than one argument and receives a second argument from luup.variable_get but they do not match.
LUA DOC
tonumber(e [, base ])
found a solution in just adding parentheses
local get = tonumber((luup.variable_get(“urn:upnp-org:serviceId:VContainer1”, “Variable4”, 24))) is working
continue adding it in the expression
Best Home Automation shopping experience. Shop at Ezlo!
© 2024 Ezlo Innovation, All Rights Reserved. Terms of Use | Privacy Policy | Forum Rules