j0ta29 / esphome

ESPHome is a system to control your ESP8266/ESP32 by simple yet powerful configuration files and control them remotely through Home Automation systems.
https://esphome.io/
Other
6 stars 2 forks source link

Missing decimal readings #10

Closed rorso closed 4 months ago

rorso commented 4 months ago

I finally got a version running with my Vitocal 333 :-D

However, I seem to miss the decimal readings of temperatures, although they show up in the log.

[00:22:21][D][OptolinkSensorBase:105]: Datapoint optolink - Boiler Temperatur oben: 48.500000
[00:22:22][D][sensor:094]: 'Boiler Temperatur oben': Sending state 48.50000 °C with 0 decimals of accuracy

Instead I get flipping numbers between 48.0 and 49.0. It does not help, if I configure the display precision to "xx,x", as obviously the decimal is dropped deeper in the program.

The key probably is the with 0 decimals of accuracy, as the idea of having a divider by 10 for an integer return IS to create a decimal.

My sensor setting for this example is:

  - platform: optolink
    name: Boiler Temperatur oben
    address: 0x010D
    bytes: 2
    div_ratio: 10
    unit_of_measurement: °C
    device_class: temperature

image

I confess, I occasionally do miss something obvious, but usually the problem is the reverse, i.e. to get rid of a bunch of excess decimals. Do I have to state the data type "float" somewhere within the optolink sensor definition?

j0ta29 commented 4 months ago

Try

 accuracy_decimals: 1 

It's an attribute of https://esphome.io/components/sensor/

rorso commented 4 months ago

Thank you. I will try that later this evening.

I did override "the default" via the property setting, as the "sensor" docs state that this is only a display suggestion and does not affect the internally stored precision.

accuracy_decimals (Optional, int): Manually set the number of decimals to use when reporting values. This does not impact the actual value reported to Home Assistant, it just sets the number of decimals to use when displaying it.

If however, the component does read this optional setting from the sensor definition to adjust the stored value - then setting it there will make a difference.

image

rorso commented 4 months ago

Perfect!

[22:34:47][D][sensor:094]: 'Vorlauf HK1': Sending state 29.20000 °C with 1 decimals of accuracy