Path to audio file - Lua on Windows
Posted: Friday 08 April 2016 9:20
Complete n00b to Lua, and Domoticz, so any help appreciated 
I'm trying to play a sound file when Security Panel is set to "Arm Away" using a switch. The following is the code I'm experimenting with:
It the arming of the security panel works, but I get the following error re the sound file:
This script is being created in the Domoticz Events editor.
TIA!

I'm trying to play a sound file when Security Panel is set to "Arm Away" using a switch. The following is the code I'm experimenting with:
Code: Select all
commandArray = {}
if (devicechanged['Shed Security'] == 'On') then
commandArray['Shed Security Panel'] = 'Arm Away'
local chord = audio.loadSound( "chord.wav" )
audio.play( chord )
end
if (devicechanged['Shed Security'] == 'Off') then
commandArray['Shed Security Panel'] = 'Disarm'
end
return commandArray
Can anyone help me with how I can get the sound file "found" by the script please? I have tried placing the chord.wav file in a few different locations, including the Domoticz scripts directory, and scripts\lua; I've also tried including file paths with the file name but none of this has worked.Error: EventSystem: in Shed security with switch: [string "commandArray = {} ..."]:4: attempt to index global 'audio' (a nil value)
This script is being created in the Domoticz Events editor.
TIA!