Skip to content
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

DecimalType: Parsing floats with a lowercase "e" separating mantissa and exponent fails #3833

Closed
abbe79 opened this issue Oct 7, 2023 · 1 comment · Fixed by #3834
Closed
Labels
bug An unexpected problem or unintended behavior of the Core

Comments

@abbe79
Copy link

abbe79 commented Oct 7, 2023

Hi,
using stable 3.3 I get following entry in my log file when my PV inverter sends really small wattage values at night:

Incoming payload '5.605193857299268e-45' not supported by type 'NumberValue'

Seems like NumberValue/DecimalType/Number does not like the lowercase "e", separating mantissa and exponent.

Using an uppercase "E" (-> 5.605193857299268E-45) works.

While I could work around this using a transformation, I think others could fall in this trap too, because this is the notation that is used by C++ (and probably other languages too), see https://cplusplus.com/reference/ios/scientific/

Could this be changed to accept both notations? Thanks!

Expected Behavior

Float value 5.605193857299268e-45 should be parsed correctly to the "close to zero" value.
Using an uppercase E works as intended.

Current Behavior

Parsing fails and item is not updated. Log entry is:
2022-09-08 20:51:01.336 [WARN ] [ab.binding.mqtt.generic.ChannelState] - Incoming payload '5.605193857299268e-45' not supported by type 'NumberValue'

Possible Solution

Accept "e" and "E".

Steps to Reproduce (for Bugs)

In my case: Send 5.605193857299268e-45 to an mqtt number channel.

Your Environment

  • Version used: openHAB 3.3
@abbe79 abbe79 added the bug An unexpected problem or unintended behavior of the Core label Oct 7, 2023
@abbe79
Copy link
Author

abbe79 commented Oct 7, 2023

Also reported here: openhab/openhab-addons#13371

@abbe79 abbe79 changed the title NumberValue: Parsing floats with a lowercase "e" separating mantissa and exponent fails DecimalType: Parsing floats with a lowercase "e" separating mantissa and exponent fails Oct 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An unexpected problem or unintended behavior of the Core
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant