Skip to content

Conversation

@SwoopX
Copy link
Collaborator

@SwoopX SwoopX commented Jul 2, 2022

Update includes:

  • Promote DDF to Gold status
  • Change processing of state/airquality, as the device reports it via attribute 0x0129 on the 0xfcc0 cluster. The applicable scale is the one of the WHO
  • Change attr/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 devices
  • Consider the device as awake, when attr/modelid is recieved. This usually happens when the device button is pressed (it does mac poll then, should be standard for all Xiaomi battery powered devices)
  • Set a binding and attribute reporting for 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

@SwoopX SwoopX added this to the v2.18.0-beta milestone Jul 2, 2022
@SwoopX SwoopX requested review from ebaauw and manup July 2, 2022 15:00
@SwoopX SwoopX marked this pull request as ready for review July 5, 2022 21:00
@manup
Copy link
Member

manup commented Jul 6, 2022

Change attr/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 devices

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 devices/tuya/tuya_swversion.js. I don't really understand what the JS does here? :)

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?

@SwoopX
Copy link
Collaborator Author

SwoopX commented Jul 7, 2022

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.
After FW upgrade, the device sends 0x0B0D (2839), which is 0.0.0_0023. Confirmed all that with the TVOC sensor, the FP1 and the H1 switch (though it is index 0x0d here).

I guess, the script could also be rewritten a bit. Happy to move it to a seperate file.

@SwoopX
Copy link
Collaborator Author

SwoopX commented Jul 9, 2022

@manup Code is now moved to seperate js file

@manup
Copy link
Member

manup commented Jul 10, 2022

Thanks looks better :)

I've just merged the standard String.padStart polyfill in PR #6186, which might be handy here to simplify the padding of strings.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/padStart

let v = "123";

v = v.padStart(6, "0");

// v == "000123"

@SwoopX
Copy link
Collaborator Author

SwoopX commented Jul 10, 2022

Yup, that indeed works 🙂

@manup manup merged commit 6021842 into dresden-elektronik:master Jul 10, 2022
@SwoopX SwoopX deleted the aqaratvoc branch October 30, 2022 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants