import { AirPurifier } from "./airPurifier" ; import { Blind } from "./blind" ; import { DeviceInfo } from "./deviceInfo" ; import { IPSODevice } from "./ipsoDevice" ; import { deserializeWith , ipsoKey } from "./ipsoObject" ; import { Light } from "./light" ; import { OperationProvider } from "./operation-provider" ; import { Plug } from "./plug" ; import { Sensor } from "./sensor" ; export enum AccessoryTypes { /** A "normal" remote */ remote = 0 , /**
     * A remote which has been paired with another remote.
     * See https://www.reddit.com/r/tradfri/comments/6x1miq for details
     */ slaveRemote = 1 , /** A lightbulb */ lightbulb = 2 , /** A smart plug */ plug = 3 , /** A motion sensor (currently unsupported) */ motionSensor = 4 , /** A signal repeater */ signalRepeater = 6 , /** A smart blind */ blind = 7 , /** Symfonisk Remote */ soundRemote = 8 , /** STARKVIND Air purifier */ airPurifier = 10 } export class Accessory extends IPSODevice { @ ipsoKey ( "5750" ) public type : AccessoryTypes = AccessoryTypes . remote ; @ ipsoKey ( "3" ) @ deserializeWith ( ( obj , me ) => new DeviceInfo ( me . options ) . parse ( obj ) ) public deviceInfo ! : DeviceInfo ; @ ipsoKey ( "9019" ) public alive : boolean = false ; @ ipsoKey ( "9020" ) public lastSeen : number = 0 ; @ ipsoKey ( "3311" ) @ deserializeWith ( ( obj , me ) => new Light ( me . options , me ) . parse ( obj ) ) public lightList ! : Light [ ] ; @ ipsoKey ( "3312" ) @ deserializeWith ( ( obj , me ) => new Plug ( me . options , me ) . parse ( obj ) ) public plugList ! : Plug [ ] ; @ ipsoKey ( "3300" ) @ deserializeWith ( ( obj , me ) => new Sensor ( me . options ) . parse ( obj ) ) public sensorList ! : Sensor [ ] ; @ ipsoKey ( "15009" ) @ deserializeWith ( ( obj , me ) => new IPSODevice ( me . options ) . parse ( obj ) ) public switchList ! : IPSODevice [ ] ; @ ipsoKey ( "15014" ) @ deserializeWith ( ( obj , me ) => new IPSODevice ( me . options ) . parse ( obj ) ) public repeaterList ! : IPSODevice [ ] ; @ ipsoKey ( "15015" ) @ deserializeWith ( ( obj , me ) => new Blind ( me . options , me ) . parse ( obj ) ) public blindList ! : Blind [ ] ; @ ipsoKey ( "15025" ) @ deserializeWith ( ( obj , me ) => new AirPurifier ( me . options , me ) . parse ( obj ) ) public airPurifierList ! : AirPurifier [ ] ; @ ipsoKey ( "9054" ) public otaUpdateState : number = 0 ; internal @ ipsoKey ( "9084" ) public UNKNOWN1 ! : string ; param client internal public link ( client ) { super . link ( client ) ; if ( this . lightList != null ) { for ( const light of this . lightList ) { light . link ( client ) ; } } if ( this . plugList != null ) { for ( const plug of this . plugList ) { plug . link ( client ) ; } } if ( this . sensorList != null ) { for ( const sensor of this . sensorList ) { sensor . link ( client ) ; } } if ( this . switchList != null ) { for ( const swtch of this . switchList ) { swtch . link ( client ) ; } } if ( this . blindList != null ) { for ( const blind of this . blindList ) { blind . link ( client ) ; } } if ( this . airPurifierList != null ) { for ( const ap of this . airPurifierList ) { ap . link ( client ) ; } } return this ; } /**
     * Fixes property values that are known to be bugged
     */ public fixBuggedProperties ( ) { super . fixBuggedProperties ( ) ; if ( this . lightList != null ) { this . lightList = this . lightList . map ( light => light . fixBuggedProperties ( ) ) ; } if ( this . plugList != null ) { this . plugList = this . plugList . map ( plug => plug . fixBuggedProperties ( ) ) ; } if ( this . sensorList != null ) { this . sensorList = this . sensorList . map ( sensor => sensor . fixBuggedProperties ( ) ) ; } if ( this . switchList != null ) { this . switchList = this . switchList . map ( swtch => swtch . fixBuggedProperties ( ) ) ; } if ( this . blindList != null ) { this . blindList = this . blindList . map ( blind => blind . fixBuggedProperties ( ) ) ; } if ( this . airPurifierList != null ) { this . airPurifierList = this . airPurifierList . map ( ap => ap . fixBuggedProperties ( ) ) ; } return this ; } }