LUA Script not running, at all

Moderator: leecollings

Post Reply
Eloque
Posts: 35
Joined: Monday 05 January 2015 12:55
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

LUA Script not running, at all

Post by Eloque »

I am trying to make a few simple lua scripts, but so far, I can't even get the simplest to run.
I've followed the instructions of renaming the demo scripts, but they never ever seem to trigger.

cat script_time_test.lua

Code: Select all

print('this will end up in the domoticz log')
and cat script_device_light.lua

Code: Select all

print('Light Test One')

commandArray = {}
if (devicechanged['Trap/Gang Licht'] == 'Off' then
        commandArray['Trap/Gang Licht']='On'
end
return commandArray
Both never seem to run, nothing shows in the logs, no devices change state, nothing. Is there something I am missing?
Holland
Posts: 179
Joined: Friday 12 July 2013 13:53
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta Ch
Location: The Netherlands
Contact:

Re: LUA Script not running, at all

Post by Holland »

Are these placed in the directory? ; ~/domoticz/scripts/lua
Eloque
Posts: 35
Joined: Monday 05 January 2015 12:55
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: LUA Script not running, at all

Post by Eloque »

Yes. Same place as the demo scripts were.
jannl
Posts: 673
Joined: Thursday 02 October 2014 6:36
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.2
Location: Geleen
Contact:

Re: LUA Script not running, at all

Post by jannl »

Not sure if the '/' is allowed in the name of a switch
NickHead
Posts: 83
Joined: Tuesday 29 October 2013 18:30
Target OS: Linux
Domoticz version:
Location: North East Coast of the UK
Contact:

Re: LUA Script not running, at all

Post by NickHead »

Try this:

My scripts are bracketed different.

May work, I am not an expert.

Code: Select all

print('Light Test One')

commandArray = {}
if (devicechanged['Trap/Gang Licht'] == 'Off') then
        commandArray[1]={['Trap/Gang Licht']='On'}
end
return commandArray
A lot of stuff that is doing my head in.
Eloque
Posts: 35
Joined: Monday 05 January 2015 12:55
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: LUA Script not running, at all

Post by Eloque »

Trying that now. I'd be happy if even the log line appears :)
paulvha
Posts: 40
Joined: Friday 29 January 2016 16:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Netherlands
Contact:

Re: LUA Script not running, at all

Post by paulvha »

does the script have the right permission?
Eloque
Posts: 35
Joined: Monday 05 January 2015 12:55
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: LUA Script not running, at all

Post by Eloque »

Nope. Nothing. The scripts don't seem to get executed at all.

What permission should they have? I'll try chmod'ing them to 777 to try just in case.
martijnhiemstra
Posts: 1
Joined: Sunday 21 February 2016 17:12
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: LUA Script not running, at all

Post by martijnhiemstra »

When you create the file script_time_test.lua domoticz expects a device called test to exist. The file name system works like this:
script_time_devicename.lua

This by the way will execute the script every minute. If you want to execute the script on every change then rename the script to:
script_device_devicename.lua
niceandeasy
Posts: 102
Joined: Thursday 28 January 2016 22:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8153
Location: NL
Contact:

Re: LUA Script not running, at all

Post by niceandeasy »

Check your settings/other. Probably the event system is disabled.
NickHead
Posts: 83
Joined: Tuesday 29 October 2013 18:30
Target OS: Linux
Domoticz version:
Location: North East Coast of the UK
Contact:

Re: LUA Script not running, at all

Post by NickHead »

Mine was called device_script_test.lua and i haven't got a switch called test.

It was to my belief that any script other than demo was run, the command being extracted
with the "devicechanged" section and acted upon.

Hence why I never included a filename.

As long as the device changed name is equal to the switch name ( as you said ) the script should act
accordingly.
A lot of stuff that is doing my head in.
NickHead
Posts: 83
Joined: Tuesday 29 October 2013 18:30
Target OS: Linux
Domoticz version:
Location: North East Coast of the UK
Contact:

Re: LUA Script not running, at all

Post by NickHead »

As previously said:

Check Setup-Settings-Other, at the bottom is a Script-Enable/Disable Radio Button
A lot of stuff that is doing my head in.
Eloque
Posts: 35
Joined: Monday 05 January 2015 12:55
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: LUA Script not running, at all

Post by Eloque »

NickHead, I found the setting, it was not disabled, blocky scripts are working btw.
I tried the old standby of turning it off and on again, and this showed up in the log;

Code: Select all

2016-02-21 17:52:27.160  EventSystem: Stopped...
2016-02-21 17:52:27.168  Active notification subsystems: (0/8)
2016-02-21 17:52:33.027  (RFXCOM) Temp + Humidity (Sensor Reinder)
2016-02-21 17:52:41.826  EventSystem: reset all events...
2016-02-21 17:52:41.826  EventSystem: reset all device statuses...
2016-02-21 17:52:41.826  EventSystem: Started
2016-02-21 17:52:41.828  Active notification subsystems: (0/8)
2016-02-21 17:52:47.661  (RFXCOM) Temp + Humidity (Sensor Woonkamer)
And the scripts don't trigger. I'll try renaming the file next.
NickHead
Posts: 83
Joined: Tuesday 29 October 2013 18:30
Target OS: Linux
Domoticz version:
Location: North East Coast of the UK
Contact:

Re: LUA Script not running, at all

Post by NickHead »

MMM Strange.

I am going to leave it with you for now as I have to go to work.

I will look back in later.

Regards
A lot of stuff that is doing my head in.
User avatar
Siewert308SW
Posts: 290
Joined: Monday 29 December 2014 15:47
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Location: The Netherlands
Contact:

Re: LUA Script not running, at all

Post by Siewert308SW »

Are you on the latest beta?
if so, check the forum... ;-)
Setup:
- RPi4 - Domo Stable / Aeotec Z-stick7 / PiHole Unbound Gemini
- RPi4 - PiHole / PiVPN Unbound Gemini
- Synology DS923+ / DS218j
- P1 Gas/Power, SmartGateway watermeter
- Fibaro switches, contacts, plugs, smoke/Co2 ect
- rootfs @ USB HDD
niceandeasy
Posts: 102
Joined: Thursday 28 January 2016 22:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8153
Location: NL
Contact:

