@@ -15,11 +15,7 @@ import {
1515 PeripheralDeviceType ,
1616} from '@sofie-automation/shared-lib/dist/peripheralDevice/peripheralDeviceAPI'
1717import { protectString } from '@sofie-automation/shared-lib/dist/lib/protectedString'
18- import {
19- PeripheralDeviceCommandId ,
20- PeripheralDeviceId ,
21- StudioId ,
22- } from '@sofie-automation/shared-lib/dist/core/model/Ids'
18+ import { PeripheralDeviceCommandId , StudioId } from '@sofie-automation/shared-lib/dist/core/model/Ids'
2319import { StatusCode } from '@sofie-automation/shared-lib/dist/lib/status'
2420import { PeripheralDeviceCommand } from '@sofie-automation/shared-lib/dist/core/model/PeripheralDeviceCommand'
2521import { LiveStatusGatewayConfig } from './generated/options'
@@ -137,8 +133,9 @@ export class CoreHandler {
137133 }
138134 // setup observers
139135 const observer = this . core . observe ( PeripheralDevicePubSubCollectionsNames . peripheralDeviceForDevice )
140- observer . added = ( id ) => this . onDeviceChanged ( id )
141- observer . changed = ( id ) => this . onDeviceChanged ( id )
136+ observer . added = ( ) => this . onDeviceChanged ( )
137+ observer . changed = ( ) => this . onDeviceChanged ( )
138+ this . onDeviceChanged ( ) // set initial settings
142139 this . setupObserverForPeripheralDeviceCommands ( this )
143140 }
144141 async destroy ( ) : Promise < void > {
@@ -178,15 +175,18 @@ export class CoreHandler {
178175 this . _onConnected = fcn
179176 }
180177
181- onDeviceChanged ( id : PeripheralDeviceId ) : void {
182- if ( id !== this . core . deviceId ) return
178+ onDeviceChanged ( ) : void {
183179 const col = this . core . getCollection < PeripheralDeviceForDevice > (
184180 PeripheralDevicePubSubCollectionsNames . peripheralDeviceForDevice
185181 )
186182 if ( ! col ) throw new Error ( 'collection "peripheralDeviceForDevice" not found!' )
187- const device = col . findOne ( id )
188183
189- this . deviceSettings = device ?. deviceSettings || { }
184+ const device = col . findOne ( this . core . deviceId )
185+ if ( ! device ) {
186+ throw new Error ( `No "peripheralDeviceForDevice" with id "${ this . core . deviceId } " found!` )
187+ }
188+
189+ this . deviceSettings = device . deviceSettings || { }
190190 const logLevel = this . deviceSettings [ 'debugLogging' ] ? 'debug' : 'info'
191191 if ( logLevel !== this . logger . level ) {
192192 this . logger . level = logLevel
@@ -198,7 +198,7 @@ export class CoreHandler {
198198 this . logger . info ( 'Loglevel: ' + this . logger . level )
199199 }
200200
201- const studioId = device ? .studioId
201+ const studioId = device . studioId
202202 if ( studioId === undefined ) {
203203 throw new Error ( `Live status gateway must be attached to a studio` )
204204 }
0 commit comments