forked from pgerke/homebridge-freeathome-local-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfreeAtHomeAccessory.ts
42 lines (39 loc) · 1.54 KB
/
freeAtHomeAccessory.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { PlatformAccessory } from "homebridge";
import { FreeAtHomeContext } from "./freeAtHomeContext";
import { FreeAtHomeHomebridgePlatform } from "./platform";
/** The abstract base class for all free@home accessories.*/
export abstract class FreeAtHomeAccessory {
/** The serial number consisting of the free@home device serial and the channel ID. */
protected readonly serialNumber = `${this.accessory.context.deviceSerial} (${this.accessory.context.channelId})`;
/**
* Constructs a new free@home accessory instance.
* @param platform The free@home Homebridge platform controlling the accessory
* @param accessory The platform accessory.
*/
constructor(
protected readonly platform: FreeAtHomeHomebridgePlatform,
protected readonly accessory: PlatformAccessory<FreeAtHomeContext>
) {
// set accessory information
this.accessory
.getService(this.platform.Service.AccessoryInformation)
?.setCharacteristic(
this.platform.Characteristic.Manufacturer,
"BUSCH-JAEGER"
)
.setCharacteristic(
this.platform.Characteristic.Model,
accessory.context.device.displayName ?? "Unknown Model"
)
.setCharacteristic(
this.platform.Characteristic.SerialNumber,
this.serialNumber
);
}
/**
* Asynchonously updates accessory characteristics from a datapoint.
* @param datapoint The updated data point.
* @param value A string representing the new value.
*/
public abstract updateDatapoint(datapoint: string, value: string): void;
}