Page 1 of 1

Lua script, do i miss something?

Posted: Thursday 07 January 2016 11:17
by francisb
Hello,

I have copied a small lua script to trigger a shell script, but it seems not to work. The .sh script on itself works, tested in a shell under the same username as where Domticz is running in.

Code: Select all

commandArray = {}
  if (devicechanged['Deurbel']=='On') then
      os.execute('/home/pi/domoticz/scripts/SentSnapshot.sh')
      print('Script Deurbel is ingedrukt')
  end
return commandArray
I have put this ual script in the following folder on Rasberry Pi: /home/pi/domoticz/scripts/lua/script_device_Deurbel.lua.

My questions are:

Is there something wrong with the script?
The device name in the script, is this the same name you give when you add the device in Domoticz?
According to some documentation i should see a log in /var/log/domoticz, is this correct? i do not seem to have this.
Any other suggestions?

As you can see i am not sure how the mechanism of the domoticz and ual scripts is working, i found some documentation but most are about the ual scripting itself.

Any help is appriciated.

Francis

Re: Lua script, do i miss something?

Posted: Thursday 07 January 2016 11:26
by ThinkPad
What does the log of Domoticz show you? You can view it through the webinterface, it is somewhere under the 'Setup' menu button.

I would turn the print and os.execute around, so that the print statement is executed first. This way it is easier to spot it in the log.
Device name should be an exact match of the name of the switch in Domoticz indeed.

Re: Lua script, do i miss something?

Posted: Thursday 07 January 2016 11:35
by francisb
When i triggered the Doorbell, i can see the notification from the device itself not from the script.
No entry of the script in the log, also not after changing the print command as you stated in your reply.

Re: Lua script, do i miss something?

Posted: Thursday 07 January 2016 11:38
by francisb
could it be that the doorbell is on "group on" and if so how can i change that?

Re: Lua script, do i miss something?

Posted: Thursday 07 January 2016 12:19
by Kjakan
You can change Doorbell Command in Setup -> Settings -> Other

Re: Lua script, do i miss something?

Posted: Thursday 07 January 2016 12:33
by francisb
And that my friend is the solution....it works now.

What is the group on for by the way? And can you change the ual script so it can also work on group on?

Re: Lua script, do i miss something?

Posted: Thursday 07 January 2016 17:55
by francisb
Ok, i cheered to early (dutch saying)

When i go the doorbell on the Domoticz website then it works, but when i actually press the doorbell it does not. The log is showing an entry.
2016-01-07 17:49:52.064 Notification sent (http) => Success
2016-01-07 17:49:51.765 (RFXCom) Lighting 2 (Deurbel)

So why does it not act correctly.....

Re: Lua script, do i miss something?

Posted: Thursday 07 January 2016 18:50
by francisb
Ok i investigate further and its the "group on" giving the problem. When i press within Domoticz website on the doorbell then i see in the log the on command.
But when de doorbell itself is pressed i see group on in the log.

So why is that?

Re: Lua script, do i miss something?

Posted: Thursday 07 January 2016 19:02
by francisb
ok solved it, changed the ual script.

Code: Select all

if (devicechanged['Deurbel']=='Group On') then
So changed it to Group on.

Re: Lua script, do i miss something?

Posted: Thursday 07 January 2016 21:49
by ThinkPad
Good to hear you got it fixed.

If you also want to trigger it from the website, you could make the script like this:

Code: Select all

if ((devicechanged['Deurbel']=='Group On') or (devicechanged['Deurbel']=='On')) then
rest of your script