homebridge-freeathome-local-api
Version:
Control your free@home setup using the local API provided by your System Access Point
32 lines • 1.69 kB
JavaScript
import { convertToString } from "./util.js";
/** The abstract base class for all free@home accessories.*/
export class FreeAtHomeAccessory {
platform;
accessory;
/** The serial number consisting of the free@home device serial and the channel ID. */
serialNumber;
/**
* Constructs a new free@home accessory instance.
* @param platform The free@home Homebridge platform controlling the accessory
* @param accessory The platform accessory.
*/
constructor(platform, accessory) {
this.platform = platform;
this.accessory = accessory;
// set the serial number
this.serialNumber = `${this.accessory.context.deviceSerial} (${this.accessory.context.channelId})`;
// 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);
}
doUpdateDatapoint(acccessoryDisplayType, service, characteristic, characteristicValue) {
// log event
this.platform.log.info(`${this.accessory.displayName} (${acccessoryDisplayType} ${this.serialNumber}) updated characteristic ${characteristic.name} -> ${convertToString(characteristicValue)}`);
// asynchoronously update the characteristic
service.updateCharacteristic(characteristic, characteristicValue);
}
}
//# sourceMappingURL=freeAtHomeAccessory.js.map