Launch scene when Shelly key event fired but only if light was off

Hi all!
First of all, sorry for my poor English…
I’m trying to launch a scene when my Shelly’s input button is pressed, but I want to activate it only when the corresponding light’s previous state was off.
I created an automation based on shelly.click event, but it is obviously launched every time I toggle the switch and not only when starting from “light off” condition. I can’t manage it using binary input sensor as the physical switch is configured as toggle. So I added a condition to check light status, but it randomly fails as action is not sync’d (sometimes the light is fired after condition check, sometimes is still off).
Any suggestion to overcome it?
Thank you in advance for your suggestions :slight_smile: