Bump ring-client-api 13.0.0-beta.2

Implement FCMv1 push changes

Fixes for new notification v2 format

Revert to upstream ring-client-api

Use upstream ring-client-api

Fix timestamp for notification v2 format

Fix incorrect timestamp property

Bump ring-client-api

Drop milliseconds from ding timestamp
This commit is contained in:
Tom Sightler
2024-06-20 17:57:57 -04:00
parent 3b249ecb70
commit c672a5554e
5 changed files with 170 additions and 1407 deletions

View File

@@ -485,19 +485,17 @@ export default class Camera extends RingPolledDevice {
async processNotification(pushData) {
let dingKind
// Is it a motion or doorbell ding? (for others we do nothing)
switch (pushData.action) {
case 'com.ring.push.HANDLE_NEW_DING':
switch (pushData.android_config?.category) {
case 'com.ring.pn.live-event.ding':
dingKind = 'ding'
break
case 'com.ring.push.HANDLE_NEW_motion':
case 'com.ring.pn.live-event.motion':
dingKind = 'motion'
break
default:
this.debug(`Received push notification of unknown type ${pushData.action}`)
return
}
const ding = pushData.ding
ding.created_at = Math.floor(Date.now()/1000)
this.debug(`Received ${dingKind} push notification, expires in ${this.data[dingKind].duration} seconds`)
// Is this a new Ding or refresh of active ding?
@@ -505,19 +503,19 @@ export default class Camera extends RingPolledDevice {
this.data[dingKind].active_ding = true
// Update last_ding and expire time
this.data[dingKind].last_ding = ding.created_at
this.data[dingKind].last_ding_time = utils.getISOTime(ding.created_at*1000)
this.data[dingKind].last_ding = Math.floor(pushData.data?.event?.eventito?.timestamp/1000)
this.data[dingKind].last_ding_time = pushData.data?.event?.ding?.created_at
this.data[dingKind].last_ding_expires = this.data[dingKind].last_ding+this.data[dingKind].duration
// If motion ding and snapshots on motion are enabled, publish a new snapshot
if (dingKind === 'motion') {
this.data[dingKind].is_person = Boolean(ding.detection_type === 'human')
this.data[dingKind].is_person = Boolean(pushData.data?.event?.ding?.detection_type === 'human')
if (this.data.snapshot.motion) {
this.refreshSnapshot('motion', ding.image_uuid)
this.refreshSnapshot('motion', pushData?.img?.snapshot_uuid)
}
} else if (this.data.snapshot.ding) {
// If doorbell press and snapshots on ding are enabled, publish a new snapshot
this.refreshSnapshot('ding', ding.image_uuid)
this.refreshSnapshot('ding', pushData?.img?.snapshot_uuid)
}
// Publish MQTT active sensor state

View File

@@ -1,5 +1,5 @@
import RingSocketDevice from './base-socket-device.js'
import { allAlarmStates, RingDeviceType } from 'ring-client-api'
import { allAlarmStates } from 'ring-client-api'
import utils from '../lib/utils.js'
import state from '../lib/state.js'

View File

@@ -12,11 +12,11 @@ async function getRefreshToken(systemId) {
let generatedToken
const email = await requestInput('Email: ')
const password = await requestInput('Password: ')
const restClient = new RingRestClient({
email,
password,
const restClient = new RingRestClient({
email,
password,
controlCenterDisplayName: `ring-mqtt-${systemId.slice(-5)}`,
systemId: systemId
systemId: systemId
})
try {
await restClient.getCurrentAuth()
@@ -28,7 +28,7 @@ async function getRefreshToken(systemId) {
}
}
while(!generatedToken) {
while(!generatedToken) {
const code = await requestInput('2FA Code: ')
try {
generatedToken = await restClient.getAuth(code)
@@ -43,11 +43,11 @@ const main = async() => {
let refresh_token
let stateData = {}
// If running in Docker set state file path as appropriate
const stateFile = (fs.existsSync('/etc/cont-init.d/ring-mqtt.sh'))
const stateFile = (fs.existsSync('/etc/cont-init.d/ring-mqtt.sh'))
? '/data/ring-state.json'
: dirname(fileURLToPath(new URL(import.meta.url)))+'/ring-state.json'
const configFile = (fs.existsSync('/etc/cont-init.d/ring-mqtt.sh'))
const configFile = (fs.existsSync('/etc/cont-init.d/ring-mqtt.sh'))
? '/data/config.json'
: dirname(fileURLToPath(new URL(import.meta.url)))+'/config.json'

1537
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{
"name": "ring-mqtt",
"version": "5.6.7",
"version": "5.7.0-dev",
"type": "module",
"description": "Ring Devices via MQTT",
"main": "ring-mqtt.js",
@@ -15,7 +15,7 @@
"js-yaml": "^4.1.0",
"minimist": "^1.2.8",
"mqtt": "^5.7.0",
"ring-client-api": "12.1.1",
"ring-client-api": "13.0.0-beta.2",
"rxjs": "^7.8.1",
"werift": "^0.19.3",
"write-file-atomic": "^5.0.1"