Page 1 of 1

[Noob Question] How to start with lua scripting?

Posted: Saturday 11 March 2017 1:01
by Zweef
Hi!

Can anyone explain how to use lua scripting?

I'm just starting to use Domoticz. I do have some experience with lua (I use an Fibaro HC2 Z-wave controller at this time with self made lua scripts).

Because I'm really fed up with Fibaro lack of transparency and closed source approach, I investigated several options to switch to another gateway. I really like Domoticz for it's open source approach, and decided to gradually switch to Domoticz.

I have installed Domoticz on a Raspberry Pi 3 (Raspian) with RealVNC support.

So, excuse for this really noob question, but can anyone help me started?
How should I use lua in Domoticz and what is the best approach?
Which tools do I need and what do I have to install?

Thanks in advance!

Re: [Noob Question] How to start with lua scripting?

Posted: Saturday 11 March 2017 2:14
by HansieNL
Hello,
I would advice to check the wiki. There are sample scripts.
You don't have to install additional software to use lua scripting.

Re: [Noob Question] How to start with lua scripting?

Posted: Sunday 12 March 2017 14:13
by Zweef
HansieNL wrote:Hello,
I would advice to check the wiki. There are sample scripts.
You don't have to install additional software to use lua scripting.
Thank you Hans for replying.

I just noticed that scripts can be inserted in 'Events'. Can you tell me how I can debug new lua scripts? If a print-function is used, where is the content printed?

Re: [Noob Question] How to start with lua scripting?

Posted: Sunday 12 March 2017 14:49
by DanM
Print sends info to the domoitz log page.

Re: [Noob Question] How to start with lua scripting?

Posted: Sunday 12 March 2017 15:11
by Zweef
DanM wrote:Print sends info to the domoitz log page.
Allright, clear! thanks.

Re: [Noob Question] How to start with lua scripting?

Posted: Sunday 12 March 2017 18:46
by Zweef
Just another noob question though:

Whats the difference between lua scripts and lua code in events --> lua?

Re: [Noob Question] How to start with lua scripting?

Posted: Sunday 12 March 2017 18:55
by jvdz
Not much. The first one is done through file(s) in the LUA subdirectory and are shelled by the event handler based on their name.
The second option is created recently and stores the LUA scripts in the domoticz database and will shell them based on the Event type selected.

Jos

Re: [Noob Question] How to start with lua scripting?

Posted: Sunday 12 March 2017 19:24
by Zweef
Thank you, Jos!

I saw some scripts published, but when to insert them in lua-events, I have error warnings.

Looks like variables like $test is not accepted. It should be without the $-sign. Does this mean this is one of the difference between lua-events and lua-scripts?

Re: [Noob Question] How to start with lua scripting?

Posted: Sunday 12 March 2017 19:34
by jvdz
Are you sure that was a LUA script that contains the $test and not a perl, php or bash script?
LUA is LUA so the syntax for both options is the same.

Jos

Re: [Noob Question] How to start with lua scripting?

Posted: Sunday 12 March 2017 19:38
by Zweef
Okay, clear enough, Jos.

I will start with my first lua coding. I will make a new topic for that. Thanks.