I tried also to use/test scripts.
I found actually no compatibility to oh1 at all.
I use an item file with a Switch item “item1” and sone others
Here my current findings…
I use this action script inside of a timer rule:
print (“Timer >>> START”);
print (“things:”);
var thxs = things.getAll();
print(thxs);
for each (var thx in thxs) {
// enumerating properties don't work: for each (var el in thx) print(el);
print ("Label=" + thx.getLabel());
print ("Channels");
for(var channel in thx.getChannels()) {
print (channel);
}
}
print (“Items”);
print (items);
try {
for each (var item in items.keySet()) {
print (item);
}
} catch (ex) { print (ex.message); }
try {
print (“try to get ‘item1’:”);
// don’t work!!!
// gets the state of the item, but not the item itself
//
var item = items.get(“item1”);
print (item);
} catch (ex) { print (ex.message); }
// don’t work …
try {
print (“Send command to item1 - A”);
events.sendCommand (“item1”, “ON”);
} catch (ex) { print (ex.message); }
// don’t work …
try {
print (“Send command to item1 - B”);
events.sendCommand (“item1”, “OPEN”);
} catch (ex) { print (ex.message); }
// don’t work …
try {
print (“Send command to item1 - C”);
events.sendCommand (“item1”, OPEN);
} catch (ex) { print (ex.message); }
// print (“rules:”);
// print(rules);
// don’t work
//print (“tigger:”);
//print(trigger); //.event);
// ok
print (ON);
print (OFF);
print (“Timer >>> END”);
====================
I found the defininition of the globals for the script like “items” “ON” “OFF” etc in: DefaultScriptScopeProvider.java
The members of an item in: ItemRegistryDelegate.java
The members of a thing in: ThingImpl.java
“Events.sendCommand etc” in: ScriptBusEvent.java
So far rules/scripts seem to work only very basic.
Any additional infos or tips how to evaluate the possibilities of scripts are welcome.
For my oh1 mini scene/sequence manager I personaly need most:
** Fully Access to the itemsRegistry (enumerate items with pattern etc).
** Creation of Timers with callbacks
** send/postCommand