This repository has been archived by the owner on Oct 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refacor/code & fixes/brightness-slider (#13)
- Loading branch information
Showing
12 changed files
with
549 additions
and
311 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 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 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,40 @@ | ||
import { Logger, PlatformAccessory } from 'homebridge'; | ||
|
||
import DeviceInfo from '../api/@types/DeviceInfo'; | ||
import TPLink from '../api/TPLink'; | ||
import Platform from '../platform'; | ||
import Context from './Context'; | ||
|
||
export enum AccessoryType { | ||
LightBulb = 'LightBulb', | ||
Unknown = 'Unknown' | ||
} | ||
|
||
abstract class Accessory { | ||
protected readonly tpLink: TPLink; | ||
protected readonly model: string; | ||
protected readonly mac: string; | ||
|
||
public static GetType(deviceInfo: DeviceInfo): AccessoryType { | ||
if (deviceInfo?.type?.includes('BULB')) { | ||
return AccessoryType.LightBulb; | ||
} | ||
|
||
return AccessoryType.Unknown; | ||
} | ||
|
||
public abstract get UUID(): string; | ||
|
||
constructor( | ||
protected readonly platform: Platform, | ||
protected readonly accessory: PlatformAccessory<Context>, | ||
protected readonly log: Logger, | ||
protected readonly deviceInfo: DeviceInfo | ||
) { | ||
this.tpLink = accessory.context.tpLink; | ||
this.model = deviceInfo.model; | ||
this.mac = deviceInfo.mac; | ||
} | ||
} | ||
|
||
export default Accessory; |
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 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 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 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 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 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 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 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
Oops, something went wrong.