generated from homebridge/homebridge-plugin-template
-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Object conversion algorithm in place
- Loading branch information
Showing
10 changed files
with
213 additions
and
159 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { PlatformConfig } from "homebridge"; | ||
import { EXPECTED_CONFIG_STRUCTURE } from "../types/constants"; | ||
import { correctObjectShape } from "./utils"; | ||
interface AdvancedOptions { | ||
periodicDiscovery: boolean; | ||
namesWithMacAddress: boolean; | ||
logLevel: number; | ||
additionalSubnets: any[]; | ||
} | ||
|
||
interface DeviceManagement { | ||
blacklistOrWhitelist: string; | ||
blacklistedUniqueIDs: any[]; | ||
} | ||
|
||
interface WhiteEffects { | ||
simultaniousDevicesColorWhite: boolean; | ||
colorWhiteThreshold: number; | ||
colorWhiteThresholdSimultaniousDevices: number; | ||
colorOffThresholdSimultaniousDevices: number; | ||
} | ||
|
||
interface Pruning { | ||
pruneMissingCachedAccessories: boolean; | ||
restartsBeforeMissingAccessoriesPruned: number; | ||
pruneAllAccessoriesNextRestart: boolean; | ||
} | ||
|
||
export interface CorrectedMHConfig { | ||
pruning: Pruning; | ||
whiteEffects: WhiteEffects; | ||
deviceManagement: DeviceManagement; | ||
advancedOptions: AdvancedOptions; | ||
} | ||
|
||
export class MHConfig { | ||
private static instance: MHConfig; | ||
|
||
public static pruning: Pruning; | ||
public static whiteEffects: WhiteEffects; | ||
public static deviceManagement: DeviceManagement; | ||
public static advancedOptions: AdvancedOptions; | ||
|
||
constructor(private hbConfig: PlatformConfig) { | ||
if (MHConfig.instance) { | ||
return; | ||
} | ||
|
||
const correctedConfig = correctObjectShape(hbConfig, EXPECTED_CONFIG_STRUCTURE) as CorrectedMHConfig; | ||
|
||
MHConfig.pruning = correctedConfig.pruning; | ||
MHConfig.whiteEffects = correctedConfig.whiteEffects; | ||
MHConfig.deviceManagement = correctedConfig.deviceManagement; | ||
MHConfig.advancedOptions = correctedConfig.advancedOptions; | ||
|
||
MHConfig.instance = this; | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.