-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inconsistant distance unit for vl53l0x distance sensor #17021
Comments
The sensor payload only has units included for values where you have an option to select what unit you want, like C/F. But yeah, as things are now, Tasmota does not have options to bridge the difference in what default units the drivers are using. Simplest might be an option |
https://github.com/arendst/Tasmota/blob/development/tasmota/tasmota_xdrv_driver/xdrv_12_home_assistant.ino#L49 |
As of today, only 1 unit of a given physical value can be pushed and there is no consensus if a distance driver should use either mm or km as either are valid depending on the use case It could be easy to modify VL53Lxx and SR04 drivers to include a Unit in their respective payload but that would not mean that HA would be able to take it into account without improvement in the HaTasmota plugin. |
https://github.com/emontnemery/hatasmota/blob/master/hatasmota/sensor.py#L116 |
Why not change all distance drivers to cm. Makes it a breaking change with regards to values for some drivers but then it's standard on all of them. I'm in favour. |
I'm also sympathetic towards a standard distance unit to be used, like cm. Maybe the unit of mm should only be for rain then, where a couple of sensors are using it. As we do have C/F selection for temperature, someone may want something similar for distance in cm/inch 😀 |
I'll start checking the impact on changing all D_JSON_DISTANCE values to cm now. EDIT: first scan shows VL53L0x, VL53L1x, AS3935 and TOF10120 are affected. |
Nooooo, noooooo What next? Gallons? |
We settle for ISO. So cm it is. |
Redesign distance sensors HRXL and DYP to use cm instead of mm (#17021)
Since those two drivers are still using uint variables (instead of float), and a divide by 10 was added, looks like the resolution is now worse, no longer able to report distance differences less than 1 cm. |
Correct. The datasheets for both sensors even mentions that distances below 30 cm need to disregarded! I don't think distances below 1cm make any sense at all. |
But you triggered another issue. I'll change to float adding the decimal resolution. |
Yeah, that was what I meant 😄 |
Redesign distance sensors VL53LXX, TOF10120, HRXL and DYP to use cm instead of mm (#17021)
@heligan pls try latest dev release and report back. |
PROBLEM DESCRIPTION
I am using a vl53l0x distance sensor with latest tamota firmware (12.2). However, I noticed an issue when the sensor data is published to home assistant. Basically the tasmota web UI shows
xxx mm
while the data published to HA says
xxx cm
(10x larger).I did check some of the tasmota code. It seems the auto discover part uses
cm
by default:https://github.com/arendst/Tasmota/blob/development/tasmota/tasmota_xdrv_driver/xdrv_12_home_assistant.ino#L49
however, different distance sensor code uses their own interpretation of the value. e.g. vl53l0x uses a
uint16_t
to represent a mm-based distancehttps://github.com/arendst/Tasmota/blob/development/tasmota/tasmota_xsns_sensor/xsns_45_vl53l0x.ino#L79
SR04 sensor translates the raw data into a
float
-value to represent a cm-based distancehttps://github.com/arendst/Tasmota/blob/development/tasmota/tasmota_xsns_sensor/xsns_22_sr04.ino#L45
Not sure how this confusion populates into later stages (e.g. web UI or mqtt or HA) but this definitely shows up when it gets published to HA side. I can see temperature sensors usually have a temp unit attached but it doesn't seem to be the same with distance sensors.
Any idea how to address this issue?
REQUESTED INFORMATION
Make sure your have performed every step and checked the applicable boxes before submitting your issue. Thank you!
Backlog Template; Module; GPIO 255
:Backlog Rule1; Rule2; Rule3
:Status 0
:weblog
to 4 and then, when you experience your issue, provide the output of the Console log:TO REPRODUCE
Steps to reproduce the behavior:
just try a vl53l0x sensor and publish the data to home assistant.
EXPECTED BEHAVIOUR
A clear and concise description of what you expected to happen.
They should use the same unit.
SCREENSHOTS
If applicable, add screenshots to help explain your problem.
see description.
ADDITIONAL CONTEXT
Add any other context about the problem here.
(Please, remember to close the issue when the problem has been addressed)
The text was updated successfully, but these errors were encountered: