New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

iobroker.evcc

Package Overview
Dependencies
Maintainers
2
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

iobroker.evcc - npm Package Compare versions

Comparing version 0.0.10 to 0.1.0

build/lib/vehicle.js

510

build/main.js

@@ -111,3 +111,3 @@ "use strict";

case 'min':
this.log.info('Start evcc ninimal charging on loadpointindex: ' + idProperty[3]);
this.log.info('Start evcc minimal charging on loadpointindex: ' + idProperty[3]);
this.setEvccStartMin(idProperty[3]);

@@ -119,10 +119,2 @@ break;

break;
case 'minSoc':
this.log.info('Set minSoc on loadpointindex: ' + idProperty[3]);
this.setEvccMinSoc(idProperty[3], state.val);
break;
case 'targetSoc':
this.log.info('Set evcc targetSoc on loadpointindex: ' + idProperty[3]);
this.setEvccTargetSoc(idProperty[3], state.val);
break;
case 'minCurrent':

@@ -136,4 +128,4 @@ this.log.info('Set minCurrent on loadpointindex: ' + idProperty[3]);

break;
case 'phases':
this.log.info('Set phases on loadpointindex: ' + idProperty[3]);
case 'phasesConfigured':
this.log.info('Set phasesConfigured on loadpointindex: ' + idProperty[3]);
this.setEvccPhases(idProperty[3], state.val);

@@ -145,3 +137,3 @@ break;

break;
case 'disable_threshold':
case 'enable_threshold':
this.log.info('Set enable threshold on loadpointindex: ' + idProperty[3]);

@@ -151,4 +143,15 @@ this.setEvccEnableThreshold(idProperty[3], state.val);

default:
this.log.debug(JSON.stringify(idProperty));
this.log.warn(`Event with state ${id} changed: ${state.val} (ack = ${state.ack}) not found`);
switch (idProperty[4]) {
case 'minSoc':
this.log.info('Set minSoc on vehicle: ' + idProperty[3]);
this.setVehicleMinSoc(idProperty[3], Number(state.val));
break;
case 'limitSoc':
this.log.info('Set limitSoc on vehicle: ' + idProperty[3]);
this.setVehicleLimitSoc(idProperty[3], Number(state.val));
break;
default:
this.log.debug(JSON.stringify(idProperty));
this.log.warn(`Event with state ${id} changed: ${state.val} (ack = ${state.ack}) not found`);
}
}

@@ -162,2 +165,5 @@ }

}
/**
* Hole Daten vom EVCC
*/
getEvccData() {

@@ -168,4 +174,4 @@ try {

this.log.debug('Get-Data from evcc:' + JSON.stringify(response.data));
//Global status Items
this.cre_status(response.data.result);
//Global status Items - ohne loadpoints - ohne vehicle
this.setStatusEvcc(response.data.result);
//Laden jeden Ladepunkt einzeln

@@ -176,2 +182,18 @@ const tmpListLoadpoints = response.data.result.loadpoints;

});
let tmpListVehicles = [];
if (typeof (response.data.result.vehicles) == 'object') {
// haben nur ein Fahrzeug daher etwas umbauen
tmpListVehicles.push(response.data.result.vehicles);
}
else {
tmpListVehicles = response.data.result.vehicles;
}
tmpListVehicles.forEach(async (vehicle) => {
await this.setVehicleData(vehicle);
});
//statistik einzeln ausführen
/*const tmpListVehicle: Vehicle[] = response.data.result.vehicles;
tmpListVehicle.forEach(async (vehicle, index) => {
await this.setVehicleData(vehicle, index);
});*/
this.setState('info.connection', true, true);

