deconz-rest-plugin icon indicating copy to clipboard operation
deconz-rest-plugin copied to clipboard

Battery life no longer reported for Xiaomi environment sensor (WSDCGQ11LM)

Open jamieshaw opened this issue 3 years ago • 17 comments
trafficstars

Describe the bug

Xiaomi Environmental sensor (WSDCGQ11LM) no longer reports battery after upgrading to deCONZ 2.15. Was working fine in 2.14, potentially attributable to #5990. Other readings including temperature, humidity, and pressure seem fine.

Steps to reproduce the behavior

Behaviour is consistent, and reproducible without steps. My home has 4 of the aforementioned sensors, all 4 report 0% battery.

Expected behavior

Battery capacity should be reported correctly.

Screenshots

N/A

Environment

  • Host system: PC
  • Running method: Ubuntu 18.04 Virtual Machine under ESXi
  • Firmware version: (26720700)
  • deCONZ version: (2.17.01)
  • Device: ConBee II
  • Do you use an USB extension cable: Yes — mains-powered USB 2.0 hub.
  • Is there any other USB or serial devices connected to the host system? Yes — Aeotec Z-Wave 7 stick, bluetooth adapter.

deCONZ Logs

deconz_gui_logs.txt

Additional context

Reopening closed issue (#6027) as is still relevant.

jamieshaw avatar Jul 13 '22 08:07 jamieshaw

I am tempted to close, as this is not compliant to #5113 and you are not on the latest stable. Additionally, i have the same sensor and mine reports the % fine.

I'll ask a dev to check this.

Mimiix avatar Jul 13 '22 12:07 Mimiix

I can confirm I am on the latest, I just copy and pasted my previous ticket as it was closed without any input.

I have four of these sensors, and since updating to the aforementioned version, all four report 0% battery but still output data.

I attempted to re-pair one of the devices this morning to see if it would spur something to life, alas, it did not.

image

jamieshaw avatar Jul 13 '22 16:07 jamieshaw

Mine are all doing fine. How do they look like from an API perspective?

SwoopX avatar Jul 13 '22 18:07 SwoopX

Mine are all doing fine. How do they look like from an API perspective?

As in what is returned via the REST API? Same deal. Home Assistant sees 0% battery, but temperature, pressure, and humidity are returned just fine.

jamieshaw avatar Jul 14 '22 04:07 jamieshaw

Have configured the GUI (I'm running headless) and captured the recommended logs. These have been attached to the original post, if they are of any help.

Feel free to ask away for further debug data if it helps.

Also worth noting that these aren't the latest version of the sensors following the rebranding of Aqara and it's v3 hub. These were purchased several years ago alongside a (then) Mijia Mi Home hub.

image

jamieshaw avatar Jul 14 '22 08:07 jamieshaw

I received the same sensor today and I can confirm that the battery shows 0% on phoscon after pairing. The other values appear to be correct.

Edit: Was too impatient, battery just updated.

KingTomaHawk avatar Jul 15 '22 16:07 KingTomaHawk

I updated to the latest version 2.17.1 and I also do not get a battery percentage. Always reporting 0%. I also repaired the device entirely (delete sensor and created again with 3 new IDs [pressure, temperature,humidity] Nothing could fix the problem, so I downgraded back to 2.14.1. That only could fixed the issue and battery is reporting fine again.

It seems that due to the structureal change to the DDF format, new errors are coming in. Same with motion sensor and lux values. Not working in the newest version.

yamaha1983 avatar Jul 19 '22 06:07 yamaha1983

Not working in the newest version

Not true, here it is working: image

Mimiix avatar Jul 19 '22 06:07 Mimiix

Not working in the newest version

Not true, here it is working:

image

Either way, it clearly is and isn't working for some users, myself included, stemming from a reproducible change in a particular version.

An investigation and fix is definitely required.

jamieshaw avatar Jul 20 '22 05:07 jamieshaw

Yesterday, I reset the lumi.weather sensor connected to my Aqara hub and paired it with my dev/test deCONZ, v2.17.1-beta. This morning, the API shows a value in config.battery alright. The API plugin is using the DDF to expose the sensor. I have set DDF Mode in the Control panel to Basic, with only Gold DDF status enabled.

If you enable DDF in the Debug View, you should see messages like:

Jul 20 07:36:57 pi5 deCONZ[7310]: 07:36:43:123 00:15:8d:00:07:6d:68:12-01-0405/config/battery expression: const vmin = 2700;
Jul 20 07:36:57 pi5 deCONZ[7310]: 07:36:43:154 00:15:8d:00:07:6d:68:12-01-0402/config/battery expression: const vmin = 2700;
Jul 20 07:36:57 pi5 deCONZ[7310]: 07:36:43:184 00:15:8d:00:07:6d:68:12-01-0403/config/battery expression: const vmin = 2700;

every 55-60 minutes (as deCONZ receives the special attribute report form the sensor).

ebaauw avatar Jul 20 '22 06:07 ebaauw

Yesterday, I reset the lumi.weather sensor connected to my Aqara hub and paired it with my dev/test deCONZ, v2.17.1-beta. This morning, the API shows a value in config.battery alright. The API plugin is using the DDF to expose the sensor. I have set DDF Mode in the Control panel to Basic, with only Gold DDF status enabled.

If you enable DDF in the Debug View, you should see messages like:

Jul 20 07:36:57 pi5 deCONZ[7310]: 07:36:43:123 00:15:8d:00:07:6d:68:12-01-0405/config/battery expression: const vmin = 2700;
Jul 20 07:36:57 pi5 deCONZ[7310]: 07:36:43:154 00:15:8d:00:07:6d:68:12-01-0402/config/battery expression: const vmin = 2700;
Jul 20 07:36:57 pi5 deCONZ[7310]: 07:36:43:184 00:15:8d:00:07:6d:68:12-01-0403/config/battery expression: const vmin = 2700;

every 55-60 minutes (as deCONZ receives the special attribute report form the sensor).

I've done just that, and left it running in the background. The following was returned.

16:25:32:258 failed to evaluate expression for 00:15:8d:00:02:d7:7f:c2-01-0405/config/battery: const vmin = 2700;
const vmax = 3000;
let bat = Attr.val;

if      (bat > vmax) { bat = vmax; }
else if (bat < vmin) { bat = vmin; }

bat = ((bat - vmin) /(vmax - vmin)) * 100;

if      (bat > 100) { bat = 100; }
else if (bat <= 0)  { bat = 1; } // ?

Item.val = bat;
, err: SyntaxError: Syntax error
16:25:32:260 failed to evaluate expression for 00:15:8d:00:02:d7:7f:c2-01-0402/config/battery: const vmin = 2700;
const vmax = 3000;
let bat = Attr.val;

if      (bat > vmax) { bat = vmax; }
else if (bat < vmin) { bat = vmin; }

bat = ((bat - vmin) /(vmax - vmin)) * 100;

if      (bat > 100) { bat = 100; }
else if (bat <= 0)  { bat = 1; } // ?

Item.val = bat;
, err: SyntaxError: Syntax error
16:25:32:262 failed to evaluate expression for 00:15:8d:00:02:d7:7f:c2-01-0403/config/battery: const vmin = 2700;
const vmax = 3000;
let bat = Attr.val;

if      (bat > vmax) { bat = vmax; }
else if (bat < vmin) { bat = vmin; }

bat = ((bat - vmin) /(vmax - vmin)) * 100;

if      (bat > 100) { bat = 100; }
else if (bat <= 0)  { bat = 1; } // ?

Item.val = bat;
, err: SyntaxError: Syntax error

jamieshaw avatar Jul 20 '22 15:07 jamieshaw

That looks to be an error in the DDF file, or in the script to translate the battery voltage reported by the sensor to a percentage. What version are you on? What DDF file are you using for the sensor?

ebaauw avatar Jul 20 '22 22:07 ebaauw

That looks to be an error in the DDF file, or in the script to translate the battery voltage reported by the sensor to a percentage. What version are you on? What DDF file are you using for the sensor?

2.17.01 / 01/07/2022

As for the file, not sure about the question, haven't changed anything so should be the default?

jamieshaw avatar Jul 21 '22 03:07 jamieshaw

If you can point me in the right direction of the DDF agile, I'm more than happy to help.

The installation was done through APT on Ubuntu, but haven't touched anything regarding the installation files other than updates through APT.

jamieshaw avatar Jul 24 '22 07:07 jamieshaw

If you can point me in the right direction of the DDF agile, I'm more than happy to help.

You could try this: Open DeCONZ, right-click on the sensor, choose "Edit DDF". This will open the DDF editor in a new window, the title bar will display the name of the DDF. Then click "File" --> "Save as", and a dialog window will show you where the file is located. Then click "Cancel" to avoid changing the DDF.

On my Raspberry Pi, the DDF for your sensor is located here: /usr/share/deCONZ/devices/xiaomi/xiaomi_wsdcgq11lm_temp_hum_press_sensor.json

root@raspberrypi:/# cd /usr/share/deCONZ/devices/xiaomi

root@raspberrypi:/usr/share/deCONZ/devices/xiaomi# grep WSDCGQ11LM *
xiaomi_wsdcgq11lm_temp_hum_press_sensor.json:  "product": "Aqara temp./hum./press. sensor WSDCGQ11LM",

root@raspberrypi:/usr/share/deCONZ/devices/xiaomi# grep "xiaomi_battery.js" xiaomi_wsdcgq11lm_temp_hum_press_sensor.json
          "parse": {"fn": "xiaomi:special", "at": "0xff01", "idx": "0x01", "script": "xiaomi_battery.js"}
          "parse": {"fn": "xiaomi:special", "at": "0xff01", "idx": "0x01", "script": "xiaomi_battery.js"}
          "parse": {"fn": "xiaomi:special", "at": "0xff01", "idx": "0x01", "script": "xiaomi_battery.js"}

root@raspberrypi:/usr/share/deCONZ/devices/xiaomi# cat "xiaomi_battery.js"
const vmin = 2700;
const vmax = 3000;
let bat = Attr.val;

if      (bat > vmax) { bat = vmax; }
else if (bat < vmin) { bat = vmin; }

bat = ((bat - vmin) /(vmax - vmin)) * 100;

if      (bat > 100) { bat = 100; }
else if (bat <= 0)  { bat = 1; } // ?

Item.val = bat;
root@raspberrypi:/usr/share/deCONZ/devices/xiaomi#


bee-con avatar Jul 24 '22 09:07 bee-con

If you can point me in the right direction of the DDF agile, I'm more than happy to help.

You could try this: Open DeCONZ, right-click on the sensor, choose "Edit DDF".

This will open the DDF editor in a new window, the title bar will display the name of the DDF.

Then click "File" --> "Save as", and a dialog window will show you where the file is located.

Then click "Cancel" to avoid changing the DDF.

On my Raspberry Pi, the DDF for your sensor is located here:

/usr/share/deCONZ/devices/xiaomi/xiaomi_wsdcgq11lm_temp_hum_press_sensor.json


root@raspberrypi:/# cd /usr/share/deCONZ/devices/xiaomi



root@raspberrypi:/usr/share/deCONZ/devices/xiaomi# grep WSDCGQ11LM *

xiaomi_wsdcgq11lm_temp_hum_press_sensor.json:  "product": "Aqara temp./hum./press. sensor WSDCGQ11LM",



root@raspberrypi:/usr/share/deCONZ/devices/xiaomi# grep "xiaomi_battery.js" xiaomi_wsdcgq11lm_temp_hum_press_sensor.json

          "parse": {"fn": "xiaomi:special", "at": "0xff01", "idx": "0x01", "script": "xiaomi_battery.js"}

          "parse": {"fn": "xiaomi:special", "at": "0xff01", "idx": "0x01", "script": "xiaomi_battery.js"}

          "parse": {"fn": "xiaomi:special", "at": "0xff01", "idx": "0x01", "script": "xiaomi_battery.js"}



root@raspberrypi:/usr/share/deCONZ/devices/xiaomi# cat "xiaomi_battery.js"

const vmin = 2700;

const vmax = 3000;

let bat = Attr.val;



if      (bat > vmax) { bat = vmax; }

else if (bat < vmin) { bat = vmin; }



bat = ((bat - vmin) /(vmax - vmin)) * 100;



if      (bat > 100) { bat = 100; }

else if (bat <= 0)  { bat = 1; } // ?



Item.val = bat;

root@raspberrypi:/usr/share/deCONZ/devices/xiaomi#





Thanks. Followed this and seeing the same, pretty sure I'm seeing the same file at xiaomi_battery.js.

const vmin = 2700;
const vmax = 3000;
let bat = Attr.val;

if      (bat > vmax) { bat = vmax; }
else if (bat < vmin) { bat = vmin; }

bat = ((bat - vmin) / (vmax - vmin)) * 100;

if      (bat > 100) { bat = 100; }
else if (bat <= 0)  { bat = 1; } // ?

Item.val = bat;

jamieshaw avatar Jul 25 '22 04:07 jamieshaw

Awaiting an update. 🙂

jamieshaw avatar Jul 31 '22 17:07 jamieshaw

Still waiting. Any ETA on a potential fix?

jamieshaw avatar Aug 13 '22 10:08 jamieshaw

So, interestingly, this issue has been resolved… somehow.

I'm currently in the middle of rebuilding the VM that I use for hosting all my home automation stuff, and today, reinstalled deCONZ (same method, via APT), and simply migrated over the zll.db file—Battery is now being reported.

Guessing something went funky during the upgrade process and that the clean install on a new machine remedied this. Just had another dig into the following files, and can confirm both are identical between working and non-working instances. /usr/share/deCONZ/devices/xiaomi/xiaomi_wsdcgq11lm_temp_hum_press_sensor.json /usr/share/deCONZ/devices/xiaomi/xiaomi_battery.js

🤷‍♂️

jamieshaw avatar Aug 17 '22 12:08 jamieshaw

Hm, as good as it is that your issue is resolved through the migration, as unsatisfying it is to still tap in the dark regarding the root cause.

Do you still have the old VM and could compare software packages, qt to be specific?

SwoopX avatar Aug 18 '22 19:08 SwoopX

Hm, as good as it is that your issue is resolved through the migration, as unsatisfying it is to still tap in the dark regarding the root cause.

Do you still have the old VM and could compare software packages, qt to be specific?

I do – just let me know what you wish me to capture and I can provide. 🙂

jamieshaw avatar Aug 19 '22 05:08 jamieshaw

@jamieshaw Riddle's been solved, see the linked issue. Maybe you can share your Qt version there...

SwoopX avatar Sep 10 '22 20:09 SwoopX