Skip to content

Commit

Permalink
Add measurements for three separate phases for P1 device. Closes #31
Browse files Browse the repository at this point in the history
  • Loading branch information
Joolee committed Mar 15, 2022
1 parent 8d27e40 commit 1f1cda4
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 2 deletions.
36 changes: 36 additions & 0 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -2483,6 +2483,42 @@
"en": "Surplus tariff 2",
"nl": "Teruglevering tarief 2"
}
},
"measure_power.received_l1": {
"title": {
"en": "Usage phase L1",
"nl": "Verbruik fase L1"
}
},
"measure_power.received_l2": {
"title": {
"en": "Usage phase L2",
"nl": "Verbruik fase L2"
}
},
"measure_power.received_l3": {
"title": {
"en": "Usage phase L3",
"nl": "Verbruik fase L3"
}
},
"measure_power.delivered_l1": {
"title": {
"en": "Surplus phase L1",
"nl": "Teruglevering fase L1"
}
},
"measure_power.delivered_l2": {
"title": {
"en": "Surplus phase L2",
"nl": "Teruglevering fase L2"
}
},
"measure_power.delivered_l3": {
"title": {
"en": "Surplus phase L3",
"nl": "Teruglevering fase L3"
}
}
},
"energy": {
Expand Down
13 changes: 11 additions & 2 deletions drivers/p1/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,16 +190,25 @@ module.exports = class P1_Device extends GeneralDevice {
});
}

// Power usage
// Total power usage
this.setValue("measure_power", dg.electricity.received.actual.reading * 1000);
this.setValue("meter_power.received1", dg.electricity.received.tariff1.reading);
this.setValue("meter_power.received2", dg.electricity.received.tariff2.reading);

// Power surplus
// Total power surplus
this.setValue("measure_power.delivery", 0 - dg.electricity.delivered.actual * 1000);
this.setValue("meter_power.delivered1", dg.electricity.delivered.tariff1.reading);
this.setValue("meter_power.delivered2", dg.electricity.delivered.tariff2.reading);

// Power usage per phase
// Only if phase 2 is not null
if (dg.electricity.instantaneous.power.positive.L2.reading) {
for (let i = 1; i < 4; i++) {
this.setValue('measure_power.received_l' + i, dg.electricity.instantaneous.power.positive['L' + i].reading * 1000);
this.setValue('measure_power.delivered_l' + i, dg.electricity.instantaneous.power.negative['L' + i].reading * 1000);
}
}

// Active tariff
if (dg.electricity.tariffIndicator) {
this.setValue("alarm_active_tariff", dg.electricity.tariffIndicator.toString());
Expand Down
36 changes: 36 additions & 0 deletions drivers/p1/driver.compose.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,42 @@
"en": "Surplus tariff 2",
"nl": "Teruglevering tarief 2"
}
},
"measure_power.received_l1": {
"title": {
"en": "Usage phase L1",
"nl": "Verbruik fase L1"
}
},
"measure_power.received_l2": {
"title": {
"en": "Usage phase L2",
"nl": "Verbruik fase L2"
}
},
"measure_power.received_l3": {
"title": {
"en": "Usage phase L3",
"nl": "Verbruik fase L3"
}
},
"measure_power.delivered_l1": {
"title": {
"en": "Surplus phase L1",
"nl": "Teruglevering fase L1"
}
},
"measure_power.delivered_l2": {
"title": {
"en": "Surplus phase L2",
"nl": "Teruglevering fase L2"
}
},
"measure_power.delivered_l3": {
"title": {
"en": "Surplus phase L3",
"nl": "Teruglevering fase L3"
}
}
},
"energy": {
Expand Down

0 comments on commit 1f1cda4

Please sign in to comment.