Rest api over rules

Hi,
i ve got following problem:

i d like to change the state of an item in another OH instance via the rest api.

here is what i ve got already but it doesnt seem to work:

rule "aslivesend"
when
	Time cron " 1 * * * * ?"
then
	if(helper.state==NULL){
		sendCommand(helper,OFF)
	}
	if(internal.state==NULL){
		sendCommand(internal,OFF)
	}
	logInfo("alive","alive executed state:"+internal.state.toString())
	if(internal.state.toString()=="ON"){
		sendHttpPutRequest("http://172.24.1.153:8080/rest/items/external/state", "text/plain","OFF")
		sendCommand(internal,OFF)
		internal.persist
		logInfo("alive","Alivemessage send to 172.24.1.153 MSG:OFF")
	}
	else if(internal.state.toString()=="OFF"){
		sendHttpPutRequest("http://172.24.1.153:8080/rest/items/external/state", "text/plain","ON")
		sendCommand(internal,ON)
		internal.persist
		logInfo("alive","Alivemessage send to 17.24.1.153 MSG:ON")
	}
end

before you ask me what its supposed to do,

I have 2 instances of OH running at the same time i ve created 3 switch items
1)external
2)internal
3)helper

internal is like a dummy switch i use to toggle
external is supposed to be changed via the rest api
helper is supposed to track if external changed within the last 1minute 30 seconds

so it is basically a crossover changing of items so i can test if the other instance is still running

my question now:

why doesnt the httpput work?

ok so if anybody has an idea the problem occours rather curious to me since i added some logs and it seems that the item change will be executed but the item change of internal never happens so it executes the same thing every time.

new code:

rule "aslivesend"
when
	Time cron " 1 * * * * ?"
then
	if(helper.state==NULL){
		sendCommand(helper,OFF)
	}
	if(internal.state==NULL){
		sendCommand(internal,OFF)
	}
	logInfo("alive","alive executed state:"+internal.state.toString())
	if(internal.state.toString()=="ON"){
		logInfo("alive","internal==ON executed")
		sendHttpPutRequest("http://172.24.1.153:8080/rest/items/external/state", "text/plain","OFF")
		logInfo("alive","HTTPPut executed")
		sendCommand(internal,OFF)
		logInfo("alive","changed internal new state:"+internal.state.toString())
		internal.persist
		logInfo("alive","alive check done executing Alivemessage send to 172.24.1.153 MSG:OFF")
	}
	else if(internal.state.toString()=="OFF"){
		logInfo("alive","internal==OFF executed")
		sendHttpPutRequest("http://172.24.1.153:8080/rest/items/external/state", "text/plain","ON")
		logInfo("alive","HTTPPut executed")
		sendCommand(internal,ON)
		logInfo("alive","changed internal new state:"+internal.state.toString())
		internal.persist
		logInfo("alive","alive check done executingAlivemessage send to 17.24.1.153 MSG:ON")
	}
end

log:

14:34:00.999 [INFO ] [eclipse.smarthome.model.script.alive] - alive executed state:ON
14:34:01.000 [INFO ] [eclipse.smarthome.model.script.alive] - internal==ON executed
14:34:01.011 [INFO ] [eclipse.smarthome.model.script.alive] - HTTPPut executed
14:34:01.012 [INFO ] [eclipse.smarthome.model.script.alive] - changed internal new state:ON
14:34:01.035 [INFO ] [eclipse.smarthome.model.script.alive] - alive check done executing Alivemessage send to 172.24.1.153 MSG:OFF
14:34:01.630 [INFO ] [eclipse.smarthome.model.script.alive] - alive Last Update:2017-08-04T14:33:05.000+02:00
14:35:01.003 [INFO ] [eclipse.smarthome.model.script.alive] - alive executed state:ON
14:35:01.003 [INFO ] [eclipse.smarthome.model.script.alive] - internal==ON executed
14:35:01.003 [INFO ] [eclipse.smarthome.model.script.alive] - HTTPPut executed
14:35:01.003 [INFO ] [eclipse.smarthome.model.script.alive] - changed internal new state:ON
14:35:01.081 [INFO ] [eclipse.smarthome.model.script.alive] - alive check done executing Alivemessage send to 172.24.1.153 MSG:OFF
14:35:01.175 [INFO ] [eclipse.smarthome.model.script.alive] - alive Last Update:2017-08-04T14:34:04.000+02:00

so if anybody has an idea how this can be solved that would be awesome

Couldn’t you do the same thing with the Network binding and get rid of this rule entirely?

Thing:

network:device:otheroh [ hostname="172.24.1.153", port="8080", retry="1", timeout="5000", refreshInterval="60000", use_system_ping="false", dhcplisten="false" ]

This will try to ping hostname on port every 60 seconds and if the host is up and the port open then whatever Switch this gets linked to is set to ON. If the port goes down or the host does off the network the Switch will go to OFF.

Well didnt know that possibility exists, so if i understand this right the item would look like :

Switch network:device:otheroh [ hostname="172.24.1.153", port="8080", retry="1", timeout="5000", refreshInterval="60000", use_system_ping="false", dhcplisten="false" ]

and then i’d only need a rule that notifies me when the itemstate changes to OFF?

-----------------edit-------------------------

nvm i looked up in the docs found the way to define

thank you for the help anyway