Page 1 of 1

run a lua script on scene execution

Posted: Friday 31 July 2020 20:53
by paede
My next question is about running a lua script I use to shutdown my media-pc.
On the pc I habe MCE Controller running.
The following lua code was run by vera in a scene and it worked.

Code: Select all

function shutDown(host)
	local socket = require("socket")
	c = assert(socket.connect(host, 5150))
	c:send("hibernate\r")
	c:close()
end

luup.call_delay("shutDown", 0, "192.168.0.3")
I made a textfile with that code in /home/pi/domoticz/scripts/ with the name 'Computer_shutdown.lua'
I made a scene that runs this script (On Action: script://Computer_shutdown.lua)

the log shows this:
2020-07-31 20:36:36.889 Status: User: Admin initiated a scene/group command
2020-07-31 20:36:37.101 Status: Executing script: /home/pi/domoticz/scripts/Computer_shutdown.lua
2020-07-31 20:36:37.121 Error: Error executing script command (/home/pi/domoticz/scripts/Computer_shutdown.lua). returned: 32256

I don't have any knowledge about lua programming. I found this code on the vera forum and used it.

Do you have any suggestions?
Greets
paede

Re: run a lua script on scene execution

Posted: Sunday 02 August 2020 20:24
by paede
I guess I try it with samba and "net rpc shutdown". (https://de.wikihow.com/Remote-einen-Com ... nterfahren)
I hope that works.

Re: run a lua script on scene execution

Posted: Tuesday 11 August 2020 12:07
by paede
I used net rpc shutdown as mentioned before.
On the rpi i made a textfile shutdown.sh with the "net rpc shutdown" command in it.
In Domoticz I run the script when a scene is executed.