MCPcopy Create free account
hub / github.com/dgreif/ring / constructor

Method constructor

packages/ring-client-api/location.ts:139–204  ·  view source on GitHub ↗
(
    locationDetails: UserLocation,
    cameras: RingCamera[],
    chimes: RingChime[],
    intercoms: RingIntercom[],
    options: {
      hasHubs: boolean
      hasAlarmBaseStation: boolean
      locationModePollingSeconds?: number
    },
    restClient: RingRestClient,
  )

Source from the content-addressed store, hash-verified

137 private restClient
138
139 constructor(
140 locationDetails: UserLocation,
141 cameras: RingCamera[],
142 chimes: RingChime[],
143 intercoms: RingIntercom[],
144 options: {
145 hasHubs: boolean
146 hasAlarmBaseStation: boolean
147 locationModePollingSeconds?: number
148 },
149 restClient: RingRestClient,
150 ) {
151 super()
152
153 this.locationDetails = locationDetails
154 this.cameras = cameras
155 this.chimes = chimes
156 this.intercoms = intercoms
157 this.options = options
158 this.restClient = restClient
159 this.hasHubs = this.options.hasHubs
160 this.hasAlarmBaseStation = this.options.hasAlarmBaseStation
161
162 this.addSubscriptions(
163 // start listening for devices immediately
164 this.onDevices.subscribe(),
165
166 // watch for sessions to come online
167 this.onSessionInfo.subscribe((sessions) => {
168 sessions.forEach(({ connectionStatus, assetUuid }) => {
169 const assetWasOffline = this.offlineAssets.includes(assetUuid),
170 asset = this.assets && this.assets.find((x) => x.uuid === assetUuid)
171
172 if (!asset) {
173 // we don't know about this asset, so don't worry about it
174 return
175 }
176
177 if (connectionStatus === 'online') {
178 if (assetWasOffline) {
179 this.requestList(deviceListMessageType, assetUuid).catch(() => {})
180 this.offlineAssets = this.offlineAssets.filter(
181 (id) => id !== assetUuid,
182 )
183 logInfo(`Ring ${asset.kind} ${assetUuid} has come back online`)
184 }
185 } else if (!assetWasOffline) {
186 logError(
187 `Ring ${asset.kind} ${assetUuid} is offline or on cellular backup. Waiting for status to change`,
188 )
189 this.offlineAssets.push(assetUuid)
190 }
191 })
192 }),
193 )
194
195 if (!options.hasAlarmBaseStation && options.locationModePollingSeconds) {
196 this.addSubscriptions(

Callers

nothing calls this directly

Calls 5

requestListMethod · 0.95
getLocationModeMethod · 0.95
logInfoFunction · 0.90
logErrorFunction · 0.90
addSubscriptionsMethod · 0.80

Tested by

no test coverage detected