Help appreciated: LUA script enhancement

Moderator: leecollings

Post Reply
antipiot
Posts: 45
Joined: Wednesday 03 January 2018 15:08
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Location: Switzerland
Contact:

Help appreciated: LUA script enhancement

Post by antipiot »

Hello everybody!

I may need assistance:

I took the lua script for the onkyo plugin and tried to modify it to fit my needs to use my pionner AMP: Same instrutions: working as it should:

https://www.domoticz.com/wiki/Onkyo3

Cans somebody knowing LUA read this and correct it if it's bad? :-)
I wanted to know if i should name the script with the name of the virtual device triggering it ( "Source" in my case) i've read somewhere that some script can be triggered by the only device with the same as their name. Is this true?

Thanks for your help!


-- Title: script_device_Onkyo
-- Date: 10-07-2015

commandArray = {}

-- function to get information from receiver
function onkyo_status(command)
local result = {}
local output = io.popen ('onkyo '..command)
for line in output:lines() do
table.insert(result, line)
end
output:close()
return result
end

-- function to change settings receiver
function onkyo_change(command)
os.execute('/usr/local/bin/onkyo '..command)
end

-- turn the receiver on/off with dummy switch 'Source'

if devicechanged['Source']=="PC" then
onkyo_change('input-selector=dvd')
else
if devicechanged['Source']=="Recalbox" then
onkyo_change('input-selector=cbl')
else
end
if devicechanged['Source']=="Switch" then
onkyo_change('SLI11')
else
end
if devicechanged['Source']=="Runeaudio" then
onkyo_change('input-selector=cd')
else
end
if devicechanged['Source']=="Off" then
onkyo_change('system-power:standby')
end
end
return commandArray
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest