JSScripting send command REFRESH to Homematic variables does not work


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) ]


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

How can I use this RefreshType.REFRESH in JS Scripts?

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');