homebridge-sense-energy-monitor
Version:
Enhanced Homebridge plugin for Sense Home Energy Monitor with comprehensive API integration and real-time monitoring
56 lines • 2.18 kB
JavaScript
let cached = null;
/**
* Eve-style custom characteristics for live power data. Apple Home ignores
* these; the Eve app shows them alongside the FakeGato history graphs.
* hap classes must derive from the runtime `api.hap`, hence the factory.
*/
export function getEveCharacteristics(api) {
if (cached) {
return cached;
}
const { Characteristic: BaseCharacteristic, Formats, Perms } = api.hap;
const perms = ["pr" /* Perms.PAIRED_READ */, "ev" /* Perms.NOTIFY */];
class Consumption extends BaseCharacteristic {
static UUID = 'E863F10D-079E-48FF-8F27-9C2605A29F52';
constructor() {
super('Consumption', Consumption.UUID, {
format: "float" /* Formats.FLOAT */, unit: 'W', perms,
minValue: 0, maxValue: 100000, minStep: 0.1,
});
this.value = 0;
}
}
class Voltage extends BaseCharacteristic {
static UUID = 'E863F10A-079E-48FF-8F27-9C2605A29F52';
constructor() {
super('Voltage', Voltage.UUID, {
format: "float" /* Formats.FLOAT */, unit: 'V', perms,
minValue: 0, maxValue: 1000, minStep: 0.1,
});
this.value = 0;
}
}
class ElectricCurrent extends BaseCharacteristic {
static UUID = 'E863F126-079E-48FF-8F27-9C2605A29F52';
constructor() {
super('Electric Current', ElectricCurrent.UUID, {
format: "float" /* Formats.FLOAT */, unit: 'A', perms,
minValue: 0, maxValue: 1000, minStep: 0.01,
});
this.value = 0;
}
}
class TotalConsumption extends BaseCharacteristic {
static UUID = 'E863F10C-079E-48FF-8F27-9C2605A29F52';
constructor() {
super('Total Consumption', TotalConsumption.UUID, {
format: "float" /* Formats.FLOAT */, unit: 'kWh', perms,
minValue: 0, maxValue: 1000000, minStep: 0.001,
});
this.value = 0;
}
}
cached = { Consumption, Voltage, ElectricCurrent, TotalConsumption };
return cached;
}
//# sourceMappingURL=eveCharacteristics.js.map