I have an ESPHome configuration with several sensors, and I’m running into some strange rounding issues.
I hope someone can point me in the right direction. What is the correct way?
The value of id(gw_registers)[42] is 236, and I want to display it as 23.6. In Home Assistant this seems to work correctly, but when I look under state in the developer tools, I see 23.6000003814697.

// Temperature
float inverter_temp = id(gw_registers)[42]; // / 10.0;
id(sensor_inverter_temp).publish_state(inverter_temp);
I’ve tried dividing the value within the float and inside the sensor itself, but it still shows the long number in the state.
sensor:
- platform: template
device_class: temperature
state_class: measurement
name: "Temperature"
id: sensor_inverter_temp
unit_of_measurement: °C
entity_category: diagnostic
accuracy_decimals: 1
filters:
- round: 1
- platform: template
name: "Temperature"
id: sensor_inverter_temp
unit_of_measurement: °C
entity_category: diagnostic
accuracy_decimals: 1
filters:
- lambda: |-
return roundf(x / 10.0 * 10.0) / 10.0;
