All,
I tried already a various number of options, surfed the forum but I always end up with not finding the correct information.
I try to learn LUA scripting so first of all I search for a beginners explanation of LUA scripting I am familiar with programming. But not with all the parameters and function calls in LUA.
If someone has a good startingpoint that would help me a lot.
And maybe someone is willing to convert the Blocky I present below to a LUA script for my reference. Maybe I can go from there to learn the LUA scripting.
Thanks for your help!
BR,
Marc
Convert to LUA, LUA Beginner
Moderator: leecollings
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Convert to LUA, LUA Beginner
If you are only going to use LUA in the domoticz environment, you should investigate if dzVents is suited for you. The wiki is an excellent starting point for that.
https://www.domoticz.com/wiki/DzVents:_ ... _scripting
My experience is that it will make LUA coding much easier to do, -understand and maintain by hiding all the complicated structures under the hood. In the end it is pure LUA but an enormous amount of work is already done for you.
https://www.domoticz.com/wiki/DzVents:_ ... _scripting
My experience is that it will make LUA coding much easier to do, -understand and maintain by hiding all the complicated structures under the hood. In the end it is pure LUA but an enormous amount of work is already done for you.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 15
- Joined: Monday 03 April 2017 15:01
- Target OS: Linux
- Domoticz version: 4.9701
- Location: Netherlands
- Contact:
Re: Convert to LUA, LUA Beginner
First steps in programming in general? What Waaren is saying is true. dzVents will be a lot more friendly then LUA. I got most of my scripts ported over to dzVents now.
That however does not answer your request. I can't give any guaranties that the Lua code below will work. I just wrote it reading your blocky info. DId not test it, don't have your setup. Tried to keep it as close to your orginal for learning purpose. Hope it helps.
That however does not answer your request. I can't give any guaranties that the Lua code below will work. I just wrote it reading your blocky info. DId not test it, don't have your setup. Tried to keep it as close to your orginal for learning purpose. Hope it helps.
Code: Select all
commandArray = {}
local timenow = os.date("*t")
local minutesnow = timenow.min + timenow.hour * 60
local dm0700 = 7 * 60
local dm2200 = 22 * 60
if (minutesnow > dm0700 and minutesnow < timeofday['SunriseInMinutes']) or
(minutesnow > timeofday['SunsetInMinutes'] and minutesnow < dm2200) or
otherdevices['UitNax'] == 'On' then
commandArray['Group:Buiten-Lampen'] = 'On'
elseif otherdevices['Laat-Thuis'] == 'On' and otherdevices['UitNax'] == 'Off' then
commandArray['Laat-Thuis'] = 'Off AFTER 30'
commandArray['UitNax'] = 'On FOR 60'
commandArray['Group:Buiten-Lampen'] = 'On'
elseif otherdevices['Laat-Thuis'] == 'Off' and otherdevices['UitNax'] == 'Off' then
commandArray['Group:Buiten-Lampen'] = 'Off'
elseif minutesnow < dm0700 or minutesnow > dm2200 and otherdevices['UitNax'] == 'Off' then
commandArray['Group:Buiten-Lampen'] = 'Off'
end
return commandArray
-
- Posts: 65
- Joined: Tuesday 13 October 2015 13:50
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: Poland
- Contact:
Re: Convert to LUA, LUA Beginner
dzVenst is very simple. Look also on new module for compact and simple syntax
viewtopic.php?f=59&t=21914
In this sytext script is very short. You can download and read about it here Who is online
Users browsing this forum: No registered users and 0 guests