frtz13 / UPSPlus_mqtt

GNU General Public License v3.0
19 stars 6 forks source link

multiply in configuration.yaml and output like 1,5250000000000001 A #18

Closed ArjenR49 closed 3 years ago

ArjenR49 commented 3 years ago

I'm sure you have noticed yourself, too, that every so often 'multiply' in the configuration.yaml file leads to a long string of decimals like so: UPS Average Output Current 7 seconden geleden 1,5250000000000001 A

I tried to find a solution, but I wasn't even able to find anything on doing math in the value_template. Actually I have no understanding of those templates or yaml files. I am rather sure js stand for JavaScript, but beyond that I am totally dependent on the internet for examples to mimic ;-)

Before you published the new configuration sample file, I had done conversions from mA to A etc. in the Python script's corresponding function (or is it method?). dictPayload['BatteryCurrent_A'] = '{:.3f}'.format(int(ups.BatteryCurrent_mA)/1000) No conversion quirks because of the formatting applied. I had mimicked that successfully from unknown sources for sure, but the new fashion is beyond me. Do you perhaps have a pointer for finding a remedy?

frtz13 commented 3 years ago

added round(3) to the sensor definitions