Hello guys,
i wanted to create a simple “turn-off timer” rule for my sound receiver which is connected to Alexa.
The connected Alexa dot is implemented in 3 different groups (Echo_Wohnzimmer_Player, Echo_Wohnung_Player, Echo_Wohnungbereich_Player). So i want to check if really all groups are in PAUSE.
Problem is that when alexa is changing music titles the player is jumping to PAUSE and back to PLAY very quickly. I want to avoid that my Sound Receiver is turn off by this, so i wanted to check 10s later if all Groups are still in Pause to turn the Receiver finally off.
However sometime this is not working an the OFF-command is not send. Even if all Groups are still in pause. I dont know the reason. Maybe something is wrong with the timer?
var Timer timer = null
rule "Alexa Wohnzimmer AUS"
when
Item Echo_Wohnzimmer_Player changed from PLAY to PAUSE or
Item Echo_Wohnung_Player changed from PLAY to PAUSE or
Item Echo_Wohnungbereich_Player changed from PLAY to PAUSE
then
if (timer === null) {
timer = createTimer(now.plusSeconds(10), [ |
if (Echo_Wohnzimmer_Player.state == PAUSE && Echo_Wohnung_Player.state == PAUSE && Echo_Wohnungbereich_Player.state == PAUSE) {
ArduinoIRcontrol_Alexa_Wohnzimmer.sendCommand(OFF)
}
])
} else {
if(timer!==null) {
timer.cancel
timer = null
}
}
end
Does someone have an idea?
I am lost