Page 1 of 1

Path to audio file - Lua on Windows

Posted: Friday 08 April 2016 9:20
by keyper
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:

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
It the arming of the security panel works, but I get the following error re the sound file:
Error: EventSystem: in Shed security with switch: [string "commandArray = {} ..."]:4: attempt to index global 'audio' (a nil value)
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.

This script is being created in the Domoticz Events editor.

TIA!