-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Adds calibration offsets for tilt on DJT11LM sensor #6622
Conversation
c2c8690
to
9a7e67c
Compare
the DJT11LM seems to be very poorly calibrated, * provide raw accelerometer values : raw_x, raw_y and raw_z used for calibration after calibration can be removed from the payload by adding "raw_[xyz]" to "filtered_attributes" of the devices * allows a simple offset based calibration went from 15° to a few degrees off
9a7e67c
to
5745255
Compare
src/converters/fromZigbee.ts
Outdated
// raw accelrometer values | ||
result.raw_x=x; | ||
result.raw_y=y; | ||
result.raw_z=z; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why would you still want to have the raw
values if you have the calibrated ones?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is the only way I found to get the raw values for doing the actual calibration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But you already have the raw values before doing any calibration?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do have the raw values, but right now, they are not available to users, we use them as is to compute and expose angles.
In order to know what offset to set, we need a way for the user to get the values when the sensor is on a level surface to compensate the values
(eg sensor flat I get "raw_x":60,"raw_y":-13,"raw_z":-704, => I set in the options the offset for x to -60, y to 13
with the sensor on one side : I get "raw_x":-942,"raw_y":-11,"raw_z":225, => offset for z ~ -225 )
so to reiterate as a user in order to find the offsets I need the raw values one way or another
To do an automated calibration witout the raw values, we would have to ask the user to put the device on 2 perpendicular faces, and wait for the values to update between each change, then compute the offsets for each axis and push them in the config or somewhere else, but not sure how to approach this tbh
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in the latest iteration, renamed the raw_x
to x_axis
to follow the other accelerometer sensors .
and expose the calibrated values
src/converters/fromZigbee.ts
Outdated
// simple offset calibration | ||
x=calibrateAndPrecisionRoundOptions(x, options, 'raw_x'); | ||
y=calibrateAndPrecisionRoundOptions(y, options, 'raw_y'); | ||
z=calibrateAndPrecisionRoundOptions(z, options, 'raw_z'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's better to call the options x
(no raw_
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looking at other accelerometer based sensors I see we have a set of x,y,z_axis that are exposed
using https://github.com/Koenkk/zigbee-herdsman-converters/blob/v16.0.2/src/lib/exposes.ts#L760
such as https://github.com/Koenkk/zigbee-herdsman-converters/blob/v16.0.2/src/devices/third_reality.ts#L228
Do you prefer me do rename and expose them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh sorry you were talking about the option name
yes I can rename (the question for the raw values is still valid though)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please rename
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
renamed the option
I think It might be confusing as they are offsets for the accelerometer underlying /raw values, not the exposed angle_x y z that are computed...
Note to self; after this merge Koenkk/zigbee2mqtt.io#2375 |
rename raw_x,y,z options to x,y,z moved options definition to the converter
rename raw_x, raw_y, raw_z to x_axis, y_axis, z_axis expose the *calibrated* accelerometer values
Thanks! |
the DJT11LM seems to be very poorly calibrated,
one sensor went from ~15° to a few degrees off
will update the documentation on how to calibrate,
but in a nutshell:
put the sensor on a flat surface, set the offset for x and y to the opposite of raw_x and raw_y
put the sensor on its side, do the same thing for z