Path to audio file - Lua on Windows

Moderator: leecollings

Post Reply
keyper
Posts: 1
Joined: Friday 08 April 2016 9:04
Target OS: -
Domoticz version: 3.4834
Contact:

Path to audio file - Lua on Windows

Post 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!
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest