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

iobroker.easee

Package Overview
Dependencies
Maintainers
2
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

iobroker.easee - npm Package Compare versions

Comparing version 0.1.1 to 1.0.1

lib/enum.js

0

admin/admin.d.ts

@@ -0,0 +0,0 @@ declare let systemDictionary: Record<string, Record<string, string>>;

106

admin/words.js

@@ -0,1 +1,2 @@

/* eslint-disable no-unused-vars */
/*global systemDictionary:true */

@@ -17,39 +18,74 @@ 'use strict';

},
'username': {
"en": "username",
"de": "Nutzername",
"ru": "имя пользователя",
"pt": "nome de usuário",
"nl": "gebruikersnaam",
"fr": "Nom d'utilisateur",
"it": "nome utente",
"es": "nombre de usuario",
"pl": "Nazwa Użytkownika",
"zh-cn": "用户名"
},
'password': {
"en": "password",
"de": "Passwort",
"ru": "пароль",
"pt": "senha",
"nl": "wachtwoord",
"fr": "le mot de passe",
"it": "parola d'ordine",
"es": "contraseña",
"pl": "hasło",
"zh-cn": "密码"
'Username': {
'en': 'Username',
'de': 'Nutzername',
'ru': 'имя пользователя',
'pt': 'nome de usuário',
'nl': 'gebruikersnaam',
'fr': "Nom d'utilisateur",
'it': 'nome utente',
'es': 'nombre de usuario',
'pl': 'Nazwa Użytkownika',
'zh-cn': '用户名'
},
'polltime': {
"en": "Poll interval in seconds",
"de": "Abfrageintervall in Sekunden",
"ru": "Интервал опроса в секундах",
"pt": "Intervalo de enquete em segundos",
"nl": "Poll-interval in seconden",
"fr": "Intervalle d'interrogation en secondes",
"it": "Intervallo di polling in secondi",
"es": "Intervalo de encuesta en segundos",
"pl": "Okres odpytywania w sekundach",
"zh-cn": "轮询间隔(秒)"
'Password': {
'en': 'Password',
'de': 'Passwort',
'ru': 'пароль',
'pt': 'senha',
'nl': 'wachtwoord',
'fr': 'le mot de passe',
'it': "parola d'ordine",
'es': 'contraseña',
'pl': 'hasło',
'zh-cn': '密码'
},
'Poll interval in seconds': {
'en': 'Poll interval in seconds',
'de': 'Abfrageintervall in Sekunden',
'ru': 'Интервал опроса в секундах',
'pt': 'Intervalo de enquete em segundos',
'nl': 'Poll-interval in seconden',
'fr': "Intervalle d'interrogation en secondes",
'it': 'Intervallo di polling in secondi',
'es': 'Intervalo de encuesta en segundos',
'pl': 'Okres odpytywania w sekundach',
'zh-cn': '轮询间隔(秒)'
},
'Api settings': {
'en': 'Api settings',
'de': 'API-Einstellungen',
'ru': 'Настройки API',
'pt': 'Configurações de API',
'nl': 'API-instellingen',
'fr': "Paramètres de l'API",
'it': 'Impostazioni API',
'es': 'Configuración de api',
'pl': 'Ustawienia API',
'zh-cn': 'api设置'
},
'Account settings': {
'en': 'Account settings',
'de': 'Kontoeinstellungen',
'ru': 'Настройки учетной записи',
'pt': 'Configurações de Conta',
'nl': 'Account instellingen',
'fr': 'Paramètres du compte',
'it': "Impostazioni dell'account",
'es': 'Configuraciones de la cuenta',
'pl': 'Ustawienia konta',
'zh-cn': ',帐号设定'
},
'Use SignalR': {
'en': 'Use SignalR',
'de': 'SignalR verwenden',
'ru': 'Используйте SignalR',
'pt': 'Use SignalR',
'nl': 'Gebruik SignalR',
'fr': 'Utiliser SignalR',
'it': 'Usa SignalR',
'es': 'Usar SignalR',
'pl': 'Użyj SignalR',
'zh-cn': '使用SignalR'
}
};
{
"common": {
"name": "easee",
"version": "0.1.1",
"version": "1.0.1",
"news": {
"1.0.1": {
"en": "Add circuitMaxCurrentPX to limit current ampere",
"de": "circuitMaxCurrentPX hinzugefügt für Amperebegrenzung"
},
"1.0.0": {
"en": "Add SignalR support",
"de": "SignalR Unterstützung hinzugefügt"
},
"0.1.4": {
"en": "Add new objects",
"de": "Neue Objekte hinzugefügt"
},
"0.1.3": {
"en": "Add #2 max Ampere changeable",
"de": "Hinzugefügt #2 maximale Ampere einstellbar"
},
"0.1.2": {
"en": "Object reconstruction",
"de": "Objektumbau"
},
"0.1.1": {

@@ -66,3 +86,3 @@ "en": "Password encrypt + bugfix for the stable version",

{
"js-controller": ">=2.0.0"
"js-controller": ">=3.1.0"
}

@@ -73,4 +93,5 @@ ]

"username": "+49",
"password": "pass",
"polltime": 30
"client_secret": "",
"polltime": 30,
"signalR": false
},

@@ -77,0 +98,0 @@ "objects": [],

@@ -0,0 +0,0 @@ // This file extends the AdapterConfig type from "@types/iobroker"

@@ -0,0 +0,0 @@ const axios = require('axios').default;

@@ -6,12 +6,17 @@ 'use strict';

const axios = require('axios').default;
const signalR = require('@microsoft/signalr');
const objEnum = require('./lib/enum.js');
//Eigene Variablen
const apiUrl = "https://api.easee.cloud";
//Eigene Variablen
const apiUrl = 'https://api.easee.cloud';
const adapterIntervals = {}; //halten von allen Intervallen
var accessToken = "";
var refreshToken = "";
var expireTime = Date.now();
var polltime = 30;
var minPollTimeEnergy = 120;
var roundCounter = 0;
let accessToken = '';
let refreshToken = '';
let expireTime = Date.now();
let polltime = 30;
let password = '';
const minPollTimeEnergy = 120;
let roundCounter = 0;
const arrCharger = [];
class Easee extends utils.Adapter {

@@ -33,4 +38,42 @@

/**
* Starten den Adapter
* SignalR
*/
startSignal(){
const connection = new signalR.HubConnectionBuilder()
.withUrl('https://api.easee.cloud/hubs/chargers', { accessTokenFactory: () => accessToken })
.withAutomaticReconnect()
.build();
connection.on('ProductUpdate', data => {
//haben einen neuen Wert über SIgnalR erhalten
if(objEnum.getNameByEnum(data.id) == undefined) {
this.log.debug('New SignalR-ID, possible new Value: ' + data.id);
this.log.debug(JSON.stringify(data));
} else {
//Value is in ioBroker, update it
const tmpValueId = data.mid + objEnum.getNameByEnum(data.id);
this.log.info('New value over SignalR for: ' + tmpValueId + 'value: ' + data.value);
this.setStateAsync(tmpValueId, { val: data.value, ack: true });
}
});
connection.start().then(() => {
//for each charger subscribe SignalR
arrCharger.forEach(charger => {
connection.send('SubscribeWithCurrentState', 'EH530097', true).then(() => {
this.log.info('Charger registrate in SignalR: ' + charger.id);
});
});
});
connection.onclose(() => {
this.log.error('SignalR Verbindung beendet!!!- restart');
this.startSignal();
});
}
/**
* Starten den Adapter
*/
async onReady() {

@@ -53,25 +96,26 @@

if (this.config.polltime < 1) {
this.log.error("Interval in seconds to short -> got to default 30")
this.log.error('Interval in seconds to short -> got to default 30');
} else {
polltime = this.config.polltime;
}
// Testen ob der Login funktioniert
if (this.config.username == '' ) {
this.log.error("No username set");
this.log.error('No username set');
//Status melden
await this.setStateAsync('online', false);
} else {
this.config.password = ''; //reset old passwords
password = ''; //reset old passwords
this.getForeignObject('system.config', async (err, obj) => {
if ((obj && obj.native && obj.native.secret) || this.config.client_secret == '') {
this.log.info("Secret is: " + this.config.client_secret);
this.log.info('Secret is: ' + this.config.client_secret);
this.config.password = decrypt(obj.native.secret, this.config.client_secret);
this.log.info("Password decrypted");
this.log.debug("Password is:" + this.config.password);
// @ts-ignore
password = decrypt(obj.native.secret, this.config.client_secret);
this.log.info('Password decrypted');
this.log.debug('Password is:' + password);
var login = await this.login(this.config.username, this.config.password);
const login = await this.login(this.config.username, password);
if (login) {

@@ -90,18 +134,27 @@ //Erstes Objekt erstellen

});
//reset all to start
this.arrCharger = [];
// starten den Statuszyklus der API neu
await this.readAllStates();
if (this.config.signalR) {
this.log.info('Starting SignalR');
this.startSignal();
}
} else {
//Login hat nicht funktionert, Adapter kann nicht gestartet werden
//Errohandling in der Loginfunktion derzeit
}
}
} else {
this.log.error("No password set");
this.log.error('No password set');
//Status melden
await this.setStateAsync('online', false);
}
});
}

@@ -129,37 +182,51 @@ }

//Token ist expired!
this.log.info("Token is Expired - refresh")
await this.refreshToken()
}
this.log.info('Token is Expired - refresh');
await this.refreshToken();
}
this.log.info("read new states from the API")
this.log.info('read new states from the API');
//Lesen alle Charger aus
let tmpAllChargers = await this.getAllCharger();
tmpAllChargers.forEach(async charger => {
this.log.debug("Charger gefunden")
this.log.debug(JSON.stringify(charger));
//Lesen den Status aus
let tmpChargerState = await this.getChargerState(charger.id);
//Lesen die config
let tmpChargerConfig = await this.getChargerConfig(charger.id);
const tmpAllChargers = await this.getAllCharger();
if (tmpAllChargers != undefined) {
tmpAllChargers.forEach(async charger => {
//Prüfen ob wir das Object kennen
if (!arrCharger.includes(charger.id)) {
//setzen als erstes alle Objekte
await this.setAllStatusObjects(charger);
await this.setAllConfigObjects(charger);
//Setzen die Daten der Charger
await this.setNewStatusToCharger(charger, tmpChargerState);
//meken uns den charger
arrCharger.push(charger.id);
}
//Setzen die Config zum Charger
await this.setNewConfigToCharger(charger, tmpChargerConfig);
this.log.debug('Charger gefunden');
this.log.debug(JSON.stringify(charger));
//setzen und erechnen der Energiedaten, aber gebremste
if(roundCounter > (minPollTimeEnergy/polltime)) {
//lesen der Energiedaten
let tmpChargerSession = await this.getChargerSession(charger.id);
//etzen die Objekte
this.setNewSessionToCharger(charger, tmpChargerSession)
}
});
//Lesen den Status aus
const tmpChargerState = await this.getChargerState(charger.id);
//Lesen die config
const tmpChargerConfig = await this.getChargerConfig(charger.id);
//Setzen die Daten der Charger
await this.setNewStatusToCharger(charger, tmpChargerState);
//Setzen die Config zum Charger
await this.setConfigStatus(charger, tmpChargerConfig);
//setzen und erechnen der Energiedaten, aber gebremste
if(roundCounter > (minPollTimeEnergy/polltime)) {
//lesen der Energiedaten
const tmpChargerSession = await this.getChargerSession(charger.id);
//etzen die Objekte
this.setNewSessionToCharger(charger, tmpChargerSession);
}
});
} else {
this.log.warn('No Chargers found!');
}
//Energiedaten dürfen nur einmal in der Minute aufgerufen werden, daher müssen wir das bremsen
if(roundCounter > (minPollTimeEnergy/polltime)) {
this.log.info("Hole Energiedaten: " + roundCounter)
this.log.info('Hole Energiedaten: ' + roundCounter);
roundCounter = 0;

@@ -171,4 +238,4 @@ }

//Melden das Update
await this.setStateAsync('lastUpdate', new Date().toLocaleTimeString());
adapterIntervals.readAllStates = setTimeout(this.readAllStates.bind(this), polltime * 1000);
await this.setStateAsync('lastUpdate', new Date().toLocaleTimeString());
adapterIntervals.readAllStates = setTimeout(this.readAllStates.bind(this), polltime * 1000);
}

@@ -185,16 +252,33 @@

this.log.info(`state ${id} changed: ${state.val} (ack = ${state.ack})`);
let tmpControl = id.split('.');
if (tmpControl[3] == "config") {
const tmpControl = id.split('.');
if (tmpControl[3] == 'config') {
// change config, wenn ack = false
if (!state.ack) {
this.log.debug("update config to API: " + id);
this.changeConfig(tmpControl[2], tmpControl[4], state.val);
this.log.info("Changes send to API");
if (tmpControl[4] == 'circuitMaxCurrentP1' || tmpControl[4] == 'circuitMaxCurrentP2' || tmpControl[4] == 'circuitMaxCurrentP3') {
//Load site for Charger
this.getChargerSite(tmpControl[2]).then( (site) => {
this.log.debug('Update circuitMaxCurrent to: ' + state.val);
this.log.debug('Get infos from site:');
this.log.debug(JSON.stringify(site));
this.log.debug('Get infos from site:');
this.log.debug(JSON.stringify(site));
this.changeCircuitConfig(site.id, site.circuits[0].id, state.val);
this.log.info('Changes send to API');
});
} else {
this.log.debug('update config to API: ' + id);
this.changeConfig(tmpControl[2], tmpControl[4], state.val);
this.log.info('Changes send to API');
}
}
} else {
// control charger
// control charger
switch (tmpControl[4]) {
case 'start':
// Starten Ladevorgang
this.log.info("Starting charging for Charger.id: " + tmpControl[2]);
this.log.info('Starting charging for Charger.id: ' + tmpControl[2]);
this.startCharging(tmpControl[2]);

@@ -204,23 +288,23 @@ break;

// Stopen Ladevorgang
this.log.info("Stopping charging for Charger.id: " + tmpControl[2]);
this.stopCharging(tmpControl[2]);
break;
this.log.info('Stopping charging for Charger.id: ' + tmpControl[2]);
this.stopCharging(tmpControl[2]);
break;
case 'pause':
// Pausiere Ladevorgang
this.log.info("Pause charging for Charger.id: " + tmpControl[2]);
this.log.info('Pause charging for Charger.id: ' + tmpControl[2]);
this.pauseCharging(tmpControl[2]);
break;
break;
case 'resume':
// Resume Ladevorgang
this.log.info("Resume charging for Charger.id: " + tmpControl[2]);
this.resumeCharging(tmpControl[2]);
break;
this.log.info('Resume charging for Charger.id: ' + tmpControl[2]);
this.resumeCharging(tmpControl[2]);
break;
case 'reboot':
// Reboot Charger
this.log.info("Reboot Charger.id: " + tmpControl[2]);
this.rebootCharging(tmpControl[2]);
break;
this.log.info('Reboot Charger.id: ' + tmpControl[2]);
this.rebootCharging(tmpControl[2]);
break;
default:
this.log.error("No command for Control found for: " + id)
}
this.log.error('No command for Control found for: ' + id);
}
}

@@ -233,13 +317,51 @@ } else {

/*onStateChange(id, state) {
if (state) {
}
} else {
// The state was deleted
this.log.error(`state ${id} deleted`);
}
}*/
/***********************************************************************
* Funktionen für Status der Reading um den Code aufgeräumter zu machen
***********************************************************************/
//Setzen alle Status für Charger
async setNewStatusToCharger(charger, charger_states) {
await this.setStateAsync(charger.id + '.name', charger.name);
await this.setStateAsync(charger.id + '.status.cableLocked', charger_states.cableLocked);
await this.setStateAsync(charger.id + '.status.chargerOpMode', charger_states.chargerOpMode);
await this.setStateAsync(charger.id + '.status.totalPower', charger_states.totalPower);
await this.setStateAsync(charger.id + '.status.wiFiRSSI', charger_states.wiFiRSSI);
await this.setStateAsync(charger.id + '.status.chargerFirmware', charger_states.chargerFirmware);
await this.setStateAsync(charger.id + '.status.latestFirmware', charger_states.latestFirmware);
await this.setStateAsync(charger.id + '.status.voltage', charger_states.voltage);
await this.setStateAsync(charger.id + '.status.outputCurrent', charger_states.outputCurrent);
await this.setStateAsync(charger.id + '.status.isOnline', charger_states.isOnline);
await this.setStateAsync(charger.id + '.status.wiFiAPEnabled', charger_states.wiFiAPEnabled);
await this.setStateAsync(charger.id + '.status.lifetimeEnergy', charger_states.lifetimeEnergy);
await this.setStateAsync(charger.id + '.status.energyPerHour', charger_states.energyPerHour);
await this.setStateAsync(charger.id + '.status.inCurrentT2', charger_states.inCurrentT2);
await this.setStateAsync(charger.id + '.status.inCurrentT3', charger_states.inCurrentT3);
await this.setStateAsync(charger.id + '.status.inCurrentT4', charger_states.inCurrentT4);
await this.setStateAsync(charger.id + '.status.inCurrentT5', charger_states.inCurrentT5);
//wert der config wird nur hier gesendet
await this.setStateAsync(charger.id + '.config.dynamicChargerCurrent', { val: charger_states.dynamicChargerCurrent, ack: true });
await this.setStateAsync(charger.id + '.config.dynamicCircuitCurrentP1', { val: charger_states.dynamicCircuitCurrentP1, ack: true });
await this.setStateAsync(charger.id + '.config.dynamicCircuitCurrentP2', { val: charger_states.dynamicCircuitCurrentP2, ack: true });
await this.setStateAsync(charger.id + '.config.dynamicCircuitCurrentP3', { val: charger_states.dynamicCircuitCurrentP3, ack: true });
}
//Setzen alle Status für Config
async setConfigStatus(charger, charger_config) {
await this.setStateAsync(charger.id + '.config.isEnabled',{ val: charger_config.isEnabled, ack: true } );
await this.setStateAsync(charger.id + '.config.phaseMode', { val: charger_config.phaseMode, ack: true });
await this.setStateAsync(charger.id + '.config.ledStripBrightness', { val: charger_config.ledStripBrightness, ack: true });
await this.setStateAsync(charger.id + '.config.wiFiSSID', { val: charger_config.wiFiSSID, ack: true });
await this.setStateAsync(charger.id + '.config.maxChargerCurrent', { val: charger_config.maxChargerCurrent, ack: true });
//Values for sites
await this.setStateAsync(charger.id + '.config.circuitMaxCurrentP1', { val: charger_config.circuitMaxCurrentP1, ack: true });
await this.setStateAsync(charger.id + '.config.circuitMaxCurrentP2', { val: charger_config.circuitMaxCurrentP3, ack: true });
await this.setStateAsync(charger.id + '.config.circuitMaxCurrentP3', { val: charger_config.circuitMaxCurrentP3, ack: true });
}
/*************************************************************************

@@ -255,7 +377,7 @@ * API CALLS

const response = await axios.post(apiUrl + '/api/accounts/token', {
userName: username,
password: password
});
userName: username,
password: password
});
this.log.info("Login successful")
this.log.info('Login successful');

@@ -274,15 +396,15 @@ accessToken = response.data.accessToken;

async refreshToken() {
return await axios.post(apiUrl + '/api/accounts/refresh_token', {
return await axios.post(apiUrl + '/api/accounts/refresh_token', {
accessToken: accessToken,
refreshToken: refreshToken
}).then(response => {
this.log.info("RefreshToken successful");
this.log.info('RefreshToken successful');
accessToken = response.data.accessToken;
refreshToken = response.data.refreshToken;
expireTime = Date.now() + (response.data.expiresIn - (polltime * 2)) * 1000;
this.log.debug(JSON.stringify(response.data));
}).catch((error) => {
this.log.error("RefreshToken error");
this.log.error(error)
this.log.error('RefreshToken error');
this.log.error(error);
});

@@ -293,10 +415,10 @@ }

async getAllCharger(){
return await axios.get(apiUrl + '/api/chargers' ,
{ headers: {"Authorization" : `Bearer ${accessToken}`}
}).then(response => {
this.log.debug("Chargers ausgelesen");
return await axios.get(apiUrl + '/api/chargers' ,
{ headers: {'Authorization' : `Bearer ${accessToken}`}
}).then(response => {
this.log.debug('Chargers ausgelesen');
this.log.debug(JSON.stringify(response.data));
return response.data
return response.data;
}).catch((error) => {
this.log.error(error)
this.log.error(error);
});

@@ -307,10 +429,10 @@ }

async getChargerState(charger_id){
return await axios.get(apiUrl + '/api/chargers/' + charger_id +'/state',
{ headers: {"Authorization" : `Bearer ${accessToken}`}
}).then(response => {
this.log.debug("Charger status ausgelesen mit id: " + charger_id);
return await axios.get(apiUrl + '/api/chargers/' + charger_id +'/state',
{ headers: {'Authorization' : `Bearer ${accessToken}`}
}).then(response => {
this.log.debug('Charger status ausgelesen mit id: ' + charger_id);
this.log.debug(JSON.stringify(response.data));
return response.data
return response.data;
}).catch((error) => {
this.log.error(error)
this.log.error(error);
});

@@ -320,22 +442,34 @@ }

async getChargerConfig(charger_id){
return await axios.get(apiUrl + '/api/chargers/' + charger_id +'/config',
{ headers: {"Authorization" : `Bearer ${accessToken}`}
}).then(response => {
this.log.debug("Charger config ausgelesen mit id: " + charger_id);
return await axios.get(apiUrl + '/api/chargers/' + charger_id +'/config',
{ headers: {'Authorization' : `Bearer ${accessToken}`}
}).then(response => {
this.log.debug('Charger config ausgelesen mit id: ' + charger_id);
this.log.debug(JSON.stringify(response.data));
return response.data
return response.data;
}).catch((error) => {
this.log.error(error)
this.log.error(error);
});
}
async getChargerSite(charger_id){
return await axios.get(apiUrl + '/api/chargers/' + charger_id +'/site',
{ headers: {'Authorization' : `Bearer ${accessToken}`}
}).then(response => {
this.log.debug('Charger site ausgelesen mit id: ' + charger_id);
this.log.debug(JSON.stringify(response.data));
return response.data;
}).catch((error) => {
this.log.error(error);
});
}
async getChargerSession(charger_id){
return await axios.get(apiUrl + '/api/sessions/charger/' + charger_id +'/monthly',
{ headers: {"Authorization" : `Bearer ${accessToken}`}
}).then(response => {
this.log.debug("Charger session ausgelesen mit id: " + charger_id);
return await axios.get(apiUrl + '/api/sessions/charger/' + charger_id +'/monthly',
{ headers: {'Authorization' : `Bearer ${accessToken}`}
}).then(response => {
this.log.debug('Charger session ausgelesen mit id: ' + charger_id);
this.log.debug(JSON.stringify(response.data));
return response.data
return response.data;
}).catch((error) => {
this.log.error(error)
this.log.error(error);
});

@@ -346,9 +480,9 @@ }

return await axios.post(apiUrl + '/api/chargers/' + id + '/commands/start_charging', {},
{ headers: {"Authorization" : `Bearer ${accessToken}`}}
{ headers: {'Authorization' : `Bearer ${accessToken}`}}
).then(response => {
this.log.info("Start charging successful");
this.log.info('Start charging successful');
this.log.debug(JSON.stringify(response.data));
}).catch((error) => {
this.log.error("Start charging error");
this.log.error(error)
this.log.error('Start charging error');
this.log.error(error);
});

@@ -359,9 +493,9 @@ }

return await axios.post(apiUrl + '/api/chargers/' + id + '/commands/stop_charging', {},
{ headers: {"Authorization" : `Bearer ${accessToken}`}}
{ headers: {'Authorization' : `Bearer ${accessToken}`}}
).then(response => {
this.log.info("Stop charging successful");
this.log.info('Stop charging successful');
this.log.debug(JSON.stringify(response.data));
}).catch((error) => {
this.log.error("Stop charging error");
this.log.error(error)
this.log.error('Stop charging error');
this.log.error(error);
});

@@ -372,9 +506,9 @@ }

return await axios.post(apiUrl + '/api/chargers/' + id + '/commands/pause_charging', {},
{ headers: {"Authorization" : `Bearer ${accessToken}`}}
{ headers: {'Authorization' : `Bearer ${accessToken}`}}
).then(response => {
this.log.info("Pause charging successful");
this.log.info('Pause charging successful');
this.log.debug(JSON.stringify(response.data));
}).catch((error) => {
this.log.error("Pause charging error");
this.log.error(error)
this.log.error('Pause charging error');
this.log.error(error);
});

@@ -385,9 +519,9 @@ }

return await axios.post(apiUrl + '/api/chargers/' + id + '/commands/resume_charging', {},
{ headers: {"Authorization" : `Bearer ${accessToken}`}}
{ headers: {'Authorization' : `Bearer ${accessToken}`}}
).then(response => {
this.log.info("Resume charging successful");
this.log.info('Resume charging successful');
this.log.debug(JSON.stringify(response.data));
}).catch((error) => {
this.log.error("Resume charging error");
this.log.error(error)
this.log.error('Resume charging error');
this.log.error(error);
});

@@ -398,9 +532,9 @@ }

return await axios.post(apiUrl + '/api/chargers/' + id + '/commands/reboot', {},
{ headers: {"Authorization" : `Bearer ${accessToken}`}}
{ headers: {'Authorization' : `Bearer ${accessToken}`}}
).then(response => {
this.log.info("Reboot charging successful");
this.log.info('Reboot charging successful');
this.log.debug(JSON.stringify(response.data));
}).catch((error) => {
this.log.error("Reboot charging error");
this.log.error(error)
this.log.error('Reboot charging error');
this.log.error(error);
});

@@ -416,20 +550,35 @@ }

[configvalue]: value
},
{ headers: {"Authorization" : `Bearer ${accessToken}`}}
},
{ headers: {'Authorization' : `Bearer ${accessToken}`}}
).then(response => {
this.log.info("Config update successful");
this.log.info('Config update successful');
this.log.debug(JSON.stringify(response.data));
}).catch((error) => {
this.log.error("Config update error");
this.log.error(error)
this.log.error('Config update error');
this.log.error(error);
});
}
//circuitMaxCurrentPX
async changeCircuitConfig(site_id, circuit_id, value) {
return await axios.post(apiUrl + '/api/sites/' + site_id + '/circuits/' + circuit_id + '/settings', {
'maxCircuitCurrentP1': value,
'maxCircuitCurrentP2': value,
'maxCircuitCurrentP3': value,
},
{ headers: {'Authorization' : `Bearer ${accessToken}`}}
).then(response => {
this.log.info('Circuit update successful');
this.log.debug(JSON.stringify(response.data));
}).catch((error) => {
this.log.error('Circuit update error');
this.log.error(error);
});
}
/***********************************************************************
* Funktionen für Status der Reading um den Code aufgeräumter zu machen
***********************************************************************/
* Funktionen zum erstellen der Objekte der Reading
***********************************************************************/
//Setzen alle Status für Charger
async setNewStatusToCharger(charger, charger_states) {
async setAllStatusObjects(charger) {
//Legen die Steurungsbutton für jeden Charger an

@@ -439,5 +588,5 @@ await this.setObjectNotExistsAsync(charger.id + '.control.start', {

common: {
name: "Start charging",
type: "boolean",
role: "button",
name: 'Start charging',
type: 'boolean',
role: 'button',
read: true,

@@ -453,5 +602,5 @@ write: true,

common: {
name: "Stop charging",
type: "boolean",
role: "button",
name: 'Stop charging',
type: 'boolean',
role: 'button',
read: false,

@@ -467,5 +616,5 @@ write: true,

common: {
name: "Pause charging",
type: "boolean",
role: "button",
name: 'Pause charging',
type: 'boolean',
role: 'button',
read: false,

@@ -481,5 +630,5 @@ write: true,

common: {
name: "Resume charging",
type: "boolean",
role: "button",
name: 'Resume charging',
type: 'boolean',
role: 'button',
read: false,

@@ -495,5 +644,5 @@ write: true,

common: {
name: "Reboot Charger",
type: "boolean",
role: "button",
name: 'Reboot Charger',
type: 'boolean',
role: 'button',
read: true,

@@ -506,3 +655,2 @@ write: true,

//id

@@ -520,4 +668,4 @@ await this.setObjectNotExistsAsync(charger.id + '.id', {

});
this.setState(charger.id + '.id', charger.id);
await this.setStateAsync(charger.id + '.id', charger.id);
//name

@@ -535,3 +683,2 @@ await this.setObjectNotExistsAsync(charger.id + '.name', {

});
this.setState(charger.id + '.name', charger.name);

@@ -542,3 +689,3 @@ //"cableLocked": true,

common: {
name: 'cableLocked',
name: 'Cable lock state',
type: 'boolean',

@@ -551,9 +698,8 @@ role: 'indicator',

});
this.setState(charger.id + '.status.cableLocked', charger_states.cableLocked);
//"chargerOpMode": 1,
await this.setObjectNotExistsAsync(charger.id + '.status.chargerOpMode', {
//"chargerOpMode": 1,
await this.setObjectNotExistsAsync(charger.id + '.status.chargerOpMode', {
type: 'state',
common: {
name: 'chargerOpMode',
name: 'Charger operation mode according to charger mode table',
type: 'number',

@@ -566,9 +712,8 @@ role: 'indicator',

});
this.setState(charger.id + '.status.chargerOpMode', charger_states.chargerOpMode);
//"totalPower": 0,
await this.setObjectNotExistsAsync(charger.id + '.status.totalPower', {
//"totalPower": 0,
await this.setObjectNotExistsAsync(charger.id + '.status.totalPower', {
type: 'state',
common: {
name: 'totalPower',
name: 'Total power [kW]',
type: 'number',

@@ -581,3 +726,2 @@ role: 'indicator',

});
this.setState(charger.id + '.status.totalPower', charger_states.totalPower);

@@ -588,3 +732,3 @@ //"wiFiRSSI": 0,

common: {
name: 'wiFiRSSI',
name: 'WiFi signal strength [dBm]',
type: 'number',

@@ -597,3 +741,2 @@ role: 'indicator',

});
this.setState(charger.id + '.status.wiFiRSSI', charger_states.wiFiRSSI);

@@ -604,3 +747,3 @@ //"chargerFirmware": 0,

common: {
name: 'chargerFirmware',
name: 'Modem firmware version',
type: 'number',

@@ -613,3 +756,2 @@ role: 'indicator',

});
this.setState(charger.id + '.status.chargerFirmware', charger_states.chargerFirmware);

@@ -620,3 +762,3 @@ //"latestFirmware": 0,

common: {
name: 'latestFirmware',
name: 'Latest Modem firmware version',
type: 'number',

@@ -629,3 +771,2 @@ role: 'indicator',

});
this.setState(charger.id + '.status.latestFirmware', charger_states.latestFirmware);

@@ -644,3 +785,2 @@ //"voltage": 0,

});
this.setState(charger.id + '.status.voltage', charger_states.voltage);

@@ -651,3 +791,3 @@ //"outputCurrent": 0,

common: {
name: 'outputCurrent',
name: 'Active output phase(s) to EV according to output phase type table.',
type: 'number',

@@ -660,4 +800,55 @@ role: 'indicator',

});
this.setState(charger.id + '.status.outputCurrent', charger_states.outputCurrent);
//"inCurrentT2": 0,
await this.setObjectNotExistsAsync(charger.id + '.status.inCurrentT2', {
type: 'state',
common: {
name: 'Current RMS for input T2 [Amperes]',
type: 'number',
role: 'indicator',
read: true,
write: false,
},
native: {},
});
//"inCurrentT3": 0,
await this.setObjectNotExistsAsync(charger.id + '.status.inCurrentT3', {
type: 'state',
common: {
name: 'Current RMS for input T3 [Amperes]',
type: 'number',
role: 'indicator',
read: true,
write: false,
},
native: {},
});
//"inCurrentT4": 0,
await this.setObjectNotExistsAsync(charger.id + '.status.inCurrentT4', {
type: 'state',
common: {
name: 'Current RMS for input T4 [Amperes]',
type: 'number',
role: 'indicator',
read: true,
write: false,
},
native: {},
});
//"inCurrentT5": 0,
await this.setObjectNotExistsAsync(charger.id + '.status.inCurrentT5', {
type: 'state',
common: {
name: 'Current RMS for input T5 [Amperes]',
type: 'number',
role: 'indicator',
read: true,
write: false,
},
native: {},
});
//"isOnline": true,

@@ -675,3 +866,2 @@ await this.setObjectNotExistsAsync(charger.id + '.status.isOnline', {

});
this.setState(charger.id + '.status.isOnline', charger_states.isOnline);

@@ -682,3 +872,3 @@ //"wiFiAPEnabled": true,

common: {
name: 'wiFiAPEnabled',
name: 'True if WiFi Access Point is enabled, otherwise false',
type: 'boolean',

@@ -691,3 +881,57 @@ role: 'indicator',

});
this.setState(charger.id + '.status.wiFiAPEnabled', charger_states.wiFiAPEnabled);
//"lifetimeEnergy": 0,
await this.setObjectNotExistsAsync(charger.id + '.status.lifetimeEnergy', {
type: 'state',
common: {
name: 'Accumulated energy in the lifetime of the charger [kWh]',
type: 'number',
role: 'indicator',
read: true,
write: false,
},
native: {},
});
//"energyPerHour": 0,
await this.setObjectNotExistsAsync(charger.id + '.status.energyPerHour', {
type: 'state',
common: {
name: 'Accumulated energy per hour [kWh]',
type: 'number',
role: 'indicator',
read: true,
write: false,
},
native: {},
});
//"energyPerHour": 0,
await this.setObjectNotExistsAsync(charger.id + '.status.energyPerHour', {
type: 'state',
common: {
name: 'Accumulated energy per hour [kWh]',
type: 'number',
role: 'indicator',
read: true,
write: false,
},
native: {},
});
// Ab hier nur Objekte die über SignalR kommen
//TempMax
await this.setObjectNotExistsAsync(charger.id + '.status.TempMax', {
type: 'state',
common: {
name:'SignaleR only: Maximum temperature for all sensors [Celsius]',
type: 'number',
role: 'indicator',
read: true,
write: false,
},
native: {},
});
}

@@ -698,3 +942,3 @@

this.log.debug(JSON.stringify(charger_session));
charger_session.forEach(async session => {
charger_session.forEach(async session => {

@@ -712,4 +956,4 @@ //für jeden Monat errechnen wir das?

native: {},
});
this.setState(charger.id + '.session.' + session.year + '.' + session.month+ '.totalEnergyUsage', session.totalEnergyUsage);
});
await this.setStateAsync(charger.id + '.session.' + session.year + '.' + session.month+ '.totalEnergyUsage', session.totalEnergyUsage);

@@ -726,4 +970,4 @@ await this.setObjectNotExistsAsync(charger.id + '.session.' + session.year + '.' + session.month+ '.totalCost', {

native: {},
});
this.setState(charger.id + '.session.' + session.year + '.' + session.month+ '.totalCost', session.totalCost);
});
await this.setStateAsync(charger.id + '.session.' + session.year + '.' + session.month+ '.totalCost', session.totalCost);

@@ -740,4 +984,4 @@ await this.setObjectNotExistsAsync(charger.id + '.session.' + session.year + '.' + session.month+ '.currencyId', {

native: {},
});
this.setState(charger.id + '.session.' + session.year + '.' + session.month+ '.currencyId', session.currencyId);
});
await this.setStateAsync(charger.id + '.session.' + session.year + '.' + session.month+ '.currencyId', session.currencyId);

@@ -754,5 +998,5 @@ await this.setObjectNotExistsAsync(charger.id + '.session.' + session.year + '.total_year', {

native: {},
});
});
});

@@ -762,3 +1006,3 @@

let tmpYearCount = 0;
charger_session.forEach(session => {
charger_session.forEach(session => {
//Jahreszähler umhängen

@@ -768,3 +1012,3 @@ this.log.info('set session year data');

//neues Jahr setzen alles zurück
this.setState(charger.id + '.session.' + session.year + '.total_year', session.totalEnergyUsage);
this.setState(charger.id + '.session.' + session.year + '.total_year', session.totalEnergyUsage);
tmpYearCount = session.totalEnergyUsage;

@@ -774,10 +1018,10 @@ tmpYear = session.year;

tmpYearCount = tmpYearCount + session.totalEnergyUsage;
this.setState(charger.id + '.session.' + session.year + '.total_year', tmpYearCount);
this.setState(charger.id + '.session.' + session.year + '.total_year', tmpYearCount);
}
});
}
}
/*************** Config Reading ****************/
async setNewConfigToCharger(charger, charger_config) {
async setAllConfigObjects(charger) {

@@ -788,3 +1032,3 @@ //isEnabled

common: {
name: 'isEnabled',
name: 'Set true to enable charger, false disables charger',
type: 'boolean',

@@ -797,3 +1041,2 @@ role: 'indicator',

});
this.setState(charger.id + '.config.isEnabled',{ val: charger_config.isEnabled, ack: true } );
this.subscribeStates(charger.id + '.config.isEnabled');

@@ -805,3 +1048,3 @@

common: {
name: 'phaseMode',
name: 'Phase mode on this charger. 1-Locked to 1-Phase, 2-Auto, 3-Locked to 3-phase(only Home)',
type: 'number',

@@ -814,5 +1057,111 @@ role: 'indicator',

});
this.setState(charger.id + '.config.phaseMode', { val: charger_config.phaseMode, ack: true });
this.subscribeStates(charger.id + '.config.phaseMode');
//maxChargerCurrent
await this.setObjectNotExistsAsync(charger.id + '.config.maxChargerCurrent', {
type: 'state',
common: {
name: 'Max current this charger is allowed to offer to car (A)',
type: 'number',
role: 'indicator',
read: true,
write: true,
},
native: {},
});
this.subscribeStates(charger.id + '.config.maxChargerCurrent');
//dynamicChargerCurrent
await this.setObjectNotExistsAsync(charger.id + '.config.dynamicChargerCurrent', {
type: 'state',
common: {
name: 'Dynamic max current this charger is allowed to offer to car (A)',
type: 'number',
role: 'indicator',
read: true,
write: true,
},
native: {},
});
this.subscribeStates(charger.id + '.config.dynamicChargerCurrent');
await this.setObjectNotExistsAsync(charger.id + '.config.dynamicCircuitCurrentP1', {
type: 'state',
common: {
name:'Dynamically set circuit maximum current for phase 1 [Amperes]',
type: 'number',
role: 'indicator',
read: true,
write: false,
},
native: {},
});
//this.subscribeStates(charger.id + '.config.dynamicCircuitCurrentP1');
await this.setObjectNotExistsAsync(charger.id + '.config.dynamicCircuitCurrentP2', {
type: 'state',
common: {
name:'Dynamically set circuit maximum current for phase 2 [Amperes]',
type: 'number',
role: 'indicator',
read: true,
write: false,
},
native: {},
});
//this.subscribeStates(charger.id + '.config.dynamicCircuitCurrentP2');
await this.setObjectNotExistsAsync(charger.id + '.config.dynamicCircuitCurrentP3', {
type: 'state',
common: {
name:'Dynamically set circuit maximum current for phase 3 [Amperes]',
type: 'number',
role: 'indicator',
read: true,
write: false,
},
native: {},
});
this.subscribeStates(charger.id + '.config.dynamicCircuitCurrentP3');
await this.setObjectNotExistsAsync(charger.id + '.config.circuitMaxCurrentP1', {
type: 'state',
common: {
name:'Set circuit maximum current [Amperes]',
type: 'number',
role: 'indicator',
read: true,
write: true,
},
native: {},
});
this.subscribeStates(charger.id + '.config.circuitMaxCurrentP1');
await this.setObjectNotExistsAsync(charger.id + '.config.circuitMaxCurrentP2', {
type: 'state',
common: {
name:'Set circuit maximum current [Amperes]',
type: 'number',
role: 'indicator',
read: true,
write: true,
},
native: {},
});
this.subscribeStates(charger.id + '.config.circuitMaxCurrentP2');
await this.setObjectNotExistsAsync(charger.id + '.config.circuitMaxCurrentP3', {
type: 'state',
common: {
name:'Set circuit maximum current [Amperes]',
type: 'number',
role: 'indicator',
read: true,
write: true,
},
native: {},
});
//this.subscribeStates(charger.id + '.config.circuitMaxCurrentP3');
//ledStripBrightness

