-
Notifications
You must be signed in to change notification settings - Fork 529
Update DDF for Aqara TVOC sensor #6162
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
Conversation
Interesting, does this apply to all Xiaomi devices? I'd prefer to have this in a separate .js file then, similar to Tuya version parsing in let b = Attr.val.toString(16);
c = [0,2].map(function(o) {if (b.length % 2) {b = '0' + b} return b.slice(o,o+2)});
f = parseInt(c[1], 16).toString();
x = ''; for (i = 0; i < (f.length % 4); i++) {x += '0'};
Item.val = '0.0.0_' + x + f;Do you have an example what the input number for the version is and to what string it is converted? |
|
This definitively seems to apply for the newer Xiaomi devices, however, some break out of the pattern and my use 0x0d (iirc, this was the case for the wired H1 switch family). E.g., the H1 switch ws-euk04 sends 0x0B0C (2838) before a firmware upgrade, Xiaomi app showed FW version 0.0.0_0022. In essence, the script takes the least significant Byte, checks how many 0s are required to have a length of 4 (in above example 0022) and constructs the version string. I guess, the script could also be rewritten a bit. Happy to move it to a seperate file. |
|
@manup Code is now moved to seperate js file |
|
Thanks looks better :) I've just merged the standard https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/padStart |
|
Yup, that indeed works 🙂 |
Update includes:
state/airquality, as the device reports it via attribute 0x0129 on the 0xfcc0 cluster. The applicable scale is the one of the WHOattr/swversion. Recent discovery is that item 0x08 of the Xiaomi special reporting holds the true firmware version (also displayed and confirmed by the Xiaomi App). In rare cases, it can also be item 0x0d on different devicesattr/modelidis recieved. This usually happens when the device button is pressed (it does mac poll then, should be standard for all Xiaomi battery powered devices)state/airqualityppb. Some people mentioned reporting would eventually stop otherwise. Has been tested for more than 10 days and reports were still coming in, the actual value hasn't changed much though