@@ -20,11 +20,7 @@ import {
2020 PeripheralDeviceType ,
2121} from '@sofie-automation/shared-lib/dist/peripheralDevice/peripheralDeviceAPI'
2222import { protectString } from '@sofie-automation/shared-lib/dist/lib/protectedString'
23- import {
24- PeripheralDeviceCommandId ,
25- PeripheralDeviceId ,
26- StudioId ,
27- } from '@sofie-automation/shared-lib/dist/core/model/Ids'
23+ import { PeripheralDeviceCommandId , StudioId } from '@sofie-automation/shared-lib/dist/core/model/Ids'
2824import { StatusCode } from '@sofie-automation/shared-lib/dist/lib/status'
2925import { PeripheralDeviceCommand } from '@sofie-automation/shared-lib/dist/core/model/PeripheralDeviceCommand'
3026import { LiveStatusGatewayConfig } from './generated/options'
@@ -152,8 +148,9 @@ export class CoreHandler {
152148 }
153149 // setup observers
154150 const observer = this . core . observe ( PeripheralDevicePubSubCollectionsNames . peripheralDeviceForDevice )
155- observer . added = ( id ) => this . onDeviceChanged ( id )
156- observer . changed = ( id ) => this . onDeviceChanged ( id )
151+ observer . added = ( ) => this . onDeviceChanged ( )
152+ observer . changed = ( ) => this . onDeviceChanged ( )
153+ this . onDeviceChanged ( ) // set initial settings
157154 this . setupObserverForPeripheralDeviceCommands ( this )
158155 }
159156 async destroy ( ) : Promise < void > {
@@ -193,13 +190,16 @@ export class CoreHandler {
193190 this . _onConnected = fcn
194191 }
195192
196- onDeviceChanged ( id : PeripheralDeviceId ) : void {
197- if ( id !== this . core . deviceId ) return
193+ onDeviceChanged ( ) : void {
198194 const col = this . core . getCollection ( PeripheralDevicePubSubCollectionsNames . peripheralDeviceForDevice )
199195 if ( ! col ) throw new Error ( 'collection "peripheralDeviceForDevice" not found!' )
200- const device = col . findOne ( id )
201196
202- this . deviceSettings = device ?. deviceSettings || { }
197+ const device = col . findOne ( this . core . deviceId )
198+ if ( ! device ) {
199+ throw new Error ( `No "peripheralDeviceForDevice" with id "${ this . core . deviceId } " found!` )
200+ }
201+
202+ this . deviceSettings = device . deviceSettings || { }
203203 const logLevel = this . deviceSettings [ 'debugLogging' ] ? 'debug' : 'info'
204204 if ( logLevel !== this . logger . level ) {
205205 this . logger . level = logLevel
@@ -211,7 +211,7 @@ export class CoreHandler {
211211 this . logger . info ( 'Loglevel: ' + this . logger . level )
212212 }
213213
214- const studioId = device ? .studioId
214+ const studioId = device . studioId
215215 if ( studioId === undefined ) {
216216 throw new Error ( `Live status gateway must be attached to a studio` )
217217 }
0 commit comments