Hi,
I migrated all my rules DSL files to JSScripting UI rules. But this simple one doesn’t work in JS:
rules DSL:
gHmReloadVariables.members.forEach [ GenericItem item | sendCommand(item, REFRESH) ]
JS:
items.getItem('gHmReloadVariables').members.forEach(function (item) { item.sendCommand('REFRESH');});
The JS result is that the items in Openhab have the value “REFRESH” and not the real value of Homematic.
The documentation just says:
In Scripts:
import org.openhab.core.types.RefreshType
...
Var_1.sendCommand(RefreshType.REFRESH)
How can I use this RefreshType.REFRESH in JS Scripts?
rlkoshak
(Rich Koshak)
2
These are String Items?
If not it’s not clear what’s happening here. This might be a bug that needs to be fixed.
As a work around you can fall back to the raw API instead of using openhab-js for this.
var { RefreshType, events } = require('@runtime');
events.sendCommand('ItemName', RefreshType.REFRESH);
Something like this should work.
unfortunately that doesn’t work.
But I got it working with this solution:
var refreshType = Java.type('org.openhab.core.types.RefreshType');
items.getItem('xy').sendCommand(refreshType.REFRESH);});
Update for OH4: this doesn’t work anymore, the item’s value is always REFRESH - I went back to rules DSL and it is working fine