Page 1 of 1
Converting my block to dzVents
Posted: Sunday 12 August 2018 12:47
by Melotron
Hiya.
I am trying to convert a blocky to dzVents.
How do I set the in between value of the Lux ??
Code: Select all
return {
on = {
devices = {
'Lux'
}
},
if (domoticz.devices.Lux ( >= 3701 ) then
print("Lux is > 3701")
end
if (domoticz.devices.Lux ( >= 401 and <= 3700 ) then
print("Lux is > 401 and < 3700")
end
if (domoticz.devices.Lux ( = 0 and <= 400 ) then
print("Lux is > 0 and < 400")
end
end
}
I want it to set a few virtual switches after how light/dark it is.
I am only having the print command to see if it changes.
Code: Select all
2018-08-12 12:46:00.818 Status: dzVents: Error (2.4.6): error loading module 'MI Day' from file '/home/pi/domoticz/scripts/dzVents/generated_scripts/MI Day.lua':
2018-08-12 12:46:00.818 ...pi/domoticz/scripts/dzVents/generated_scripts/MI Day.lua:7: unexpected symbol near 'if'
Re: Converting my block to dzVents
Posted: Sunday 12 August 2018 13:01
by Andyf66
Your syntax is a bit off. Try something like this
Code: Select all
return {
on = {
devices = {
'Lux'
}
},
execute = function(domoticz, device)
if (device.Lux >= 3701 ) then
print("Lux is > 3701")
end
if ((device.Lux >= 401) and (device.Lux <= 3700 )) then
print("Lux is > 401 and < 3700")
end
if ((device.Lux >= 0) and (device.Lux <= 400)) then
print("Lux is > 0 and < 400")
end
end
}
Re: Converting my block to dzVents
Posted: Monday 13 August 2018 9:17
by Melotron
Andyf66 wrote: ↑Sunday 12 August 2018 13:01
Your syntax is a bit off. Try something like this
Thanks alot.
But now I need to learn how to handle values in dzvents.
Sat a few hours googling yesterday on the error and trying to figure out how it works.
I'm still lost
Code: Select all
Status: dzVents: Info: ------ Finished MI Day
Status: dzVents: Info: Handling events for: "Lux", value: "20266.6666667"
Status: dzVents: Info: ------ Start internal script: MI Day: Device: "Lux (Virtual_Switches)", Index: 130
Status: dzVents: Error (2.4.6): An error occured when calling event handler MI Day
Status: dzVents: Error (2.4.6): ...pi/domoticz/scripts/dzVents/generated_scripts/MI Day.lua:9: attempt to compare number with table
Status: dzVents: Info: ------ Finished MI Day
Code: Select all
return {
on = {
devices = {
'Lux'
}
},
execute = function(domoticz, device)
if (domoticz.devices('Lux') >= 3701 ) then
print("Lux is > 3701")
end
end
}
I've even made the script as simple as possible.
The Lux are 20k+ so it should work.
Re: Converting my block to dzVents
Posted: Monday 13 August 2018 9:28
by waaren
Melotron wrote: ↑Monday 13 August 2018 9:17
Status: dzVents: Error (2.4.6): ...pi/domoticz/scripts/dzVents/generated_scripts/MI Day.lua:9: attempt to compare number with table
Status: dzVents: Info: ------ Finished MI Day[/code]
You are trying to evaluate the table containing all attributes of your lux device. You should only evaluate the lux value.
Change
Code: Select all
if (domoticz.devices('Lux') >= 3701 ) then
to
Code: Select all
if (domoticz.devices('Lux').lux >= 3701 ) then
Re: Converting my block to dzVents
Posted: Monday 13 August 2018 14:24
by Melotron
waaren wrote: ↑Monday 13 August 2018 9:28
Melotron wrote: ↑Monday 13 August 2018 9:17
Status: dzVents: Error (2.4.6): ...pi/domoticz/scripts/dzVents/generated_scripts/MI Day.lua:9: attempt to compare number with table
Status: dzVents: Info: ------ Finished MI Day[/code]
You are trying to evaluate the table containing all attributes of your lux device. You should only evaluate the lux value.
Change
Code: Select all
if (domoticz.devices('Lux') >= 3701 ) then
to
Code: Select all
if (domoticz.devices('Lux').lux >= 3701 ) then
Thank you so much its working perfectly now =))