Skip to content

Commit

Permalink
Merge pull request #249 from MK-2001/onprem
Browse files Browse the repository at this point in the history
1.0.38
  • Loading branch information
MK-2001 authored Jul 19, 2024
2 parents 3d83586 + e94fcce commit 68cec3c
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 11 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ https://go-e.co/support/

## Changelog

### 1.0.38
* Bug on Negate Watts if use Go-e charger

### 1.0.35
* switch between ioBroker and go-e Hardware logic for PV-Calculation
* Adding phaseSwitch Buffer to reduce switch on coudy days
Expand Down
16 changes: 16 additions & 0 deletions admin/index_m.html
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,22 @@ <h5>Foreign Objects</h5>
</div>
</div>
</div>
<div class="col s12 m6">
<div class="row">
<div class="col s10">
<div class="row">
<div class="col s11">
<input class="value" id="carBatterySoCForeignObjectID"/>
</div>
<div class="col s1">
<button id="carBatterySoCForeignSearch">...</button>
</div>
<div class="col s12">
<label id="houseBatteryLbl" for="carBatterySoCForeignObjectID" class="translate">carBatterySoCForeignObjectID</label>
</div>
</div>
</div>
</div>
</div>
<div class="col s12 m6">
<input type="text" class="value" id="bufferToBattery" />
Expand Down
3 changes: 3 additions & 0 deletions admin/words.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,5 +254,8 @@ systemDictionary = {
},
"calcMethod": {
"en": "Which mode should be used to calculate the PV-Überschuss"
},
"carBatterySoCForeignObjectID": {
"en": "Car Battery Status SoC in percent (0-100)"
}
};
36 changes: 33 additions & 3 deletions io-package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
{
"common": {
"name": "go-e",
"version": "1.0.36",
"version": "1.0.38",
"news": {
"1.0.38": {
"en": "bug; wrong negate if set object to go-e Adapter;"
},
"1.0.36": {
"en": "bug #232; wrong default value type;"
},
Expand Down Expand Up @@ -326,6 +329,7 @@
"houseBatteryForeignObjectID": "",
"houseBatteryForeignObjectAck": false,
"houseBatteryForeignObjectNegate": true,
"carBatterySoCForeignObjectID": "",
"bufferToSolar": 100,
"bufferToBattery": 0,
"apiVersion": 1,
Expand Down Expand Up @@ -2232,8 +2236,34 @@
"read": true,
"write": true
}
},
{
"_id": "stopChargeingAtCarSoc80",
"type": "state",
"common": {
"name": "Stop 80% SoC",
"role": "",
"icon": "",
"desc": "Dont allow charging when the car battery has 80% SoC",
"type": "boolean",
"def": false,
"read": true,
"write": true
}
},
{
"_id": "phaseSwitchModeEnabled",
"type": "state",
"common": {
"name": "Enable phase switching",
"role":"",
"icon":"",
"desc": "Enable switchin between 1 and 3 phases during solar Only Loading. Disable will stick on 1 phase.",
"type": "boolean",
"def": true,
"read": true,
"write": true
}
}


]
}
36 changes: 29 additions & 7 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,8 @@ class GoE extends utils.Adapter {
this.setValueV2("fup", 0).catch(() => {}); // go-e Solarladen deaktivieren
this.setValueV2("psm", 0).catch(() => {}); // Phases Switch to auto
}
} else {
this.setValueV2("psm", 1).catch(() => {}); // Phases Switch to 1-phase
}
} else {
this.setValueV2("fup", state.val)
Expand Down Expand Up @@ -328,7 +330,7 @@ class GoE extends utils.Adapter {
case this.config.houseConsumptionForeignObjectID:
if(this.ackObj[id] === false) {
this.log.silly("Will work on " + id + " becase ack is " + state.ack + " and should be " + this.ackObj[id]);
this.calculateFromForeignObjects();
this.calculateFromForeignObjects(id);
} else {
this.log.silly("Will NOT work on " + id + " becase ack is " + state.ack + " and should be " + this.ackObj[id]);
}
Expand All @@ -345,7 +347,7 @@ class GoE extends utils.Adapter {
this.log.silly(`state ${id} changed: ${state.val} (ack = ${state.ack}) namespace: ` + this.namespace);
if(this.ackObj[id] === true) {
this.log.silly("Will work on " + id + " becase ack is " + state.ack + " and should be " + this.ackObj[id]);
this.calculateFromForeignObjects();
this.calculateFromForeignObjects(id);
} else {
this.log.silly("Will NOT work on " + id + " becase ack is " + state.ack + " and should be " + this.ackObj[id]);
}
Expand Down Expand Up @@ -454,8 +456,12 @@ class GoE extends utils.Adapter {
* This function is writing the IDS endpoint on the go-e adapter based to given attributes
*/
async writeIds() {
const availWatts = await this.getNumberFromForeignObjectId(this.config.solarPowerForeignObjectID);
let availWatts = await this.getNumberFromForeignObjectId(this.config.solarPowerForeignObjectID);
const houseBattery = await this.getNumberFromForeignObjectId(this.config.houseBatteryForeignObjectID);
if(this.config.solarPowerForeignObjectNegate) {
availWatts = availWatts * -1;
this.log.silly("Negate watts of Solar new: " + availWatts);
}
const buildObj = {
pGrid: availWatts,
pAkku: houseBattery
Expand Down Expand Up @@ -865,6 +871,11 @@ class GoE extends utils.Adapter {
this.log.error("adjustAmpLevelInWatts: Not all required information about the phases are found. Required Values are: phaseSwitchMode");
return;
}
const phaseSwitchModeEnabled = await this.getStateAsync("phaseSwitchModeEnabled");
if(phaseSwitchModeEnabled === null || phaseSwitchModeEnabled === undefined || phaseSwitchModeEnabled.val === null) {
this.log.error("adjustAmpLevelInWatts: Not all required information about the phases are found. Required Values are: phaseSwitchModeEnabled");
return;
}
const avgVoltage1 = await this.getStateAsync("energy.phase1.voltage");
if(avgVoltage1 === null || avgVoltage1 === undefined || avgVoltage1.val === null) {
this.log.error("adjustAmpLevelInWatts: Not all required information about the phases are found. Required Values are: eneregy.phase1.voltage");
Expand Down Expand Up @@ -949,8 +960,8 @@ class GoE extends utils.Adapter {
// (9240 W + 1320) / (660 / 3) / 3 => 16 A
// Using floor (abrunden) anstatt runden, damit immer etwas übrig bleibt.
let maxAmp = Math.floor((usedWatts + changeWatts) / (usedVolts / usedPhases) / usedPhases);
this.log.debug("Current used " + Math.round(usedWatts) + " Watts with " + usedAmperes + " Ampere (sum) by " + usedPhases + " Phases and adjusting this with " + changeWatts + " watts by " + (usedVolts / usedPhases) + " Volts (avg) to new max of " + maxAmp + " Amperes per Phase; PhaseSwitchLevel: from " + phaseSwitchMode.val + " at " + (phaseSwitchMode.val != 1 ? "<" + (Number(phaseSwitchWatts) - Number(phaseSwitchModeBuffer.val)) : ">" + (Number(phaseSwitchWatts) + Number(phaseSwitchModeBuffer.val))));
if((usedWatts + changeWatts) > Number(phaseSwitchWatts) + Number(phaseSwitchModeBuffer.val) && phaseSwitchMode.val != 2) {
this.log.info("Change Amperes: Current used " + Math.round(usedWatts) + " Watts with " + usedAmperes + " Ampere (sum) by " + usedPhases + " Phases and adjusting this with " + changeWatts + " watts by " + (usedVolts / usedPhases) + " Volts (avg) to new max of " + maxAmp + " Amperes per Phase; PhaseSwitchLevel: from " + (phaseSwitchModeEnabled.val ? (phaseSwitchMode.val + " at " + (phaseSwitchMode.val != 1 ? "<" + (Number(phaseSwitchWatts) - Number(phaseSwitchModeBuffer.val)) : ">" + (Number(phaseSwitchWatts) + Number(phaseSwitchModeBuffer.val)))): "off"));
if((usedWatts + changeWatts) > Number(phaseSwitchWatts) + Number(phaseSwitchModeBuffer.val) && phaseSwitchMode.val != 2 && phaseSwitchModeEnabled.val == true) {
// initiate phase switch to 3-phases
this.log.debug(`Current Watts ${usedWatts + changeWatts} require Mode 3-phases; current: ${phaseSwitchMode.val}; Change maxAmp from ${maxAmp} to ${Math.round(maxAmp / 3)}`);
await axios.get("/api/set?psm=2")
Expand Down Expand Up @@ -1002,7 +1013,7 @@ class GoE extends utils.Adapter {
* Get the max Watts from foreign adapters
* params: stateObjectId = "[unknown State ID]"
*/
async calculateFromForeignObjects() {
async calculateFromForeignObjects(foreignObj = "unknown") {
try {
const allowCharge = await this.getStateAsync("allow_charging");
if(allowCharge === null || allowCharge === undefined || allowCharge.val === null) {
Expand All @@ -1029,6 +1040,17 @@ class GoE extends utils.Adapter {
this.setState("solarLoadOnly", { val: false, ack: true });
return;
}

// Check if SoC Car is enabled
const carBatterySoC = await this.getNumberFromForeignObjectId(this.config.carBatterySoCForeignObjectID);
const stopChargeingAtCarSoC = await this.getStateAsync("stopChargeingAtCarSoC");
if(stopChargeingAtCarSoC != null && stopChargeingAtCarSoC != undefined && stopChargeingAtCarSoC.val === true && carBatterySoC >= 80) {
this.log.info("Stop loading over 80% because car SoC is at " + carBatterySoC);
if( allowCharge.val !== 0)
this.setValue("alw", 0);
return;
}

const usedPower = await this.getStateAsync("energy.power");
// Check if used Power has a value
if(usedPower === undefined || usedPower == null || usedPower.val == null) {
Expand Down Expand Up @@ -1065,7 +1087,7 @@ class GoE extends utils.Adapter {
// If your home battery contains 3000 Wh use in one hour the whole energy to load.
//

this.log.debug("Start ajust by foreign Object with " + (availWatts - parseInt(usedPower.val.toString(), 10)) + ` Watts. (${availWatts1} solarPower - ${this.config.bufferToSolar} Buffer - ${houseConsumption} House consumption + ${houseBattery} House battery)`);
this.log.debug("Incoming request from foreign Object " + foreignObj + " with " + (availWatts - parseInt(usedPower.val.toString(), 10)) + ` Watts. (${availWatts1} solarPower - ${this.config.bufferToSolar} Buffer - ${houseConsumption} House consumption + ${houseBattery} House battery)`);
this.adjustAmpLevelInWatts(availWatts - parseInt(usedPower.val.toString(), 10));
} catch (err) {
const errMsg = err instanceof Error ? err.message : JSON.stringify(err);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "iobroker.go-e",
"version": "1.0.36",
"version": "1.0.38",
"description": "go-e ist die Aufforderung, sich elektrisch zu bewegen. e-Mobilität ist unser Antrieb, wobei unsere Kernkompetenz die Ladetechnik für Elektroautos ist. Von der einzelnen Ladestation für e-Autos über Photovoltaik-Anbindung bis hin zum Lastmanagement von ganzen Gebäuden, sind wir Anbieter gesamtheitlicher Systemlösungen für sämtliche Anforderungen der modernen e-Mobilität.",
"author": {
"name": "MK-2001",
Expand Down

0 comments on commit 68cec3c

Please sign in to comment.