I don’t have much experience with Groovy, but I wrote a device type for Somfy shades. These shades support three commands: UP, DOWN, and MY/STOP. If the shades are moving, the MY/STOP command is interpreted as STOP. If the shades are stopped, the MY/STOP command moves the shades to a preset “MY” level.
As you can probably guess, ON raises the shades and OFF lowers the shades — but implementing MY/STOP wasn’t obvious. To make this command work with SmartTiles, remotes, modes, etc. I used the dim level:
if (level >= 75) UP else if (level <= 25) DOWN else MY/STOP
Unfortunately this logic doesn’t work well with Routines. If I set a Routine to “dim” the shades to 50%, it doesn’t just send a MY/STOP command. It sends an ON command then a MY/STOP command. So instead of moving the shades to the preset level, the shades move up slightly and then stop.
How should I change my code to fix this problem? I’ve come up with some workarounds, but none of them are ideal.