Re: LUA Script not running, at all

Post by niceandeasy »

Indeed. I also discovered a bug in my system. Some things still work, some don't. Luckily, my lights are controlled by curl commands.
My time script gets triggered according to the log but it does not do anything.
(running newest beta)
Eloque
Posts: 35
Joined: Monday 05 January 2015 12:55
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: LUA Script not running, at all

Post by Eloque »

About Domoticz
Version: 2.3029
Build Hash: 3b588dd
Compile Date: 2015-09-15 13:32:45

I'll try upgrading next.
Eloque
Posts: 35
Joined: Monday 05 January 2015 12:55
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: LUA Script not running, at all

Post by Eloque »

Upgrading worked. Scripts run.
User avatar
Siewert308SW
Posts: 290
Joined: Monday 29 December 2014 15:47
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Location: The Netherlands
Contact:

Re: LUA Script not running, at all

Post by Siewert308SW »

Eloque wrote:Upgrading worked. Scripts run.
Upgrading to what version?
Setup:
- RPi4 - Domo Stable / Aeotec Z-stick7 / PiHole Unbound Gemini
- RPi4 - PiHole / PiVPN Unbound Gemini
- Synology DS923+ / DS218j
- P1 Gas/Power, SmartGateway watermeter
- Fibaro switches, contacts, plugs, smoke/Co2 ect
- rootfs @ USB HDD
Eloque
Posts: 35
Joined: Monday 05 January 2015 12:55
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: LUA Script not running, at all

Post by Eloque »

About Domoticz
Version: 2.4692
Build Hash: f42a1df
Compile Date: 2016-02-21 14:33:51

But, now Blocky scripts don't work at all :( Also, I can't set my SmartWares radiators to a temp, the devices don't show up. I can do it manually via the webinterface, but not via scripts.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest