Bugs in Snapshot 4.0.0

Hi,

I’m finding a few bugs and wondering if anyone knows anything about them before I submit issues on gitub.

1. time.Duration

      const timerDuration = items.getItem('BackHall_Ceiling_Light_MotionTimer').state // A Number Item

      console.info(time.Duration.ofSeconds(1))
      console.info(time.Duration.ofMinutes(1))

      console.info(time.Duration.ofSeconds(timerDuration))

give me PT1S, PT1M, and PT1S respectively.

But

console.info(time.Duration.ofMinutes(timerDuration))

throws an error:

ArithmeticException: Multiplication overflows: 1 * 60: ArithmeticException: Multiplication overflows: 1 * 60

and ofHours says something similar:

ArithmeticException: Multiplication overflows: 1 * 3600: ArithmeticException: Multiplication overflows: 1 * 3600

only ‘ofSeconds’ seems to work.

2. things.getThings() .setLabel
When I change a thing’s label with JS Scripting, it works, but doesn’t stick after a reboot.

things.getThing('test:thing:45636344247:62464367').setLabel('A New Label')

3. items.replaceItem
With JS Scripting, if I set the giBaseType to ‘String’, it doesn’t apply this to the new item. Other base types and aggregation functions work fine.

items.replaceItem({
        type: 'Group',
        name: 'Item_Name',
        label: 'Item Label',
        groups: ['group1', 'group2'],
        tags: ['Setpoint'],
        category: 'lightbulb',
        giBaseType: 'Switch'
        //  groupFunction: aggregationFunction
    });

4. Applying metadata
When I apply metadata (any kind) using JS scripting, it works, but the UI displays ‘Not Set’

let itemToEdit = items.getItem('Test_Item);
itemToEdit.replaceMetadata('stateDescription', '', { options: 'ON=MOTION,OFF=NO MOTION'} );

5. material icons
I can apply a material icon and it works in most places.
image

but it shows as blank in a default list widget

Am I doing something wrong? Seems unusual to find 5 bugs in a row

Please post to openHAB 4.0 SNAPSHOT discussion where the 4.0 SNAPSHOT problems are discussed.

Note that timerDuration in this case is a String. The .state is always a String. You might need to parse it to a Number first.

But in any case, this is 100% implemented in the joda-js library so any issue would need to be filed and corrected there. It’s not an OH problem.

How is the Thing defined? In a text file or through the UI?

What use case would have you changing the label of a Thing?

Note, this code is not correct (missing a closing ’ on the first line).

Which version of openhab-js are you using? The metadata was completely reworked in the latest release.

Show the full config from the “Code” tab.

You are testing the 4.0 SNAPSHOT. Tons of breaking changes are being introduced with almost every build. Welcome to the bleeding edge.

I moved this to the post you suggested