Suddenly not getting dings #1566
-
I've worked on an app that uses the library pretty much all day and in the first hours, I always got dings that I triggered. But at some point, they must've just stopped working. I went back to my first experimental script (and added import { readFile, writeFile } from "node:fs/promises";
import { PushNotificationAction, RingApi } from "ring-client-api";
const refreshToken = await readFile("refreshtoken", "utf8");
const ringApi = new RingApi({
refreshToken,
debug: true,
});
const allCameras = await ringApi.getCameras();
ringApi.onRefreshTokenUpdated.subscribe(({ newRefreshToken }) => {
void writeFile("refreshToken", newRefreshToken);
});
allCameras.forEach((camera) => {
console.log(`Found camera: ${camera.name}`);
camera.onBatteryLevel.subscribe((batteryLevel) => {
console.log("Battery level " + batteryLevel);
});
camera.onNewNotification.subscribe((notification) => {
const action = notification.android_config.category;
const event =
action === PushNotificationAction.Motion
? "Motion detected"
: action === PushNotificationAction.Ding
? "Doorbell pressed"
: `Video started (${action})`;
console.log(
`${event} on ${camera.name} camera. Ding id ${
notification.data.event.ding.id
}. Received at ${new Date()}`,
);
});
camera.onDoorbellPressed.subscribe(
({
data: {
event: {
ding: { created_at },
},
},
}) => {
console.log(
`Doorbell pressed on ${camera.name} // ` +
new Date(created_at).toLocaleString() +
" // " +
new Date().toLocaleString(),
);
},
);
});
console.log("Listening for doorbell presses."); Nothing. I tried everything mentioned in the wiki about Notification Troubleshooting, without success. I live in Austria, so NL server is probably fine. (Logging the camera name and battery level still works.) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 11 replies
-
It sounds like perhaps you did not follow all details about handling refresh tokens as, without this, push notifications will fail after initial success. |
Beta Was this translation helpful? Give feedback.
It sounds like perhaps you did not follow all details about handling refresh tokens as, without this, push notifications will fail after initial success.