From 20eb137ad8f6e041e70d5df0d185b359e269589b Mon Sep 17 00:00:00 2001 From: simatec Date: Tue, 2 Jan 2024 00:10:06 +0100 Subject: [PATCH] (simatec) X1/X3-EVC added --- lib/inverterData.js | 30 ++++++++++++++++++++++++++++-- main.js | 34 ++++++++++++++++++++++++++++++++-- 2 files changed, 60 insertions(+), 4 deletions(-) diff --git a/lib/inverterData.js b/lib/inverterData.js index 0420a25..320cc18 100644 --- a/lib/inverterData.js +++ b/lib/inverterData.js @@ -7,6 +7,7 @@ // 4: X3-Hybrid-G4 // 5: X3-MIC/PRO-G2 // 6: X1-Hybrid-G4 +// 7: X1/X3-EVC Wallbox /***********************************************************************/ class inverterData { @@ -49,6 +50,11 @@ class inverterData { 6: { /***************************************** X1-Hybrid-G4 ***************************************/ 0: { name: 'info.totalSize', description: 'Total Size of Power', type: 'number', unit: 'kW', role: 'value.power' }, 2: { name: 'info.inverterSN', description: 'Unique identifier of inverter (Serial No.)', type: 'string', role: 'text' }, + }, + 7: { /***************************************** X1/X3-EVC ***************************************/ + 0: { name: 'info.totalSize', description: 'Total Size of Power', type: 'number', unit: 'kW', role: 'value.power' }, + 2: { name: 'info.chargerSN', description: 'Unique identifier of charger (Serial No.)', type: 'string', role: 'text' }, + 4: { name: 'info.version', description: 'Version', type: 'string', role: 'text' }, } }; resolve(information_dataPoints); @@ -201,8 +207,8 @@ class inverterData { 112: { name: 'data.batteryCellTemperatureMax', description: 'Battery Cell Temperature Max', type: 'number', multiplier: 0.1, unit: '°C', role: 'value.temperature' }, // Battery Cell Temperature Max, 113: { name: 'data.batteryCellTemperatureMin', description: 'Battery Cell Temperature Min', type: 'number', multiplier: 0.1, unit: '°C', role: 'value.temperature' }, // Battery Cell Temperature Min, 116: { name: 'data.batteryChargingCycles', description: 'battery charging cycles', type: 'number', role: 'indicator.state' }, // 'battery charging cycles, - 125: { name: 'data.batteryCellVoltageMax', description: 'Battery Cell Voltage Max', type: 'number', multiplier: 0.01, unit: 'V', role: 'value.power' }, // Battery Cell Voltage Max, - 126: { name: 'data.batteryCellVoltageMin', description: 'Battery Cell Voltage Max', type: 'number', multiplier: 0.01, unit: 'V', role: 'value.power' }, // Battery Cell Voltage Min, + 125: { name: 'data.batteryCellVoltageMax', description: 'Battery Cell Voltage Max', type: 'number', multiplier: 0.01, unit: 'V', role: 'value.power' }, // Battery Cell Voltage Max, + 126: { name: 'data.batteryCellVoltageMin', description: 'Battery Cell Voltage Max', type: 'number', multiplier: 0.01, unit: 'V', role: 'value.power' }, // Battery Cell Voltage Min, }, 5: { /****************************************** X3-MIC/PRO-G2 *****************************************/ @@ -260,6 +266,26 @@ class inverterData { 34: { name: 'data.feedinenergy', description: 'Feed in Energy', type: 'number', multiplier: 0.01, unit: 'kWh', role: 'value.power.consumption' }, // Feed in Energy 36: { name: 'data.consumeenergy', description: 'Consume Energy', type: 'number', multiplier: 0.01, unit: 'kWh', role: 'value.power.consumption' }, // Consume Energy }, + 7: { + 0: { name: 'data.plugstatus', description: 'Plug Status', type: 'string', role: 'text' }, // '0=Unplugged 1=Plugged 2=Charging': (0, ''), + 1: { name: 'data.chargemode', description: 'Charge Mode', type: 'string', role: 'text' }, // '0= Stop 1= Fast 2=Green 3=Eco': (1, ''), + 2: { name: 'data.acvoltage1', description: 'Grid Voltage 1', type: 'number', multiplier: 0.01, unit: 'V', role: 'value.power' }, // '': (2, 'V'), + 3: { name: 'data.acvoltage2', description: 'Grid Voltage 2', type: 'number', multiplier: 0.01, unit: 'V', role: 'value.power' }, // '': (3, 'V'), + 4: { name: 'data.acvoltage3', description: 'Grid Voltage 3', type: 'number', multiplier: 0.01, unit: 'V', role: 'value.power' }, // '': (4, 'V'), + 5: { name: 'data.accurrent1', description: 'AC Current 1', type: 'number', multiplier: 0.01, unit: 'A', role: 'value.power' }, // '': (5, 'A'), + 6: { name: 'data.accurrent2', description: 'AC Current 2', type: 'number', multiplier: 0.01, unit: 'A', role: 'value.power' }, // '': (6, 'A'), + 7: { name: 'data.accurrent3', description: 'AC Current 3', type: 'number', multiplier: 0.01, unit: 'A', role: 'value.power' }, // '': (7, 'A'), + 8: { name: 'data.acpower1', description: 'AC Power 1', type: 'number', multiplier: 0.01, unit: 'W', role: 'value.power' }, // '': (8, 'W'), + 9: { name: 'data.acpower2', description: 'AC Power 2', type: 'number', unit: 'W', role: 'value.power' }, // '': (9, 'W'), + 10: { name: 'data.acpower3', description: 'AC Power 3', type: 'number', unit: 'W', role: 'value.power' }, // '': (10, 'W'), + 11: { name: 'data.acpower', description: 'AC Power', type: 'number', unit: 'W', role: 'value.power' }, // '': (11, 'W'), + 12: { name: 'data.capacity', description: 'Carged Capacity', type: 'number', multiplier: 0.1, unit: 'KW/h', role: 'value.power.consumption' }, // '': (12, 'KW/h'), + 14: { name: 'data.totalcharged', description: 'Total Charged', type: 'number', multiplier: 0.1, unit: 'KW/h', role: 'value.power.consumption' }, // '': (14, 'KW/h'), + 23: { name: 'data.plugTemperature', description: 'Plug Temperature', type: 'number', unit: '°C', role: 'value.temperature' }, // '': (23, ''), + 24: { name: 'data.boardTemperature', description: 'Board Temperature', type: 'number', unit: '°C', role: 'value.temperature' }, // '': (24, ''), + 26: { name: 'data.plugged', description: 'Car Plugged', type: 'number', role: 'indicator.state' }, // '': (26, ''), + 80: { name: 'data.chargeduration', description: 'Charge Duration', type: 'number', unit: 's', role: 'value.time' }, // '': (80, 's') + } }; resolve(data_dataPoints); }); diff --git a/main.js b/main.js index b0c5d70..dbb1a59 100644 --- a/main.js +++ b/main.js @@ -77,6 +77,21 @@ const _inverterStateAPI = { 113: 'Gen Run Mode' }; +const _wallboxStateLocal = { + 0: 'Unplugged', + 1: 'Plugged', + 2: 'Charging' +}; + +const _wallboxChargemodeLocal = { + 0: 'Stop', + 1: 'Fast', + 2: 'Green', + 3: 'Eco' +}; + + + let adapter; const adapterName = require('./package.json').name.split('.').pop(); @@ -472,6 +487,9 @@ async function requestLocalAPI(root_dataPoints, information_dataPoints, data_dat await adapter.setStateAsync('info.connection', true, true); switch (apiData.type) { + case 1: + type = 7; + break; case 4: type = 2; break; @@ -518,9 +536,20 @@ async function requestLocalAPI(root_dataPoints, information_dataPoints, data_dat data = data * dataPoint.multiplier; } - if ((type == 1 && key == '68') || (type == 3 && key == '18') || (type == 4 && key == '19') || (type == 2 && key == '10') || (type == 5 && key == '21') || (type == 6 && key == '10')) { + if ((type == 1 && key == '68') || (type == 3 && key == '18') || (type == 4 && key == '19') || (type == 2 && key == '10') || (type == 5 && key == '21') || (type == 6 && key == '10') || (type == 7 && key == '10')) { data = data !== undefined ? _inverterStateLocal[data] : 'Offline'; } + + // State for Wallbox Type 7 + if (type == 7 && key == '0') { + data = data !== undefined ? _wallboxStateLocal[data] : 'Offline'; + } + + // State for chargemode Wallbox Type 7 + if (type == 7 && key == '1') { + data = data !== undefined ? _wallboxChargemodeLocal[data] : 'Undefined'; + } + await setDataPoint(dataPoint, data); } @@ -586,12 +615,13 @@ async function resetValues(data_dataPoints) { 4: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 34, 39, 40, 41, 47, 90, 92, 103, 105], 5: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 72, 74, 76, 78,], 6: [0, 1, 2, 4, 5, 6, 7, 8, 9, 10, 14, 15, 16, 17, 18, 32, 34, 36], + 7: [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 26, 80], }; for (const value of valuesOfReset[type]) { const dataPoint = data_dataPoints[type][value]; - if ((type == 1 && value == '68') || (type == 3 && value == '18') || (type == 4 && value == '19') || (type == 2 && value == '10') || (type == 5 && value == '21')) { + if ((type == 1 && value == '68') || (type == 3 && value == '18') || (type == 4 && value == '19') || (type == 2 && value == '10') || (type == 5 && value == '21') || (type == 6 && value == '10') || (type == 7 && value == '0')) { await setDataPoint(dataPoint, 'Offline'); } else if (value != 8) { await setDataPoint(dataPoint, 0);