[Noob Question] How to start with lua scripting?

Moderator: leecollings

Post Reply
User avatar
Zweef
Posts: 17
Joined: Sunday 02 November 2014 16:10
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: The Netherlands
Contact:

[Noob Question] How to start with lua scripting?

Post 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!
Domoticz on Raspberry Pi 3 using mainly Z-Wave

Other gateways:
Fibaro HC2
Athom Homey
User avatar
HansieNL
Posts: 964
Joined: Monday 28 September 2015 15:13
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

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

Post 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.
Blah blah blah
User avatar
Zweef
Posts: 17
Joined: Sunday 02 November 2014 16:10
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: The Netherlands
Contact:

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

Post 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?
Domoticz on Raspberry Pi 3 using mainly Z-Wave

Other gateways:
Fibaro HC2
Athom Homey
DanM
Posts: 79
Joined: Thursday 23 October 2014 22:41
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

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

Post by DanM »

Print sends info to the domoitz log page.
User avatar
Zweef
Posts: 17
Joined: Sunday 02 November 2014 16:10
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: The Netherlands
Contact:

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

Post by Zweef »

DanM wrote:Print sends info to the domoitz log page.
Allright, clear! thanks.
Domoticz on Raspberry Pi 3 using mainly Z-Wave

Other gateways:
Fibaro HC2
Athom Homey
User avatar
Zweef
Posts: 17
Joined: Sunday 02 November 2014 16:10
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: The Netherlands
Contact:

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

Post by Zweef »

Just another noob question though:

Whats the difference between lua scripts and lua code in events --> lua?
Domoticz on Raspberry Pi 3 using mainly Z-Wave

Other gateways:
Fibaro HC2
Athom Homey
User avatar
jvdz
Posts: 2328
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

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

Post 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
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
User avatar
Zweef
Posts: 17
Joined: Sunday 02 November 2014 16:10
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: The Netherlands
Contact:

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

Post 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?
Domoticz on Raspberry Pi 3 using mainly Z-Wave

Other gateways:
Fibaro HC2
Athom Homey
User avatar
jvdz
Posts: 2328
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

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

Post 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
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
User avatar
Zweef
Posts: 17
Joined: Sunday 02 November 2014 16:10
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: The Netherlands
Contact:

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

Post by Zweef »

Okay, clear enough, Jos.

I will start with my first lua coding. I will make a new topic for that. Thanks.
Domoticz on Raspberry Pi 3 using mainly Z-Wave

Other gateways:
Fibaro HC2
Athom Homey
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest