Hey All,
I use the following two rules to turn on my speakers (even with amazon ECHO (a dummy item))
This should give the amplifier a 4 second delay, before turning on the Subwoofer.
Or turning of the subwoofer 4 seconds prior the amplifier.
Since i added a script to check, if i controlled the switches from another site, i added rule two.
How can i avoid timing errors, which will lead really often to the circumstance, that “Port2_4” stays on (switches off, and then really quickly on again)
I would like to implement another condition in the second rule, to check if the 4-second-timer is active.
I created this rules to avoid an earthquake when shutting down subwoofer and amp together.
Thanks
rule "Audio Delay"
when
Item Audio_ALL changed
then
if(Audio_ALL.state==ON) {
if(ECHO_Switch1.state!=ON){ECHO_Switch1.sendCommand(ON)}
if (audiodelay != null){ audiodelay.cancel()}
sendCommand(Port2_4, ON)
audiodelay = createTimer(now.plusSeconds(4)) [|sendCommand(Port1_2, ON)]}
if(Audio_ALL.state==OFF) {
if(ECHO_Switch1.state!=OFF){ECHO_Switch1.sendCommand(OFF)}
if (audiodelay != null){ audiodelay.cancel()}
sendCommand(Port1_2, OFF)
audiodelay = createTimer(now.plusSeconds(4)) [|sendCommand(Port2_4, OFF)]}
end
rule "Audio Update"
when
Item Port1_2 changed or
Item Port2_4 changed
then
if (Port1_2.state==ON && Port2_4.state==ON && Audio_ALL.state==OFF){ postUpdate(Audio_ALL, ON)}
if (Port1_2.state==OFF && Port2_4.state==OFF && Audio_ALL.state==ON) { postUpdate(Audio_ALL, OFF)}
end