-
-
Notifications
You must be signed in to change notification settings - Fork 429
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
The "equals" condition does not work for the items storing dimensionless number values #2624
Comments
I submitted #2653 to solve this. I will allow equals comparison between |
I have to revoke this. We decided in #2653 that we cannot set a |
But what is the solution for the described situation? The item's status is a dimensionless number (a current side number of the cube). What should I write in conditions section instead of "0"? |
Just to make sure - your item state is a dimensionless For the books - even a dimensionless |
No, I would not say you did something wrong. You did something which is possible but not considered in all details. Despite this I would recommend you to use item type |
@cweitkamp, thanks a lot. I changed the item type to |
I created the channel like this and linked it to the item "AqaraSmartHomeCube001_Side".
I added the "But only if" condition to the rule like this:
This condition always returns "false" even state of "AqaraSmartHomeCube001_Side" is equal to 0.
The problem is in the "org.openhab.core.automation.internal.module.handler.ItemStateConditionHandler". Look at the code (version 3.1.x, but i bet the version 3.2 has the same issue):
The "item.getAcceptedDataTypes()" returns "[class org.openhab.core.library.types.DecimalType, class org.openhab.core.library.types.QuantityType, class org.openhab.core.types.UnDefType]". It means the "TypeParser.parseState(item.getAcceptedDataTypes(), state)" returns object of "DecimalType" creating as "DecimalType.valueOf("0")". But the "item.getState()" returns the object of "QuantityType". The "compareState" and "itemState" have different types. and the equation "temState.equals(compareState)" never returns "true".
The safest way to solve it to rewrite the equation like this:
But I think the right path to fix it is to convert the "itemState" to the class of "compareState" before comparing.
I have found a workaround. The condition can be replaced by this couple which works well:
The text was updated successfully, but these errors were encountered: