@homebridge-plugins/homebridge-smarthq
Version:
The SmartHQ plugin allows you to interact with SmartHQ Devices in HomeKit and with Siri.
84 lines • 3.53 kB
JavaScript
import { deviceBase } from './device.js';
export class SmartHQMicrowave extends deviceBase {
platform;
device;
constructor(platform, accessory, device) {
super(platform, accessory, device);
this.platform = platform;
this.device = device;
this.debugLog(`Microwave Features: ${JSON.stringify(accessory.context.device.features)}`);
// Microwave Light
const light = this.accessory.getService('Microwave Light') ?? this.accessory.addService(this.platform.Service.Lightbulb, 'Microwave Light', 'MicrowaveLight');
light.setCharacteristic(this.platform.Characteristic.Name, 'Microwave Light');
light
.getCharacteristic(this.platform.Characteristic.On)
.onGet(async () => {
try {
// TODO: Implement light state ERD
return false;
}
catch (error) {
this.warnLog?.(`Microwave Light error: ${error?.message ?? error}`);
return false;
}
})
.onSet(async (value) => {
try {
// TODO: Implement light control ERD
this.debugLog(`Microwave Light set to: ${value}`);
}
catch (error) {
this.warnLog?.(`Microwave Light set error: ${error?.message ?? error}`);
}
});
// Microwave Running State (Switch)
const runningSwitch = this.accessory.getService('Microwave') ?? this.accessory.addService(this.platform.Service.Switch, 'Microwave', 'Microwave');
runningSwitch.setCharacteristic(this.platform.Characteristic.Name, 'Microwave');
runningSwitch
.getCharacteristic(this.platform.Characteristic.On)
.onGet(async () => {
try {
// TODO: Implement running state ERD
return false;
}
catch (error) {
this.warnLog?.(`Microwave Running error: ${error?.message ?? error}`);
return false;
}
})
.onSet(async (value) => {
try {
// TODO: Implement running control ERD
this.debugLog(`Microwave Running set to: ${value}`);
}
catch (error) {
this.warnLog?.(`Microwave Running set error: ${error?.message ?? error}`);
}
});
// Ventilation Fan (if applicable)
const fan = this.accessory.getService('Microwave Fan') ?? this.accessory.addService(this.platform.Service.Fanv2, 'Microwave Fan', 'MicrowaveFan');
fan.setCharacteristic(this.platform.Characteristic.Name, 'Microwave Fan');
fan
.getCharacteristic(this.platform.Characteristic.Active)
.onGet(async () => {
try {
// TODO: Implement fan state ERD
return this.platform.Characteristic.Active.INACTIVE;
}
catch (error) {
this.warnLog?.(`Microwave Fan error: ${error?.message ?? error}`);
return this.platform.Characteristic.Active.INACTIVE;
}
})
.onSet(async (value) => {
try {
// TODO: Implement fan control ERD
this.debugLog(`Microwave Fan set to: ${value}`);
}
catch (error) {
this.warnLog?.(`Microwave Fan set error: ${error?.message ?? error}`);
}
});
}
}
//# sourceMappingURL=microwave.js.map