From f923ec10e0b413d536f466fbecbada2b3520256d Mon Sep 17 00:00:00 2001 From: ebaauw Date: Sun, 12 Feb 2023 14:00:02 +0100 Subject: [PATCH] Update P1Accessory.js - Add accessory for Capacity tariff, see #69. --- lib/P1Accessory.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/P1Accessory.js b/lib/P1Accessory.js index a2ea15c..aac8170 100644 --- a/lib/P1Accessory.js +++ b/lib/P1Accessory.js @@ -33,6 +33,7 @@ class P1Accessory extends homebridgeLib.AccessoryDelegate { } static get Electricity () { return Electricity } + static get ElectricityCapacity () { return ElectricityCapacity } static get Gas () { return Gas } static get Water () { return Water } } @@ -60,6 +61,22 @@ class Electricity extends P1Accessory { } } +class ElectricityCapacity extends P1Accessory { + constructor (platform, data, name = 'Electricity Capacity') { + data.id += 'C' + super(platform, name, data) + this.service = new P1Service.ElectricityCapacity(this, data) + this.historyService = new homebridgeLib.ServiceDelegate.History( + this, { + averagePowerDelegate: this.service.characteristicDelegate('power') + } + ) + if (!this.platform.config.outlet) { + this.dummyService = new homebridgeLib.ServiceDelegate.Dummy(this) + } + } +} + class Gas extends P1Accessory { constructor (platform, data) { super(platform, 'Gas', data)