Blocky Script challenges

Tags: #<Tag:0x00007f17326854c0> #<Tag:0x00007f17326853d0> #<Tag:0x00007f1732685268>
  • Platform information:
    • Hardware: X86/16G_
    • OS: _Win10
    • Java Runtime Environment: OpenJDK Client VM Zulu11.43+55-CA (build 11.0.9.1+1-LTS, mixed mode)
    • openHAB version:OH3
  • Issue of the topic: Getting value of Item
  • Please post configurations (if applicable):
    • Items configuration
      image

    • Sitemap configuration related to the issue:not relevant

    • Rules code related to the issue:No rules

    • Services configuration related to the issue

  • If logs where generated please post these here using code fences:

So I’m creating this small script with hysteresis to control temperature in my outdoors fridge (Keeping it from freezing)
image
Might not be the optimal approach, but that is not so important at this point.
It didn’t seem to work, so I attempted playing a bit with print statements:
image
Which gave some result:
image
Third statement is working…, although strange characters are printed after the 27.7

Problem is the “IF” statement wont accept the “get item state” (shown to the right) to be dropped on it.

And if it did allow, I’d probably face issues with the “degC” which the graphic characters probably represent.
Somewhere it’s how to specify float compare not string compare.
What am I missing in this picture?

PS
Wonder what the idea with the first print statement
‘’‘print item(ogs04_FridgeTemp)’’ printing exactly the same is?

PPS
Where is the “Code” button in blocky, as it would be a great way to start JavaScript programming, getting syntax and item names fully right.

Thanks

This is a known issue. Assign the get item state to a variable first and you can drop the variable into the if statement. For some reason it will only let you use get item state in an if block when it’s being compared to a String.

That implies that your Item is a Number:Temperature which probably means that Blockly isn’t going to work the way you expect in all cases. I don’t think it supports QuantityTypes yet.

Should be in the upper right corner but it won’t appear until you save it. You might need to back out to the overall rule first.