I’m not too deep into homematic, but one thing that might help you in general:
If you want to modify a variable that has an Action assigned (e.g. can be switched in the web frontend) the method of choice is RequestAction()
It provides a nice abstraction, so you do not need to fiddle with the details of each HW module type.
So if your Homematic device has a variable STATE that can be switched on and off the way to do this via RequestAction() is:
$varIdState = 12345; // The object ID of the STATE variable
// turn on
$resultOn = RequestAction($varIdState, true);
// turn off
$resultOff = RequestAction($varIdState, false);
It works with all kind of variables, not just switches:
$varIdIntensity = 12346; // The object ID of the Intensity variable of a dimmer
// dim to 20%
$resultDim = RequestAction($varIdIntensity, 20);
I only fall back to the native functions if I really need some hw specific, granular control (e.g. the DimSetEx fuction of Z-Wave).