@@ -822,3 +1171,3 @@ await this.setObjectNotExistsAsync(charger.id + '.config.ledStripBrightness', {

common: {
name: 'ledStripBrightness',
name: 'LED strip brightness, 0-100%',
type: 'number',

@@ -831,3 +1180,2 @@ role: 'indicator',

});
this.setState(charger.id + '.config.ledStripBrightness', { val: charger_config.ledStripBrightness, ack: true });
this.subscribeStates(charger.id + '.config.ledStripBrightness');

@@ -839,3 +1187,3 @@

common: {
name: 'wiFiSSID',
name: 'WiFi SSID name',
type: 'string',

@@ -848,6 +1196,5 @@ role: 'indicator',

});
this.setState(charger.id + '.config.wiFiSSID', { val: charger_config.wiFiSSID, ack: true });
this.subscribeStates(charger.id + '.config.wiFiSSID');
}
}
}

@@ -854,0 +1201,0 @@

@@ -0,0 +0,0 @@ 'use strict';

{
"name": "iobroker.easee",
"version": "0.1.1",
"version": "1.0.1",
"description": "Adapter to connect Easee Wallbox",

@@ -20,2 +20,3 @@ "author": {

"@iobroker/adapter-core": "^2.4.0",
"@microsoft/signalr": "^5.0.4",
"axios": "^0.21.1"

@@ -22,0 +23,0 @@ },

@@ -21,19 +21,9 @@ ![Logo](admin/easee.png)

### 0.0.1
* (Newan) initial release
### 0.0.2
* (Newan) add config values
### 0.0.3
* (Newan) add config writeable
### 0.0.4
* (Newan) fixed config writeable
* (Newan) reboot charger
### 0.0.5
* (Newan) add energy used values
### 0.1.0
* (Newan) Preparation for the first stable version
### 0.1.1
* (Newan) Password encrypt + bugfix for the stable version
### 1.0.1
* (Newan) Add circuitMaxCurrentPX to limit current ampere
### 1.0.0
* (Newan) Stable Version with SignalR
## Donation

@@ -40,0 +30,0 @@ [![](https://www.paypalobjects.com/de_DE/DE/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=L55UBQJKJEUJL)

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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