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