[SOLVED] Repeat command in rules

I have the following question. I have a rule for xiaomi. How to make the playing of a melody for example 10 times?
rule “Открыта дверь” when
Item mihome_sensor_magnet_158d0002e29d73_isOpen changed from CLOSED
to OPEN then
if (mihome_gateway_7c49eb88f15c_volume.state == 100){
sendTelegram(“bot1”, “Сработала сигнализация”)
mihome_gateway_7c49eb88f15c_enableSound.sendCommand(ON)
mihome_gateway_7c49eb88f15c_sound.sendCommand(2)
executeCommandLine(“bash /home/orange/bot/sms.sh”)}
end

Is there an item which represents the play status (to get the information if playout is finished)?

mihome_gateway_7c49eb88f15c_enableSound.sendCommand(ON) this command starts playback
mihome_gateway_7c49eb88f15c_sound.sendCommand(2) This command indicates which melody to play.
I think I need to repeat this command. mihome_gateway_7c49eb88f15c_sound.sendCommand(2) with delay 5 sec.

The question was: Is there an item which represents the play status? Maybe mihome_gateway_7c49eb88f15c_enableSound switches to OFF when playout is finished?

Yes

Then the easy solution is:

var Number nCount = -1                        //counter

rule "Открыта дверь"
when
    Item mihome_sensor_magnet_158d0002e29d73_isOpen changed from CLOSED to OPEN or
    mihome_gateway_7c49eb88f15c_enableSound changed to OFF   // playout ended
then
    if(mihome_gateway_7c49eb88f15c_volume.state == 100 && mihome_sensor_magnet_158d0002e29d73_isOpen.state == OPEN) {
        if(nCount == -1) {                                   // start, send Telegram and sms
            sendTelegram("bot1", "Сработала сигнализация")
            executeCommandLine("bash /home/orange/bot/sms.sh")
        }
        if (nCount < 10) {                                   // iteration
            mihome_gateway_7c49eb88f15c_enableSound.sendCommand(ON)
            mihome_gateway_7c49eb88f15c_sound.sendCommand(2)
            nCount += 1                                      // count up
        }
        else {
            nCount = -1                                      // reset counter
        }
    }
end

Thank you. Tomorrow I will try