Blockly returns string instead of number?

I’m on OH 4.3.0.

It seems to me as if Blockly returns a String where a Number is expected - but maybe I’m wrong.

The following items are used:

DateTime    MAWeatherID_Zuletztgesehen         { channel="exec:command:mobilealertsAPI:output"[profile="transform:JSONPATH", function="$.devices[0].measurement.c", sourceFormat="%s"], stateDescription=""[pattern="%1$td.%1$tm.%1$tY, %1$tH:%1$tM:%1$tS"] }
Number MAWeatherIDTimestamp_Zuletztgesehen_Age      { unit="min", stateDescription=""[pattern="%.0f min"]}

Why don’t the following blocks provide a Number?
Number vs string 3

Log:

2025-01-02 15:26:01.370 [INFO ] [script.ui.test_blockly_logic_numbers] - Rule fired ...
2025-01-02 15:26:01.378 [INFO ] [script.ui.test_blockly_logic_numbers] - 1
2025-01-02 15:26:01.390 [INFO ] [script.ui.test_blockly_logic_numbers] - 1.0
2025-01-02 15:26:01.390 [INFO ] [script.ui.test_blockly_logic_numbers] - false
2025-01-02 15:26:01.391 [INFO ] [script.ui.test_blockly_logic_numbers] - 1
2025-01-02 15:26:01.391 [INFO ] [script.ui.test_blockly_logic_numbers] - false
2025-01-02 15:26:01.397 [INFO ] [script.ui.test_blockly_logic_numbers] - false

The following screenshot shows that the decimal point is white - I think it should be in the same color as the numbers to be recognized as a number… I think, in this case there shouldn’t be any decimal point at all.
Number vs string 1

Is this a bug or am I doing something wrong?

The Blockly blocks are all based on the JSScripting javascript. In this environment, a basic call to get an item’s state always returns the stringified version of the state regardless of the item type. Specific item types have additional options for getting the state in other variable types. In this case, if you want the numeric state of your item, the more general Get [ X ] of item block has a “numeric state” option:
image

2 Likes

A big Thank You for your response - especially for providing the relevant background info: