diff options
author | lonkaars <loek@pipeframe.xyz> | 2021-08-03 19:50:17 +0200 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2021-08-03 19:50:17 +0200 |
commit | 773c4ef10e3b2be7376271afe30633848fb0eb94 (patch) | |
tree | d2d2a02b5596f413ad3b2f21e1aa6e83c59e59b7 /plugin.ts | |
parent | 2876d7a9ec90cd75274b18f6383fa35bd075d6b2 (diff) |
python from stdin + plugin beginnings
Diffstat (limited to 'plugin.ts')
-rw-r--r-- | plugin.ts | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/plugin.ts b/plugin.ts new file mode 100644 index 0000000..01af191 --- /dev/null +++ b/plugin.ts @@ -0,0 +1,73 @@ +import { + API, + Characteristic, + DynamicPlatformPlugin, + Logger, + PlatformAccessory, + PlatformConfig, + Service, +} from 'homebridge'; + +export default class BekenBridge implements DynamicPlatformPlugin { + public readonly Service: typeof Service = this.api.hap.Service; + public readonly Characteristic: typeof Characteristic = this.api.hap.Characteristic; + + public readonly accessories: PlatformAccessory[] = []; + + constructor( + public readonly log: Logger, + public readonly config: PlatformConfig, + public readonly api: API, + ) { + this.log.debug('Loaded BekenBridge'); + + this.api.on('didFinishLaunching', () => { + log.debug('Executed didFinishLaunching callback'); + this.discoverDevices(); + }); + } + + configureAccessory(accessory: PlatformAccessory) { + this.log.info('Loading accessory from cache:', accessory.displayName); + + this.accessories.push(accessory); + } + + discoverDevices() { + this.log.info('gert'); + // const exampleDevices = [ + // { + // exampleUniqueId: 'ABCD', + // exampleDisplayName: 'Bedroom', + // }, + // { + // exampleUniqueId: 'EFGH', + // exampleDisplayName: 'Kitchen', + // }, + // ]; + + // for (const device of exampleDevices) { + + // const uuid = this.api.hap.uuid.generate(device.exampleUniqueId); + + // const existingAccessory = this.accessories.find(accessory => accessory.UUID === uuid); + + // if (existingAccessory) { + // this.log.info('Restoring existing accessory from cache:', existingAccessory.displayName); + + // new ExamplePlatformAccessory(this, existingAccessory); + + // } else { + // this.log.info('Adding new accessory:', device.exampleDisplayName); + + // const accessory = new this.api.platformAccessory(device.exampleDisplayName, uuid); + + // accessory.context.device = device; + + // new ExamplePlatformAccessory(this, accessory); + + // this.api.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, [accessory]); + // } + // } + } +} |