Open sjonez opened 10 months ago
I'm pretty sure it's because the code checks for hasBattery()
during startup, but that will only return true if "battery_life" property exist. However, it appears there is either no battery, or a completely dead battery, in slot 1, thus this check returns false and no battery characteristics are registered for the device. If you simply move the battery to slot one and restart the plugin, my guess is it will work.
Realistically, the code should probably check for either "battery_life" or "battery_life_2" and return true if either are present (that is what I do in ring-mqtt), but it's a pretty good corner case as I believe this is only checked during initial startup.
The battery_life property is in there, it just has a value of null.
I'll test swapping the battery to the other slot tomorrow and see if it makes a difference
Ah yes, sorry, missed it, glanced through too quickly. So it's not that it is not registering a battery characteristic, it's that it is reporting the battery value as null because the primary battery is either completely dead or not installed. Looks like it is probably because of getBatteryLevel()
in ring-camera.ts, specifically this:
if (
!levels.length ||
(health && !health.battery_percentage && !health.battery_present)
) {
return null
}
Because there is no battery_percentage or battery_present properties, this function will return null instead of the value from second battery (I believe the goal of this function is to return the highest value from either of two batteries). Should probably add an additional check for !health.second_battery_percentage to this function, then it will return value of second battery even if first is completely dead/removed.
If you modify line 38
in node_modules/ring-client-api/lib/ring-camera.js
and change:
(health && !health.battery_percentage && !health.battery_present)) {
to
(health && !health.battery_percentage && !health.second_battery_percentage && !health.battery_present)) {
Restart and I believe it will work.
If you modify
line 38
innode_modules/ring-client-api/lib/ring-camera.js
and change:
(health && !health.battery_percentage && !health.battery_present)) {
to
(health && !health.battery_percentage && !health.second_battery_percentage && !health.battery_present)) {
Restart and I believe it will work.
It looks like slot 1 of the camera has an issue, the camera won't boot up unless the battery is in slot 2 :(
I made the code change you suggested though and that does indeed fix the problem when there is only a battery in slot 2, thanks!
Great, I'll see about getting a fix into the next version.
Is there an existing issue for this?
Describe The Bug
I'm not seeing any battery data for one of my cameras which is a stickup cam v4. Here's the discovery data:
I think it's because there is no health.battery_percentage or health.battery_present like my other devices, but there is instead health.active_battery
To Reproduce
No response
Expected behavior
Battery reported
Relevant log output
No response
Screenshots
No response
Additional context
No response
OS
Ubuntu
Node.js Version
20.6.1
NPM Version
9.8.1
ring-client-api
12.0.1
Operating System
Ubuntu