Battery level not updating in HA with Z-wave JS

For me 1 sensor is working correctly for battery level , but the other 2 are always 100%

image

i use an automation , 1 a day ““Z-Wave JS: Refresh value(s) of a Z-Wave entity”” for each zwave sensor

Hi,

I cannot add much here, apart from stating i have the same problems.
I added the update scripts as described above, but I am not sure how I should verify if they have actually been executed or run.
My setup:

  • z-wave js
  • zawave js addon
  • Z‐Stick Gen5 USB Controller

So, for some it seems to work ( since they give a value other than ‘0’ or ‘100’), but I am not sure of they are actually updating.

  • Some devices are fine, others stay at 100%
  • note that it is both one Heiman Smoke detector HS1SA-Z, as well as one Fibaro smoke sensor that shows 100%
  • I am also suspicious of the 97 % value of another Heiman HS1SA-Z, since I bought all of these devices more than 2 year s ago…

What I think is interesting/strange is that some devices work, and others don’t. I assume this somehow has to do with the way the messages are queued while waiting for the devices to come up, in combination with the status of the z-wave network.

Best,

Alexander.

Thanks! I did this and then manually ran it and fairly soon my motion sensor went from 0% to 100% which had been irritating me given i’d put a new battery in it.

Same problem. Added an automation that calls refresh_value every night, but the following devices always show 100% battery level:

  • Vision Security Tilt Sensor ZG8101
  • Ecolink DWZWAVE25 Open/Close Sensor
  • Ecolink motion sensor

Same problem, “refresh_value” doesn’t resolve with sensors:

  • FGMS001
  • PD03Z
  • SP814
  • PSP05
  • PST02A

Here’s a template that reports when the device sends the battery level, this way you can differentiate between the device not reporting and the device sending. It’s likely that some devices just have a poor electronics for sensing battery level…

template:
  - trigger:
      - platform: zwave_js.value_updated
        entity_id:
          - sensor.garage_door_1_battery_level
        command_class: 128
        property: level
    sensor:
      - name: "garage_door_1_battery_last_updated"
        state: "{{ now() }} "

recorder:
  include:
    entities:
      - sensor.garage_door_1_battery_last_updated

I have seen all the discussion on this but am still unable to get the battery level updated unless I remove the battery from the device. In this particular case, it’s an Ecolink PIR motion sensor.
I created the recommended automation to using zwave_js.refresh_value. I would have expected to be able to wake up the device by walking in front of it and then this would cause the battery level to be updated (after the automation runs) This doesn’t seem to work. I also added a call to this service in the automation that is activated when this motion sensor goes off. This also doesn’t update the battery level.
I’m stumped.

Your expectation is incorrect, it doesn’t work that way. A “wake up” event is distinct from the device detecting motion or reporting something else. When the device wakes up, it’s in a high power mode listening for commands, and this occurs either on a (usually) programmable interval (i.e. the wake up interval setting) or when you physically perform some action on the device, like pushing the inclusion button. The entity refresh will only occur during this “wake up”, not when reporting.

There are two versions of the Ecolink PIR. According to both manuals (1 2), you wake up the device by opening and then closing the cover.

Thanks, this is really helpful. I’m relatively new to zwave so I’m not super familiar with the details.

So, it looks like if I run this automation and then just let the devices wake up on their own, I should get battery levels updated. Would you agree? I started running the automation a couple of days ago and as of this morning, I hadn’t seen any updated values. Perhaps the default wake up interval for this sensor is longer than this. I have two other battery operated sensors (Zooz leak detectors) and the instructions say the default is 12 hours. I just installed these so I would kind of expect them to show 100% battery.

I guess I can wait a bit longer to see if the battery level changes…

1 Like

If you use the template I posted above it will capture the timestamp of when the battery updates. Since it may just update to the same value It previously had, this is the only way to know it is working.

Thanks. Yeah, I saw that template earlier but, being totally unfamiliar with templates, I skipped past it :). This morning, I added what you posted to configuration.yaml, editing the name of the entity of course. This was the right place to put it, right?
I restarted HA, manually ran my automation that does the value refresh, then removed and replaced the battery of the motion sensor. The “updated” entity created by the template is still “unknown”. I guess this implies that the template code didn’t work or didn’t get triggered. I’m not sure how to debug this.
Also, a very wacky thing happened…
Last night, after messing with this motion sensor, I was able to see the battery level updated to 61% (from 100%). This morning, the level is back to 100%. My refresh values automation ran at midnight. I can only assume the value was updated as a result of this but I’m puzzled as to why it’s back to 100%. This motion detector has been operating for close to two years. There’s no way the battery is at 100% :).

