diff --git a/README.md b/README.md index 0322b73e..1e5f2618 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/admin/index_m.html b/admin/index_m.html index c00cbb59..02650a00 100644 --- a/admin/index_m.html +++ b/admin/index_m.html @@ -198,6 +198,22 @@
Foreign Objects
+
+
+
+
+
+ +
+
+ +
+
+ +
+
+
+
diff --git a/admin/words.js b/admin/words.js index 43bad106..220b74c7 100644 --- a/admin/words.js +++ b/admin/words.js @@ -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)" } }; \ No newline at end of file diff --git a/io-package.json b/io-package.json index 1e15fde0..8a665f65 100644 --- a/io-package.json +++ b/io-package.json @@ -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;" }, @@ -326,6 +329,7 @@ "houseBatteryForeignObjectID": "", "houseBatteryForeignObjectAck": false, "houseBatteryForeignObjectNegate": true, + "carBatterySoCForeignObjectID": "", "bufferToSolar": 100, "bufferToBattery": 0, "apiVersion": 1, @@ -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 + } } - - ] } diff --git a/main.js b/main.js index f5d5cf33..82288576 100644 --- a/main.js +++ b/main.js @@ -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) @@ -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]); } @@ -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]); } @@ -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 @@ -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"); @@ -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") @@ -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) { @@ -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) { @@ -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); diff --git a/package.json b/package.json index 98b9da0c..7d65e568 100644 --- a/package.json +++ b/package.json @@ -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",