-
-
Notifications
You must be signed in to change notification settings - Fork 243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Blockly handles comparison differently when taken from state directly or from intermediate variable #836
Comments
I have researched the problem myself. Basically the reason is because it is converted to Javascript and comparison works well if
In the case a String (containing a number) is compared with a Number then Javascript converts the String into a Number and the comparison works. So the reason why it works above in the first case is actually not the reason that is assigned to a variable but because the comparison is done agains a number. Also see discussion here: https://community.openhab.org/t/extending-blockly-with-new-openhab-commands/127169/202 |
Nevertheless there is the mentioned workarround and a reasonable explanation it is not intuitive and should be fixed some day ;) |
I agree totally we just don't yet know what would be the best approach on how to fix it. |
@ghys What if we would add a block that would always return a number for a given state (stripping off any trailing metric string after a number). We could
|
@florian-h05 I would say that this will be fixed with openhab/openhab-js#201 , correct? |
@stefan-hoehn As far as I have understand the issue correctly, the problem here is that the state is type of a Java object. Anyway, the introduction of UoM support will solve problems with comparison. So yes, this will be fixed. |
Can you add this to openhab/openhab-js#201 this here it will be automatically closed with 201? |
I’ll add it to both Quantity PRs, not sure which one will get merged but I’d guess the second one 👍 |
@stefan-hoehn Can you please close this issue? openhab/openhab-js#206 has been merged, I guess that it did not close this issue because I have no write access to the webui repo. |
The problem
See more details in thread https://community.openhab.org/t/solved-how-to-convert-state-string-to-number-in-blockly/113933/4
Expected behavior
It is expected that a state value of type number can be directly compared against a number without intermediate assignment to a variable which to me even though working rather looks like a hack 😄
Steps to reproduce
Your environment
Openhab 3.0.0
The text was updated successfully, but these errors were encountered: