Display precision in settings is only for HA front end, it will never effect the actual state. You need to do that with a round() filter and set the precison in what ever template you’re using to for your email and app alerts. Something like…
What precision and type is the variable for the distance sensor in your code that generates the data? The yaml code for your SR04T?
Check in your debug code.
You are not going to get an improvement in precision by converting it to another type.
As the value of a state in HA it’s always a string, so if you want to change it’s precision when sending the value via notify or what ever it needs to become a float (which is what the device is supplying anyways before it becomes an HA sensor state). round(1) does this without having to mess with the device firmware.
Rick, thank you for mentioning the Round(1) function - app messages and emailed texts are coming through with selected precision … except when the sensor reading is unavailable from the ESP32 due to loss of Wifi communications. At those times no message is sent and this error is raised:
Is there any way to trap that error and send the ‘unavailable’ status?
IOT7712 - the decimals:1 and round: 3 are being applied to the measurement in meters which then gets multiplied by -100 to convert to xy.z cm below the floor and 33 is then added to compensate for the height of the sensor above the floor.
The sensor readings have been looking really good.
HA’s has_value() test/filter will check if the sensor has a valid value (aka not unavailable or unknown), you can catch it with something like…
{% if has_value('sensor.esphome_01_jsn_sr04t_distance') %}
{{ states('sensor.esphome_01_jsn_sr04t_distance') | round(1) }}
{% else %}
The distance is currently {{ states('sensor.esphome_01_jsn_sr04t_distance') }}, apologies for the inconvenience.
{% endif %}
# or
{{ states('sensor.esphome_01_jsn_sr04t_distance') | round(1) if has_value('sensor.esphome_01_jsn_sr04t_distance')
else states('sensor.esphome_01_jsn_sr04t_distance') }}