@@ -193,2 +215,82 @@ }).catch(error => {

}
async setStatusEvcc(daten) {
for (const lpEntry in daten) {
const lpType = typeof daten[lpEntry]; // get Type of Variable as String, like string/number/boolean
let lpData = daten[lpEntry];
//TODO noch PV uns statístic ausführen
if (lpEntry == 'result' || lpEntry == 'vehicles' || lpEntry == 'loadpoints') {
continue;
}
if (lpType == 'object') {
lpData = JSON.stringify(daten[lpEntry]);
}
await this.extendObjectAsync(`status.${lpEntry}`, {
type: 'state',
common: {
name: lpEntry,
type: lpType,
read: true,
write: false,
role: 'value',
},
native: {},
});
await this.setState(`status.${lpEntry}`, lpData, true);
}
}
/**
* Hole Daten von und für Vehicle
*/
async setVehicleData(vehicle) {
//Vehicle kann es X fach geben
const vehicleID = Object.keys(vehicle)[0];
this.log.debug('Vehicle mit index ' + vehicleID + ' gefunden...');
this.getObject('verhicle.' + vehicleID, (err, obj) => {
if (!obj) {
// Das Objekt existiert nicht
this.log.info(`Das Objekt ${vehicleID} braucht noch controls!`);
}
});
await this.extendObjectAsync(`vehicle.${vehicleID}.title`, {
type: 'state',
common: {
name: 'title',
type: 'string',
read: true,
write: false,
role: 'value',
},
native: {},
});
await this.setState(`vehicle.${vehicleID}.title`, vehicle[vehicleID].title, true);
await this.extendObjectAsync(`vehicle.${vehicleID}.minSoc`, {
type: 'state',
common: {
name: 'minSoc',
type: 'number',
read: true,
write: true,
role: 'value',
},
native: {},
});
this.subscribeStates(`vehicle.${vehicleID}.minSoc`);
await this.setStateAsync(`vehicle.${vehicleID}.minSoc`, { val: vehicle[vehicleID].minSoc !== undefined ? vehicle[vehicleID].minSoc : 0, ack: true });
await this.extendObjectAsync(`vehicle.${vehicleID}.limitSoc`, {
type: 'state',
common: {
name: 'limitSoc',
type: 'number',
read: true,
write: true,
role: 'value',
},
native: {},
});
this.subscribeStates(`vehicle.${vehicleID}.limitSoc`);
await this.setStateAsync(`vehicle.${vehicleID}.limitSoc`, { val: vehicle[vehicleID].limitSoc !== undefined ? vehicle[vehicleID].limitSoc : 100, ack: true });
}
/**
* Hole Daten für Ladepunkte
*/
async setLoadPointdata(loadpoint, index) {

@@ -207,8 +309,9 @@ //Ladepunkt kann es X fach geben

await this.setStateAsync('loadpoint.' + index + '.control.minCurrent', { val: loadpoint.minCurrent, ack: true });
await this.setStateAsync('loadpoint.' + index + '.control.minSoc', { val: loadpoint.minSoc, ack: true });
await this.setStateAsync('loadpoint.' + index + '.control.phases', { val: loadpoint.phases, ack: true });
await this.setStateAsync('loadpoint.' + index + '.control.targetSoc', { val: loadpoint.targetSoc, ack: true });
this.cre_status_idx(loadpoint, index);
await this.setStateAsync('loadpoint.' + index + '.control.disableThreshold', { val: loadpoint.disableThreshold, ack: true });
await this.setStateAsync('loadpoint.' + index + '.control.enableThreshold', { val: loadpoint.enableThreshold, ack: true });
await this.setStateAsync('loadpoint.' + index + '.control.phasesConfigured', { val: loadpoint.phasesConfigured, ack: true });
//Alle Werte unter Status veröffentlichen
this.setStatusLoadPoint(loadpoint, index);
}
async cre_status_idx(loaddata, index) {
async setStatusLoadPoint(loaddata, index) {
for (const lpEntry in loaddata) {

@@ -238,26 +341,2 @@ let lpType = typeof loaddata[lpEntry]; // get Type of Variable as String, like string/number/boolean

}
async cre_status(daten) {
for (const lpEntry in daten) {
const lpType = typeof daten[lpEntry]; // get Type of Variable as String, like string/number/boolean
let lpData = daten[lpEntry];
if (lpEntry == 'result') {
continue;
}
if (lpType == 'object') {
lpData = JSON.stringify(daten[lpEntry]);
}
await this.extendObjectAsync(`status.${lpEntry}`, {
type: 'state',
common: {
name: lpEntry,
type: lpType,
read: true,
write: false,
role: 'value',
},
native: {},
});
await this.setState(`status.${lpEntry}`, lpData, true);
}
}
changeMiliSeconds(nanoseconds) {

@@ -342,26 +421,2 @@ const secondsG = nanoseconds / 1000000000;

this.subscribeStates('loadpoint.' + index + '.control.pv');
await this.setObjectNotExistsAsync('loadpoint.' + index + '.control.minSoc', {
type: 'state',
common: {
name: 'minSoc',
type: 'number',
role: 'value.min',
read: true,
write: true,
},
native: {},
});
this.subscribeStates('loadpoint.' + index + '.control.minSoc');
await this.setObjectNotExistsAsync('loadpoint.' + index + '.control.targetSoc', {
type: 'state',
common: {
name: 'targetSoc',
type: 'number',
role: 'value',
read: true,
write: true,
},
native: {},
});
this.subscribeStates('loadpoint.' + index + '.control.targetSoc');
await this.setObjectNotExistsAsync('loadpoint.' + index + '.control.maxCurrent', {

@@ -391,6 +446,6 @@ type: 'state',

this.subscribeStates('loadpoint.' + index + '.control.minCurrent');
await this.setObjectNotExistsAsync('loadpoint.' + index + '.control.phases', {
await this.setObjectNotExistsAsync('loadpoint.' + index + '.control.phasesConfigured', {
type: 'state',
common: {
name: 'phases',
name: '(0=auto/1=1p/3=3p)',
type: 'number',

@@ -403,7 +458,7 @@ role: 'value',

});
this.subscribeStates('loadpoint.' + index + '.control.phases');
await this.setObjectNotExistsAsync('loadpoint.' + index + '.control.enable_threshold', {
this.subscribeStates('loadpoint.' + index + '.control.phasesConfigured');
await this.setObjectNotExistsAsync('loadpoint.' + index + '.control.enableThreshold', {
type: 'state',
common: {
name: 'enable_threshold',
name: 'enableThreshold',
type: 'number',

@@ -416,7 +471,7 @@ role: 'value',

});
this.subscribeStates('loadpoint.' + index + '.control.enable_threshold');
await this.setObjectNotExistsAsync('loadpoint.' + index + '.control.disable_threshold', {
this.subscribeStates('loadpoint.' + index + '.control.enableThreshold');
await this.setObjectNotExistsAsync('loadpoint.' + index + '.control.disableThreshold', {
type: 'state',
common: {
name: 'disable_threshold',
name: 'disableThreshold',
type: 'number',

@@ -429,268 +484,3 @@ role: 'value',

});
this.subscribeStates('loadpoint.' + index + '.control.disable_threshold');
//Rest in status als Objekte
await this.setObjectNotExistsAsync('loadpoint.' + index + '.status.activePhases', {
type: 'state',
common: {
name: 'activePhases',
type: 'number',
role: 'value',
read: true,
write: false,
},
native: {},
});
await this.setObjectNotExistsAsync('loadpoint.' + index + '.status.chargeConfigured', {
type: 'state',
common: {
name: 'chargeConfigured',
type: 'boolean',
role: 'value.current',
read: true,
write: false,
},
native: {},
});
await this.setObjectNotExistsAsync('loadpoint.' + index + '.status.chargeCurrent', {
type: 'state',
common: {
name: 'chargeCurrent',
type: 'number',
role: 'value.current',
read: true,
write: false,
},
native: {},
});
await this.setObjectNotExistsAsync('loadpoint.' + index + '.status.chargeCurrents', {
type: 'state',
common: {
name: 'chargeCurrents',
type: 'string',
role: 'value.current',
read: true,
write: false,
},
native: {},
});
await this.setObjectNotExistsAsync('loadpoint.' + index + '.status.chargeDuration', {
type: 'state',
common: {
name: 'chargeDuration',
type: 'number',
role: 'value.current',
read: true,
write: false,
},
native: {},
});
await this.setObjectNotExistsAsync('loadpoint.' + index + '.status.chargePower', {
type: 'state',
common: {
name: 'chargePower',
type: 'number',
role: 'value.current',
read: true,
write: false,
},
native: {},
});
await this.setObjectNotExistsAsync('loadpoint.' + index + '.status.chargeRemainingDuration', {
type: 'state',
common: {
name: 'chargeRemainingDuration',
type: 'number',
role: 'value.current',
read: true,
write: false,
},
native: {},
});
await this.setObjectNotExistsAsync('loadpoint.' + index + '.status.chargedEnergy', {
type: 'state',
common: {
name: 'chargedEnergy',
type: 'number',
role: 'value.current',
read: true,
write: false,
},
native: {},
});
await this.setObjectNotExistsAsync('loadpoint.' + index + '.status.charging', {
type: 'state',
common: {
name: 'charging',
type: 'boolean',
role: 'value.current',
read: true,
write: false,
},
native: {},
});
await this.setObjectNotExistsAsync('loadpoint.' + index + '.status.connected', {
type: 'state',
common: {
name: 'connected',
type: 'boolean',
role: 'info.status',
read: true,
write: false,
},
native: {},
});
await this.setObjectNotExistsAsync('loadpoint.' + index + '.status.connectedDuration', {
type: 'state',
common: {
name: 'connectedDuration',
type: 'number',
role: 'info.status',
read: true,
write: false,
},
native: {},
});
await this.setObjectNotExistsAsync('loadpoint.' + index + '.status.enabled', {
type: 'state',
common: {
name: 'enabled',
type: 'boolean',
role: 'info.status',
read: true,
write: false,
},
native: {},
});
await this.setObjectNotExistsAsync('loadpoint.' + index + '.status.hasVehicle', {
type: 'state',
common: {
name: 'hasVehicle',
type: 'boolean',
role: 'info.status',
read: true,
write: false,
},
native: {},
});
await this.setObjectNotExistsAsync('loadpoint.' + index + '.status.mode', {
type: 'state',
common: {
name: 'mode',
type: 'string',
role: 'info.status',
read: true,
write: false,
},
native: {},
});
await this.setObjectNotExistsAsync('loadpoint.' + index + '.status.timerActive', {
type: 'state',
common: {
name: 'timerActive',
type: 'boolean',
role: 'info.status',
read: true,
write: false,
},
native: {},
});
await this.setObjectNotExistsAsync('loadpoint.' + index + '.status.timerProjectedEnd', {
type: 'state',
common: {
name: 'timerProjectedEnd',
type: 'string',
role: 'info.status',
read: true,
write: false,
},
native: {},
});
await this.setObjectNotExistsAsync('loadpoint.' + index + '.status.timerSet', {
type: 'state',
common: {
name: 'timerSet',
type: 'boolean',
role: 'info.status',
read: true,
write: false,
},
native: {},
});
await this.setObjectNotExistsAsync('loadpoint.' + index + '.status.title', {
type: 'state',
common: {
name: 'title',
type: 'string',
role: 'info.name',
read: true,
write: false,
},
native: {},
});
await this.setObjectNotExistsAsync('loadpoint.' + index + '.status.vehicleCapacity', {
type: 'state',
common: {
name: 'vehicleCapacity',
type: 'number',
role: 'info.name',
read: true,
write: false,
},
native: {},
});
await this.setObjectNotExistsAsync('loadpoint.' + index + '.status.vehicleIdentity', {
type: 'state',
common: {
name: 'vehicleIdentity',
type: 'string',
role: 'info.name',
read: true,
write: false,
},
native: {},
});
await this.setObjectNotExistsAsync('loadpoint.' + index + '.status.vehiclePresent', {
type: 'state',
common: {
name: 'vehiclePresent',
type: 'boolean',
role: 'info.status',
read: true,
write: false,
},
native: {},
});
await this.setObjectNotExistsAsync('loadpoint.' + index + '.status.vehicleRange', {
type: 'state',
common: {
name: 'vehicleRange',
type: 'number',
role: 'info.status',
read: true,
write: false,
},
native: {},
});
await this.setObjectNotExistsAsync('loadpoint.' + index + '.status.vehicleSoc', {
type: 'state',
common: {
name: 'vehicleSoc',
type: 'number',
role: 'info.status',
read: true,
write: false,
},
native: {},
});
await this.setObjectNotExistsAsync('loadpoint.' + index + '.status.vehicleTitle', {
type: 'state',
common: {
name: 'vehicleTitle',
type: 'string',
role: 'info.name',
read: true,
write: false,
},
native: {},
});
this.subscribeStates('loadpoint.' + index + '.control.disableThreshold');
}

@@ -780,3 +570,3 @@ //Funktionen zum sterun von evcc

this.log.debug('call: ' + 'http://' + this.ip + '/api/loadpoints/' + index + '/enable/threshold/' + value);
axios_1.default.post('http://' + this.ip + '/api/loadpoints/' + index + '/disable/threshold/' + value, { timeout: this.timeout }).then(() => {
axios_1.default.post('http://' + this.ip + '/api/loadpoints/' + index + '/enable/threshold/' + value, { timeout: this.timeout }).then(() => {
this.log.info('Evcc update successful');

@@ -787,2 +577,34 @@ }).catch(error => {

}
setEvccSetTargetTime(index, value) {
this.log.debug('call: ' + 'http://' + this.ip + '/api/loadpoints/' + index + '/target/time/' + value);
axios_1.default.post('http://' + this.ip + '/api/loadpoints/' + index + '/target/time/' + value, { timeout: this.timeout }).then(() => {
this.log.info('Evcc update successful');
}).catch(error => {
this.log.error('12 ' + error.message);
});
}
setEvccDeleteTargetTime(index) {
this.log.debug('call: ' + 'http://' + this.ip + '/api/loadpoints/' + index + '/target/time');
axios_1.default.delete('http://' + this.ip + '/api/loadpoints/' + index + '/target/time', { timeout: this.timeout }).then(() => {
this.log.info('Evcc update successful');
}).catch(error => {
this.log.error('13 ' + error.message);
});
}
setVehicleMinSoc(vehicleID, minSoc) {
this.log.debug('call: ' + 'http://' + this.ip + '/api/vehicles/' + vehicleID + '/minsoc/' + minSoc);
axios_1.default.post('http://' + this.ip + '/api/vehicles/' + vehicleID + '/minsoc/' + minSoc, { timeout: this.timeout }).then(() => {
this.log.info('Evcc update successful');
}).catch(error => {
this.log.error('14 ' + error.message);
});
}
setVehicleLimitSoc(vehicleID, minSoc) {
this.log.debug('call: ' + 'http://' + this.ip + '/api/vehicles/' + vehicleID + '/limitsoc/' + minSoc);
axios_1.default.post('http://' + this.ip + '/api/vehicles/' + vehicleID + '/limitsoc/' + minSoc, { timeout: this.timeout }).then(() => {
this.log.info('Evcc update successful');
}).catch(error => {
this.log.error('15 ' + error.message);
});
}
}

@@ -789,0 +611,0 @@ if (require.main !== module) {

{
"common": {
"name": "evcc",
"version": "0.0.10",
"version": "0.1.0",
"news": {
"0.1.0": {
"en": "rewrite for evcc api changes\nadd multiple vehicle",
"de": "neu schreiben für evcc api änderungen\nmehrere fahrzeuge",
"ru": "переписать для evcc api изменений\nдобавить несколько транспортных средств",
"pt": "reescrever para mudanças de api evcc\nadicionar vários veículos",
"nl": "herschrijf voor evcc api veranderingen\nvoeg meerdere voertuigen toe",
"fr": "réécriture pour evcc api changes\najouter plusieurs véhicules",
"it": "riscrittura per evcc api modifiche\naggiungere più veicoli",
"es": "reescribir para cambios de evcc api\nañadir el vehículo múltiple",
"pl": "rewrite for evcc api changes (ang.)\ndodać multiple pojazdy",
"uk": "rewrite для evcc api зміни\nдодати багаторазовий автомобіль",
"zh-cn": "投 影\n增加多种车辆"
},
"0.0.10": {

@@ -80,14 +93,2 @@ "en": "generate dynamic objects\ntypo fixes",

"zh-cn": "(Newan) 支持 evcc 0.9X - 更改为 jsonConfig GUI"
},
"0.0.1": {
"en": "initial release",
"de": "Erstveröffentlichung",
"ru": "Начальная версия",
"pt": "lançamento inicial",
"nl": "Eerste uitgave",
"fr": "Première version",
"it": "Versione iniziale",
"es": "Versión inicial",
"pl": "Pierwsze wydanie",
"zh-cn": "首次出版"
}

@@ -130,4 +131,4 @@ },

"enabled": true,
"extIcon": "https://raw.githubusercontent.com/Newan/ioBroker.evcc/master/admin/evcc.png",
"readme": "https://github.com/Newan/ioBroker.evcc/blob/master/README.md",
"extIcon": "https://raw.githubusercontent.com/Newan/ioBroker.evcc/main/admin/evcc.png",
"readme": "https://github.com/Newan/ioBroker.evcc/blob/main/README.md",
"loglevel": "info",

@@ -134,0 +135,0 @@ "mode": "daemon",

{
"name": "iobroker.evcc",
"version": "0.0.10",
"version": "0.1.0",
"description": "Controll evcc over rest api",

@@ -19,28 +19,28 @@ "author": {

"dependencies": {
"@iobroker/adapter-core": "^2.6.0",
"@iobroker/adapter-core": "^2.6.8",
"axios": "^0.27.2"
},
"devDependencies": {
"@alcalzone/release-script": "^3.5.8",
"@alcalzone/release-script": "^3.5.9",
"@alcalzone/release-script-plugin-iobroker": "^3.5.9",
"@alcalzone/release-script-plugin-license": "^3.5.9",
"@iobroker/adapter-dev": "^1.0.1",
"@iobroker/testing": "^4.0.0",
"@types/chai": "^4.3.3",
"@iobroker/adapter-dev": "^1.2.0",
"@iobroker/testing": "^4.1.0",
"@types/chai": "^4.3.5",
"@types/chai-as-promised": "^7.1.5",
"@types/mocha": "^9.1.1",
"@types/node": "^14.18.26",
"@types/node": "^14.18.53",
"@types/proxyquire": "^1.3.28",
"@types/sinon": "^10.0.13",
"@types/sinon-chai": "^3.2.8",
"@typescript-eslint/eslint-plugin": "^5.35.1",
"@typescript-eslint/parser": "^5.35.1",
"chai": "^4.3.6",
"@types/sinon": "^10.0.15",
"@types/sinon-chai": "^3.2.9",
"@typescript-eslint/eslint-plugin": "^5.60.1",
"@typescript-eslint/parser": "^5.60.1",
"chai": "^4.3.7",
"chai-as-promised": "^7.1.1",
"eslint": "^8.23.0",
"eslint-plugin-react": "^7.32.0",
"mocha": "^10.0.0",
"eslint": "^8.44.0",
"eslint-plugin-react": "^7.32.2",
"mocha": "^10.2.0",
"proxyquire": "^2.1.3",
"rimraf": "^3.0.2",
"sinon": "^14.0.0",
"sinon": "^14.0.2",
"sinon-chai": "^3.7.0",

@@ -47,0 +47,0 @@ "source-map-support": "^0.5.21",

@@ -25,2 +25,6 @@ ![Logo](admin/evcc.png)

-->
### 0.1.0 (2023-12-30)
* (Newan) rewrite for evcc api changes
* (Newan) add multiple vehicle
### 0.0.10 (2023-06-14)

@@ -31,16 +35,16 @@ * (arteck) generate dynamic objects

### 0.0.8 (2023-05-09)
* fix for minSoc & targetSoc
* (Newan) fix for minSoc & targetSoc
### 0.0.7 (2023-01-15)
* Update for evcc 1.11.x
* Bugfix #4, change SoC names
* (Newan) Update for evcc 1.11.x
* (Newan) Bugfix #4, change SoC names
### 0.0.5 (2022-10-14)
* update for latest-repository
* (Newan) update for latest-repository
### 0.0.4 (2022-08-08)
* first release
* (Newan) first release
### 0.0.3 (2022-05-21)
(Newan) support evcc 0.9X - change to jsonConfig GUI
* (Newan) support evcc 0.9X - change to jsonConfig GUI

@@ -47,0 +51,0 @@ ### 0.0.2 (2021-11-07)

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc