homebridge-touchwand-google
Version:
64 lines • 2.26 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Window = void 0;
const hap_types_1 = require("../hap-types");
class Window {
sync(service) {
return {
id: service.uniqueId,
type: 'action.devices.types.WINDOW',
traits: [
'action.devices.traits.OpenClose',
],
name: {
defaultNames: [
service.serviceName,
service.accessoryInformation.Name,
],
name: service.serviceName,
nicknames: [],
},
willReportState: true,
attributes: {
openDirection: ['LEFT', 'RIGHT'],
},
deviceInfo: {
manufacturer: service.accessoryInformation.Manufacturer,
model: service.accessoryInformation.Model,
},
customData: {
aid: service.aid,
iid: service.iid,
instanceUsername: service.instance.username,
instanceIpAddress: service.instance.ipAddress,
instancePort: service.instance.port,
},
};
}
query(service) {
return {
on: true,
online: true,
openPercent: service.characteristics.find(x => x.type === hap_types_1.Characteristic.CurrentPosition).value,
};
}
execute(service, command) {
if (!command.execution.length) {
return { payload: { characteristics: [] } };
}
switch (command.execution[0].command) {
case ('action.devices.commands.OpenClose'): {
const payload = {
characteristics: [{
aid: service.aid,
iid: service.characteristics.find(x => x.type === hap_types_1.Characteristic.TargetPosition).iid,
value: command.execution[0].params.openPercent,
}],
};
return { payload };
}
}
}
}
exports.Window = Window;
//# sourceMappingURL=window.js.map