Skip to content
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

ble-pasv-mqtt-gw.js not correctly reporting negative temperatures for xiaomi devices #88

Open
ghost opened this issue Feb 10, 2024 · 3 comments

Comments

@ghost
Copy link

ghost commented Feb 10, 2024

Negative temperatures are not reported correctly. -8.8c (might not be exact as the temperature fluctuates a bit) is reported as 6544.8c

To Reproduce
Simply place the xiaomi sensor in an environment with negative temperatures (in celcius) and check the mqqt output

Expected behavior
Expected to see negative temperatures reported in MQTT. Both mqqt reports (the one with only temperature and the one with temperature & humidity) are incorrect.

As long as it's still cold enough here I can easily test any fixes.

@ghost
Copy link
Author

ghost commented Feb 10, 2024

Fixed it (I think), changed

  else if(fmt[pos] === 'H') {
    res[keyArr[pos]] = le ? this.getUInt16LE() : this.getUInt16BE();
  }

to

  else if(fmt[pos] === 'H') {
    res[keyArr[pos]] = le ? this.getInt16LE() : this.getInt16BE();
  }

@sdrsdr
Copy link
Member

sdrsdr commented Feb 12, 2024

getUInt16LE implies Unsigned integer so no negative values are possible. Changing to getInt16BE will allow for negative values so if the data looks ok it should be a valid solution

@pytekmobile
Copy link
Contributor

Should be fixed with #92. The fix posted by ghost will fix the temperature values but destroys other fields like soil, humidity, … which expect an unsigned value.

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

No branches or pull requests

2 participants