I'm attempting to simply play a door chime mp3 when a contact switch opens. Took me a while but I finally figured out how to get the simple contact switch working. Resistor to 3.3v?? Who knew? Not me. haha
The script works perfectly within a terminal but, as has all too often been mentioned in these forums, does not within Domoticz.
Script is simple: /home/pi/domoticz/scripts/doorchime.sh
Code: Select all
#!/bin/bash
# Play the door chime
mplayer -volume 80 /home/pi/domoticz/sounds/cabin_chime.mp3 > /dev/null 2>&1
Code: Select all
pi@NorthwoodDeux:~/domoticz/scripts $ id
uid=1000(pi) gid=1000(pi) groups=1000(pi),4(adm),20(dialout),24(cdrom),27(sudo),29(audio),44(video),46(plugdev),60(games),100(users),105(input),109(netdev),117(lpadmin),997(gpio),998(i2c),999(spi)
I've attempted calling the script via the "On action" function directly in the device:
Code: Select all
script:///home/pi/domoticz/scripts/doorchime.sh
Code: Select all
script://doorchime.sh
I've attempted using dzVents and tested the os.execute command several ways using a motion sensor as the trigger (easier than opening/closing the switch right now)
Code: Select all
return {
on = {
devices = {
'PIR_MotionSensor'
}
},
logging = {
level = domoticz.LOG_INFO,
marker = 'whoops thar be motion in da hizzle',
},
execute = function(domoticz, device)
os.execute ("runuser -l pi -c \'mplayer -volume 80 /home/pi/domoticz/sounds/cabin_chime.mp3'")
domoticz.log('PIR_MotionSensor' .. device.name .. ' got a little jiggy', domoticz.LOG_INFO)
end
}
I've gone as far as completely wiping the SD card and starting from scratch to no avail. I did have this same issue several years back (5 or so?) when I first began using Domoticz but was able to get it working although, I cannot recall how.
user "pi" is in the audio group
runuser does not seem to work in this instance
script works perfectly and be called from within other scripts within terminal
I'm unsure how to code this within dzVents to display an error code that could possibly help identify an issue. I'm not a coder but am pretty adept at learning and have become quite comfy with LUA although I'm now preferring dzVents - all self-taught.
Does anyone have any suggestions on what to check next or how to script dzVents to reveal any error codes? I'm kinda pulling my hair out on something that seems should be quite simple. Every single thread I've viewed on this topic - and there are many! - their resolution did not work for me.
Did I provide enough information or is there something else I should add to clarify?
Thanks in advance.