Edit/Update: I played more with this sensor, running my refresh automation then opening the sensor case (not removing the battery). I am able to see the battery level change sometimes. It sometimes shows 99%, other times 100%. So, I think this means that the refresh is actually working.
My conclusion is that the sensor thinks that the battery level is 99%. It’s really surprising because, as I said, the sensor has been in operation for almost 2 years. It probably gets triggered 20-30 times a day. I have read that some battery operated devices don’t have very good circuits for battery level detection. Maybe this is the case here. Or, maybe the battery really is at 99%.

Also, I checked the voltage of the battery. Nominal voltage for this type is listed as 3.2-3.3V. My battery measured 2.97V. It seems odd to report this as 99% capacity. On the other hand, it’s interesting that 99% of 3.0V is 2.97V :).

Regarding the template, it still doesn’t seem to be working.

Building a good battery tester takes a bunch of circuitry to do it well. So I think most vendor do a poor job here. For example, look at this chart. I’ve determine the battery circuit is influenced by ambient temperature, but it certainly seems to be waning.

I use that template for all my battery devices. It maybe in your configuration.yaml you already have a template section and may need to combine this in there.

Thanks again.
As for the template, I didn’t already have a template section. Regardless, this discussion has motivated me to dig into templates :). I found a video tutorial and also found the template editor. I’ll play around with that and see how far I get.

Still messing with this… :slight_smile:

Does any of this debug info help explain why the template isn’t working?
This is a trace from when I remove the cover to when I put it back on. Prior to removing it, I sent the value refresh to the motion sensor.


2023-01-30T03:57:11.819Z DRIVER « [Node 027] [REQ] [ApplicationCommand]
└─[NotificationCCReport]
notification type: Home Security
notification status: 255
notification state: Tampering, product cover removed
2023-01-30T03:57:34.610Z DRIVER « [Node 027] [REQ] [ApplicationCommand]
└─[WakeUpCCWakeUpNotification]
2023-01-30T03:57:34.614Z CNTRLR « [Node 027] received wakeup notification
2023-01-30T03:57:34.616Z CNTRLR [Node 027] The node is now awake.
2023-01-30T03:57:34.632Z DRIVER » [Node 027] [REQ] [SendData]
│ transmit options: 0x25
│ callback id: 121
└─[BatteryCCGet]
2023-01-30T03:57:34.643Z DRIVER « [RES] [SendData]
was sent: true
2023-01-30T03:57:34.890Z DRIVER « [Node 027] [REQ] [ApplicationCommand]
└─[WakeUpCCWakeUpNotification]
2023-01-30T03:57:34.896Z CNTRLR « [Node 027] received wakeup notification
2023-01-30T03:57:37.579Z DRIVER « [REQ] [SendData]
callback id: 121
transmit status: OK
2023-01-30T03:57:37.675Z DRIVER « [Node 027] [REQ] [ApplicationCommand]
└─[BatteryCCReport]
level: 99
is low: false
2023-01-30T03:57:38.686Z CNTRLR » [Node 027] Sending node back to sleep…
2023-01-30T03:57:38.709Z DRIVER » [Node 027] [REQ] [SendData]
│ transmit options: 0x24
│ callback id: 0
└─[WakeUpCCNoMoreInformation]
2023-01-30T03:57:38.717Z DRIVER « [RES] [SendData]
was sent: true
2023-01-30T03:57:38.727Z CNTRLR [Node 027] The node is now asleep.

Update:
For some unexplained reason, this template worked a few times. The only thing I did this morning was to update home assistant core. After this, I saw an update time from the template. However, I now can’t get it to update again, despite opening and closing the cover :). The log always shows the value update happening. So weird…

Update #2:
Ok, the mystery may have been solved :).
In the automation that does the refresh value, I was not checking the “Refresh all values” option. I played a little with this option yesterday but saw some odd behavior of the motion sensor, so I unchecked it. I’m guessing that one of the refresh operations got to the device when this option was checked, which caused the template to work as intended.
The way this option is described, it’s hard to tell what it does. I did try to find more info about it on this forum but couldn’t find a clear description. This is what it says:
“Whether to refresh all values (true) or just the primary value (false)”
I thought that the primary value would be the one I was trying to refresh. I only specified one in my automation.
I still don’t understand what this option does, but it seems to be required for the template to show me the last time the battery level was updated.
Hopefully this is the last post I will make to this thread. But, I guess time will tell :).

Hi, Did this topic ever get properly resolved? I still can’t get updating battery levels from any of my many battery devices. Even though I have tried most of the suggestions here. Most devices say they have updated the battery level 3 hours/ 4 hours/ 5 minutes ago but they never change significantly. One smoke detector with new batteries some times change from 35.000000000000000 to 34.999444444444440.

Any suggestions welcome particularly using Nod-Red if possible.

1 Like