In OH2 I’m using the FritzBox binding to control my DECT 200 device.
Items definition to get the energy Information from the DECT 200 device:
Number Verbrauch “abs. Verbrauch [%.0f Wh]” (Daten_Pumpe) {channel=“avmfritz:FRITZ_DECT_200:69e04e20:087610053251:energy”}
I detected, that the formatting string is actually cutting of the three last digits. Thus making out of a float value an integer, because the number received from the cannel is posting a dot as grouping separator.
Example:
2017-01-02 19:55:03.403 [ItemStateChangedEvent ] - Leistung changed from 49.130 to 0.000
2017-01-02 19:56:18.399 [ItemStateChangedEvent ] - Verbrauch changed from 507.214 to 507.215
The first value is the actual power consumption and reflects a float value. The energy value is actually an integer. But the dot is handled as decimal point, not as a group separator.
Now, knowing about this issue and using the DecimalType.intValue cast, will remove the digits past the point, because the value for energy appears as float although it is not.
Example:
Events.log entry:
2017-01-02 13:52:15.667 [ItemStateChangedEvent ] - Verbrauch changed from 507.061 to 507.063
openhab.log entry:
2017-01-02 13:50:00.088 [INFO ] [me.model.script.leistungsdaten.rules] - Aktuell bei Einschalten:507
Anyone seen the same issue?
My circumvention, instead of using
akt_verbrauch = (Verbrauch.state as DecimalType).intValue
and loosing the three digits, I calculate
akt_verbrauch = (Verbrauch.state as DecimalType).floatValue * 1000
and in further handling I can savely use
akt_verbrauch.intValue