[SOLVED] Using stateDescription.pattern in rule

Howdi

I´m trying to use the initial state value of a string item by using stateDescription.pattern in a rule - Is there any restriction using this value in combination with an exec cmd?

.
*.rules

...
    // Execute command on selected blind
    gRolloMAC.members.filter[ i | i.name == macItem ].forEach[ i | 
        var Number j = 0
        while(j < 3) {
            // logInfo("TEST", "sudo python /etc/openhab2/scripts/blind_control.py -t " + i.stateDescription.pattern + " -c move_target -a " + triggeringItem.state)
            executeCommandLine("sudo python /etc/openhab2/scripts/blind_control.py -t " + i.stateDescription.pattern  + " -c move_target -a " + triggeringItem.state, 5000)
            j = j + 1
        }
    ]
...

thanks

It seems the issue resolved itself by restarting the RPi (maybe the bluettoth device had a hickup while testing) - Sry for bothering you guys.

You are aware that you are going to exexcute this 3 times for each item
You don’t need the while loop because the forEach is doing that for you:

    // Execute command on selected blind
    gRolloMAC.members.filter[ i | i.name == macItem ].forEach[ i | 
        // logInfo("TEST", "sudo python /etc/openhab2/scripts/blind_control.py -t " + i.stateDescription.pattern + " -c move_target -a " + triggeringItem.state)
        executeCommandLine("sudo python /etc/openhab2/scripts/blind_control.py -t " + i.stateDescription.pattern  + " -c move_target -a " + triggeringItem.state, 5000)
    ]

Should work

Thanks for your quick answer - and yes, I´am aware of that.

I took this approach from another post (Smart Shades and OpenHAB) - where was said, that this could be helpful if you encounter problems with the reliability of the command - which I had. (maybe it has something to do with a poor BT connection or the implementation on the used device itself?!)