Hello All!
I’ve been running OH 1.8 for many months and have really enjoyed expanding my system with the wealth of knowledge available on this forum. My system is on a RASPi 3 using MQTT with a mix of RFM69HCW packet radios with Arduino and ESP8266 NodeMcu’s.
I recently started using some rule-triggered audio responses for certain events and thought to utilize low power UHF radios to carry notifications. (I already use two-way radios on my property so it seemed to fit plus i once worked in the two-way repair industry).
I have linked the RASPi audio output with a radio’s audio input. I have a sendCommand to GPIO pin to “key” the radio before playSound starts the mp3 followed by another sendCommand to “dekey” to radio. Of course, as soon as playSound is executed, the next line is the Transmit OFF which only takes a split second.
I am looking for a way to delay the execution of the next line of code until playSound completes. Short of tweeking each rule using createTimer(now.plusSeconds) for each of the dozens of TTS generated mp3’s I’m using, I am stuck. I have looked at example rules and countless threads here but I can not see how to get past this.
Is there any returned value from playSound that I can utilize? I cant locate any evidence of this.
rule "driveway alarm"
when
Item driveway1 changed from OFF to ON
then
logInfo("LOG:","driveway rule start and voice is " + (VOICE.state.toString())
if (VOICE.state == ON) {
sendCommand(Transmit, ON)
playSound("visitor.mp3")
sendCommand(Transmit, OFF)
logInfo("LOG:","driveway alert voice triggered")}
end
Any feedback would be appreciated.