Is there a simple way to toggle STATE in script for switching?

Hi

I would like to toggle the state of a switch by pushing the same position again. pushing first time -> on
pushing second time -> off

I have the following scripted:
pushing channel 1 short -> on
pushing channel 2 short -> off

is there a simple way to query the state and feed it back with inversion as new state?

cheers
Jipp

<?php
$hg = new \Homegear\Homegear();

$hg->addEvent(
	array(
		"ID" => "Felix, Decke on",
		"TYPE" => 0,
		"ENABLED" => true,
		"PEERID" => 11,
		"PEERCHANNEL" => 1,
		"VARIABLE" => "PRESS_SHORT",
		"TRIGGER" => 8,
		"TRIGGERVALUE" => true,
		"EVENTMETHOD" => "setValue",
		"EVENTMETHODPARAMS" => Array(12, 1, "STATE", true)
	)
);

$hg->addEvent(
	array(
		"ID" => "Felix, Decke off",
		"TYPE" => 0,
		"ENABLED" => true,
		"PEERID" => 11,
		"PEERCHANNEL" => 2,
		"VARIABLE" => "PRESS_SHORT",
		"TRIGGER" => 8,
		"TRIGGERVALUE" => true,
		"EVENTMETHOD" => "setValue",
		"EVENTMETHODPARAMS" => Array(12, 1, "STATE", false)
	)
);

Just use setValue(<peer ID>, <channel>, "STATE", "!"). The ! toggles a boolean value.

Hi

I tried it and works like a charm:

$hg->addEvent(
array(
"TYPE" => 0, 
"ID" => "Remote 1", 
"PEERID" => 6, 
"PEERCHANNEL" => 2, 
"VARIABLE" => "PRESS_SHORT", 
"TRIGGER" => 8, 
"TRIGGERVALUE" => true, 
"EVENTMETHOD" => "setValue", 
"EVENTMETHODPARAMS" => Array(2, 1, "STATE", "!")));