@Sim209 Here’s roughly what I think may be happening in this scenario (and possibly also in your other scenarios):
- The script asks the lamp to set itself to 1 brightness.
- The lamp then processes that set-brightness command.
- The script then asks the lamp, “What’s your current brightness?”
- At this point, the lamp should reply to the script with “I’m at 1 brightness”—because that’s what the lamp’s brightness should be if it had actually processed that set-brightness command—but instead the lamp replies with “I’m at 0 brightness.”
- So from there, the script exits early because it thinks that the lamp had been turned off.
The way that lamps typically work in steps 1 and 2 is that they accept the set-brightness command, and then the script doesn’t continue until that set-brightness command has been applied.
But for some reason, when your particular lamp gets to step 2, the lamp seems to be saying to the script “All good—I’ve processed that set-brightness command!” even though it hasn’t actually processed that set-brightness command just yet. And—sure enough—when the script gets to step 3 where it checks whether the lamp is at 0 brightness (off), the lamp is indeed still at 0 brightness.
I’m not really sure why your lamp might be acting as if it had processed that set-brightness command (in step 2) when it actuality it hadn’t yet processed that set-brightness command.
Perhaps it may be that the lamp isn’t able to process set-brightness commands all that quickly, and perhaps the lamp might be pretending to have processed that set-brightness command so as to appear snappier than it might actually be?
I don’t have much solid advice here, but if indeed your lamp might not be able to process set-brightness commands from the script all that quickly, you could perhaps try increasing the script’s Minimum delay per step parameter to try to ensure that the lamp isn’t being sent set-brightness commands faster than the lamp can handle?
And as that goes, I believe that the Minimum delay per step parameter’s default value is 100 ms, but you might potentially try something like 200 ms or 250 ms. Or maybe even as high as 500 ms? (And if you do, I’d be most curious to hear how things might turn out!)