Fibaro Dimmer 2 Unlink Actuator from Dimmer

Hi,
Bear with me - I am at the very start of using openhab2.
I would like to have different results depending on when the Switch (S1) ist pressed.
I have a test rule which fades out the lights slowly, when S1 is pressed.
I use the Scene to tell openhab that S1 was pressed and I let the rule check the dimmer state to know whether the light was turned on or off. Then it fades.

var int percent = 0
var Timer fade_Timer = null
rule "test scene"
when
	Item zwave_device_zwave_usb_node4_scene_number received update 16 //or whatever numbers your device is creating
 then
 	if (zwave_device_zwave_usb_node4_switch_dimmer.state==0)
 	{
 	logInfo("File", "Bad Licht AN geschaltet")
	}
	else
	{ 	(zwave_device_zwave_usb_node4_switch_dimmer.state instanceof DecimalType) {
        percent = ((zwave_device_zwave_usb_node4_switch_dimmer.state as DecimalType)/5).intValue * 5 //round to 5
        fade_Timer = createTimer(now.plusMillis(500)) [|
            zwave_device_zwave_usb_node4_switch_dimmer.sendCommand(percent)
            if (percent > 0) {
                percent = percent - 5
                fade_Timer.reschedule(now.plusMillis(500))
            }
        ]
    logInfo("File", "Bad Licht AUS geschaltet")
    
    }
	
		
	}	
	
end

It somewhat works BUT when I press S1 to turn off, the light turns off,immidiately on again and THEN fades out. I guess that is because S1 directly tells the Dimmer2 to switch off and only after that openhab kicks in. Quite a useful behaviour because that way the switch also works when openhab failed or is turned off. But it is not desirable in my case.
So what do I do? Is there some change in the parameter or do I have to use a completely different Actuator?
Thanks for helping me out here.

else
	{
    if (zwave_device_zwave_usb_node4_switch_dimmer.state instanceof DecimalType) {
        

At a glance, I saw you’re missing an IF ?

If you send an OFF command, then yes, it will turn off first. Then your rule kicks in.

Thanks to @sihui I managed to add a channel which sends the ON or OFF status.

rule "DimmerSwitchReadout"
when
	Item ZwaveFibaroDimmerBad_Switch changed 
then
 if (ZwaveFibaroDimmerBad_Switch.state==ON) {
 	logInfo("File", "Bad Licht AN geschaltet")
	}
	else{
		       
    logInfo("File", "Bad Licht AUS geschaltet")
    }
 end 

That gives me a reliable readout. But the problem somewhat remains. S1 directly sends the ON command to the relais which turns on the light.
I could set the Default brightness to “1” (I think thats parameter 19)
That way when I press S1 the dimmer turns on to 1 - so lowest brightnes level. and then my rule kicks in.
I couldn’t think of a way to unlink S1 with the dimmer other than this workarround.

My goal would actually be the following:
I press S1
A “S1 switched to ON” is send to openhab
Now I can execute a rule which turns on the dimmer to a brightness according to my rule.
You guys see what I’m aiming at?

In case anyone else runs into a similar problem - I set Parameter 19 to 1, which forces the Fibaro Dimmer 2 to set Dimmer intensity to 1 when switched on shortly after that my rule kicks in, which then sets the light to the correct brightness.