Pavion
(Pavion)
June 28, 2022, 4:04pm
1
Hello fellow developers!
I’ve got an issue with my bundle Synology Surveillance Station Binding and the latest 3.3.0-STABLE
There is a config parameter, defined as integer :
with its corresponding group:
Normally I’m parsing this value using:
int streamId = Integer.parseInt(thing.getConfiguration().get("snapshot-stream-id").toString());
If I’m looking into
\userdata\jsondb\org.openhab.core.thing.Thing.json
I see my parameter properly set:
This value stays persisted upon OH restart.
Until 3.3.0RC it worked as intended, now I’m observing a different behavior.
The creation of this Thing seems to work as intended, json file looks proper…
but after OH restart all entries are changed into decimal values:
As expected, it causes an exception upon parsing:
java.lang.NumberFormatException: For input string: “1.0”
Now I could use Float.parseFloat instead or try/catch this error but it’s a dirty solution and I’m still wondering how could it be possible and whether it’s a bug or a feature
Thanks in advance!
Pav
1 Like
Lolodomo
(Lolodomo)
June 28, 2022, 5:46pm
2
@J-N-K : could I in relation yo that PR?
main ← J-N-K:bug-fixconfigvalidation
opened 05:10PM - 21 Jun 22 UTC
Reported on the forum. The problem is that on deserialization 255 is deserialize… d to a `BigDecimal` without scale. The validation the fails because the `BigDecimal` is converted to a `255.0` string, which is not equal to the `255` string from the config description option. The value is now properly normalized.
Signed-off-by: Jan N. Klug <github@klug.nrw>
This is the omly recent one related to config parameters.
1 Like
J-N-K
(Jan N. Klug)
July 2, 2022, 3:31pm
3
No, this is just the same root cause which I fixed for the validation. I proposed Normalize thing configuration before initialization by J-N-K · Pull Request #3024 · openhab/openhab-core · GitHub . But parsing configuration in that way should be avoided in any case. I believe if you define a configuration class and use .as on the configuration, you will not run into trouble.
2 Likes
system
(system)
Closed
August 13, 2022, 7:32am
4
This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.