Trainer
(Hannes)
1
Hi,
i try to start and stop things via item.
I use OH 4.3.1.
rule "reboot ebus Thing"
when
Item restartEBUS_THING changed
then
var ThingUID = Java.type('org.openhab.core.thing.ThingUID');
if(restartEBUS_THING.state == ON){
thingMgr.setEnabled(new ThingUID('androiddebugbridge:android:1e12b02f269d'), false);
}else{
thingMgr.setEnabled(new ThingUID('androiddebugbridge:android:1e12b02f269d'), true);
}
end
But when i try to execute i got this errormessage.
failed: The name 'Java' cannot be resolved to an item or type;
Do you know maybe why?
Trainer
(Hannes)
3
thank you but do you also know how to use it in *.rule file without Blockly or JS Scripting?
As said in the thread, you can’t use DSL rules for that.
arohleder
(Achim Rohleder)
5
things.getThing(‘bluetooth:goveeHygrometerMonitor:hci0:a4c138b16332’).setEnabled(false)
That’s not DSL, or is it?
sihui
(SiHui)
8
No, but I found (a long time ago) a solution through the REST api in this forum:
enable:
var headers = new java.util.HashMap()
headers.put("Authorization", "Bearer " + "oh.restapi.mbE6fCExxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
sendHttpPutRequest("http://192.168.2.212:8080/rest/things/bsblan:bridge:heating/enable", "text/plain", 'true', headers, 5000)
disable:
var headers = new java.util.HashMap()
headers.put("Authorization", "Bearer " + "oh.restapi.mbE6fCExxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
sendHttpPutRequest("http://192.168.2.212:8080/rest/things/bsblan:bridge:heating/enable", "text/plain", 'false', headers, 5000)
1 Like
Trainer
(Hannes)
9
sometimes it is working sometimes i got this error:
Fatal transport error: java.util.concurrent.TimeoutException: Total timeout 5000 ms elapsed
do you know why i got sometimes this error?
sihui
(SiHui)
10
It looks like your connection isn’t stable if that command works only from time to time …
Trainer
(Hannes)
11
i check it again and it is working for enable the thing but not disable
sihui
(SiHui)
12
Make sure you have the correct syntax: in both cases it is .../enable...
with true
for enable and false
for disable
Trainer
(Hannes)
13
i using the right syntax but i forgot to change the IP Adress. My fault 