Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: simatec/ioBroker.remeha-home
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 6c45272ed04d8163c9d76b172260efc94b14894a
Choose a base ref
..
head repository: simatec/ioBroker.remeha-home
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 446284cf37ec587060d3240644ecac8dbad409f5
Choose a head ref
2 changes: 1 addition & 1 deletion .github/workflows/test-and-release.yml
Original file line number Diff line number Diff line change
@@ -55,7 +55,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
node-version: [18.x, 20.x]
node-version: [18.x, 20.x, 22.x]
os: [ubuntu-latest, windows-latest, macos-latest]

steps:
3 changes: 2 additions & 1 deletion admin/i18n/de/translations.json
Original file line number Diff line number Diff line change
@@ -3,5 +3,6 @@
"Connect your Remeha Home System with ioBroker": "Verbinden Sie Ihr Remeha Home System mit ioBroker",
"Remeha Home Settings": "Remeha Home-Einstellungen",
"Remeha Home Account": "Remeha Home Konto",
"Remeha Home Password": "Remeha Home Passwort"
"Remeha Home Password": "Remeha Home Passwort",
"Poll Intervall (seconds)": "Abfrage-Intervall (Sekunden)"
}
3 changes: 2 additions & 1 deletion admin/i18n/en/translations.json
Original file line number Diff line number Diff line change
@@ -3,5 +3,6 @@
"Connect your Remeha Home System with ioBroker": "Connect your Remeha Home System with ioBroker",
"Remeha Home Settings": "Remeha Home Settings",
"Remeha Home Account": "Remeha Home Account",
"Remeha Home Password": "Remeha Home Password"
"Remeha Home Password": "Remeha Home Password",
"Poll Intervall (seconds)": "Poll Intervall (seconds)"
}
3 changes: 2 additions & 1 deletion admin/i18n/es/translations.json
Original file line number Diff line number Diff line change
@@ -3,5 +3,6 @@
"Connect your Remeha Home System with ioBroker": "Conecte su sistema doméstico Remeha con ioBroker",
"Remeha Home Settings": "Configuración de inicio de Remeha",
"Remeha Home Account": "Cuenta de inicio de Remeha",
"Remeha Home Password": "Contraseña de inicio de Remeha"
"Remeha Home Password": "Contraseña de inicio de Remeha",
"Poll Intervall (seconds)": "Intervalo de encuesta (segundos)"
}
3 changes: 2 additions & 1 deletion admin/i18n/fr/translations.json
Original file line number Diff line number Diff line change
@@ -3,5 +3,6 @@
"Connect your Remeha Home System with ioBroker": "Connectez votre système domestique Remeha avec ioBroker",
"Remeha Home Settings": "Paramètres de la maison Remeha",
"Remeha Home Account": "Compte Accueil Remeha",
"Remeha Home Password": "Mot de passe de la maison Remeha"
"Remeha Home Password": "Mot de passe de la maison Remeha",
"Poll Intervall (seconds)": "Intervalle d'interrogation (secondes)"
}
3 changes: 2 additions & 1 deletion admin/i18n/it/translations.json
Original file line number Diff line number Diff line change
@@ -3,5 +3,6 @@
"Connect your Remeha Home System with ioBroker": "Collega il tuo sistema Remeha Home con ioBroker",
"Remeha Home Settings": "Impostazioni della casa Remeha",
"Remeha Home Account": "Conto domestico Remeha",
"Remeha Home Password": "Password di casa Remeha"
"Remeha Home Password": "Password di casa Remeha",
"Poll Intervall (seconds)": "Intervallo di sondaggio (secondi)"
}
3 changes: 2 additions & 1 deletion admin/i18n/nl/translations.json
Original file line number Diff line number Diff line change
@@ -3,5 +3,6 @@
"Connect your Remeha Home System with ioBroker": "Verbind uw Remeha Home Systeem met ioBroker",
"Remeha Home Settings": "Remeha Home-instellingen",
"Remeha Home Account": "Remeha Home-account",
"Remeha Home Password": "Remeha Home-wachtwoord"
"Remeha Home Password": "Remeha Home-wachtwoord",
"Poll Intervall (seconds)": "Poll-interval (seconden)"
}
3 changes: 2 additions & 1 deletion admin/i18n/pl/translations.json
Original file line number Diff line number Diff line change
@@ -3,5 +3,6 @@
"Connect your Remeha Home System with ioBroker": "Połącz swój system domowy Remeha z ioBrokerem",
"Remeha Home Settings": "Ustawienia domowe Remehy",
"Remeha Home Account": "Konto domowe Remeha",
"Remeha Home Password": "Hasło do domu Remehy"
"Remeha Home Password": "Hasło do domu Remehy",
"Poll Intervall (seconds)": "Interwał ankiety (sekundy)"
}
3 changes: 2 additions & 1 deletion admin/i18n/pt/translations.json
Original file line number Diff line number Diff line change
@@ -3,5 +3,6 @@
"Connect your Remeha Home System with ioBroker": "Conecte seu sistema doméstico Remeha com ioBroker",
"Remeha Home Settings": "Configurações iniciais de Remeha",
"Remeha Home Account": "Conta inicial Remeha",
"Remeha Home Password": "Senha inicial de Remeha"
"Remeha Home Password": "Senha inicial de Remeha",
"Poll Intervall (seconds)": "Intervalo de pesquisa (segundos)"
}
3 changes: 2 additions & 1 deletion admin/i18n/ru/translations.json
Original file line number Diff line number Diff line change
@@ -3,5 +3,6 @@
"Connect your Remeha Home System with ioBroker": "Подключите домашнюю систему Remeha к ioBroker",
"Remeha Home Settings": "Домашние настройки Remeha",
"Remeha Home Account": "Ремеха Домашняя учетная запись",
"Remeha Home Password": "Ремеха Домашний пароль"
"Remeha Home Password": "Ремеха Домашний пароль",
"Poll Intervall (seconds)": "Интервал опроса (секунды)"
}
3 changes: 2 additions & 1 deletion admin/i18n/uk/translations.json
Original file line number Diff line number Diff line change
@@ -3,5 +3,6 @@
"Connect your Remeha Home System with ioBroker": "Підключіть свою домашню систему Remeha до ioBroker",
"Remeha Home Settings": "Домашні налаштування Remeha",
"Remeha Home Account": "Домашній обліковий запис Remeha",
"Remeha Home Password": "Домашній пароль Remeha"
"Remeha Home Password": "Домашній пароль Remeha",
"Poll Intervall (seconds)": "Інтервал опитування (секунди)"
}
3 changes: 2 additions & 1 deletion admin/i18n/zh-cn/translations.json
Original file line number Diff line number Diff line change
@@ -3,5 +3,6 @@
"Connect your Remeha Home System with ioBroker": "将您的 Remeha Home 系统与 ioBroker 连接",
"Remeha Home Settings": "Remeha 主页设置",
"Remeha Home Account": "Remeha 家庭帐户",
"Remeha Home Password": "雷米哈主页密码"
"Remeha Home Password": "雷米哈主页密码",
"Poll Intervall (seconds)": "轮询间隔(秒)"
}
14 changes: 14 additions & 0 deletions admin/jsonConfig.json
Original file line number Diff line number Diff line change
@@ -45,6 +45,20 @@
"validatorNoSaveOnError": true,
"help": "Remeha Home Password"
},
"pollInterval": {
"type": "number",
"visible": true,
"label": "Poll Intervall (seconds)",
"min": 30,
"max": 3600,
"xs": 12,
"sm": 12,
"md": 8,
"lg": 4,
"validator": "data.pollInterval",
"validatorNoSaveOnError": true,
"help": "Poll Intervall (seconds)"
},
"_helpLine2": {
"newLine": true,
"type": "divider",
4 changes: 2 additions & 2 deletions io-package.json
Original file line number Diff line number Diff line change
@@ -65,7 +65,7 @@
"readme": "https://github.com/simatec/ioBroker.remeha-home/blob/master/README.md",
"loglevel": "info",
"mode": "daemon",
"type": "messaging",
"type": "climate-control",
"compact": true,
"connectionType": "cloud",
"dataSource": "poll",
@@ -86,7 +86,7 @@
},
"native": {
"account": "",
"pollInterval": 600
"pollInterval": 60
},
"encryptedNative": [
"password"
66 changes: 28 additions & 38 deletions main.js
Original file line number Diff line number Diff line change
@@ -3,7 +3,6 @@
const utils = require('@iobroker/adapter-core');
const crypto = require('crypto');
const { URL } = require('url');
const base64url = require('base64url');

const { CookieJar } = require('tough-cookie');

@@ -19,7 +18,6 @@ class RemehaHomeAdapter extends utils.Adapter {
this.accessToken = null;
this.refreshToken = null;
this.csrfToken = null;
//this.codeVerifier = crypto.randomBytes(32).toString('hex');
this.codeChallenge = '';
this.state = '';
this.loadGot();
@@ -116,10 +114,6 @@ class RemehaHomeAdapter extends utils.Adapter {
this.codeChallenge = codeChallenge;
const codeChallengeSha256 = await this.computeCodeChallenge(codeChallenge);

//this.log.debug(`Using state: ${this.state}`);
//this.log.debug(`Code challenge: ${codeChallenge}`);
//this.log.debug(`Code codeChallengeSha256: ${codeChallengeSha256}`);

const response = await this.client.get(`bdrb2cprod.onmicrosoft.com/oauth2/v2.0/authorize?`, {
searchParams: {
response_type: 'code',
@@ -140,7 +134,6 @@ class RemehaHomeAdapter extends utils.Adapter {
});

this.log.debug('Response get Auth: ' + response.statusCode);
//this.log.debug('x-request-id: ' + response.headers["x-request-id"]);

let csrfTokenCookie;
const cookies = response.headers['set-cookie'];
@@ -150,7 +143,6 @@ class RemehaHomeAdapter extends utils.Adapter {

if (csrfTokenCookie) {
this.csrfToken = csrfTokenCookie.split(';')[0].replace("x-ms-cpim-csrf=", "").replace(/;$/, "");
//this.log.debug('csrfToken: ' + csrfTokenCookie.split(';')[0].replace("x-ms-cpim-csrf=", "").replace(/;$/, ""));
} else {
throw new Error('CSRF-Token not found in response headers.');
}
@@ -162,11 +154,13 @@ class RemehaHomeAdapter extends utils.Adapter {

// Create state_properties JSON and encode it in base64 URL-safe format
const statePropertiesJson = `{"TID":"${requestId}"}`;
const stateProperties = base64url.encode(statePropertiesJson);
//this.log.debug(`stateProperties: ${stateProperties}`);
const stateProperties = Buffer.from(statePropertiesJson)
.toString('base64')
.replace(/\+/g, '-')
.replace(/\//g, '_')
.replace(/=+$/, '');

const authorizationCode = await this.login(stateProperties, this.csrfToken);
//this.log.debug(`authorizationCode: ${authorizationCode}`)

if (!authorizationCode) throw new Error('Authorization code is missing.');

@@ -185,9 +179,6 @@ class RemehaHomeAdapter extends utils.Adapter {

async login(stateProperties, csrfToken) {
try {
//this.log.debug(`Attempting login with stateProperties: ${stateProperties}`);
//this.log.debug(`CSRF-Token: ${csrfToken}`);

const response = await this.client.post(`bdrb2cprod.onmicrosoft.com/B2C_1A_RPSignUpSignInNewRoomv3.1/SelfAsserted`, {
searchParams: {
tx: `StateProperties=${stateProperties}`,
@@ -204,8 +195,6 @@ class RemehaHomeAdapter extends utils.Adapter {
followRedirect: true,
});



this.log.debug('Login response status:' + response.statusCode);

} catch (error) {
@@ -245,16 +234,13 @@ class RemehaHomeAdapter extends utils.Adapter {
}
this.log.debug('Authorization code not found in redirect URL.');
return null;


} catch (error) {
this.log.error(`Error get code: ${error}`);
if (error.response) {
this.log.error(`Response error status: ${error.response}`);
}
throw error;
}

}

async generateRandomToken(length) {
@@ -287,46 +273,48 @@ class RemehaHomeAdapter extends utils.Adapter {
searchParams: {
p: 'B2C_1A_RPSignUpSignInNewRoomV3.1'
},
form: grantParams, // Hier werden die Parameter als Formulardaten gesendet
followRedirect: true, // Erlaubt Weiterleitungen
responseType: 'json' // Stellt sicher, dass die Antwort als JSON geparst wird
form: grantParams,
followRedirect: true,
responseType: 'json'
});
this.log.debug('Access Token Stattus:' + response.statusCode);
this.accessToken = response.body.access_token;
this.refreshToken = response.body.refresh_token;
//this.log.debug('Access Token:' + this.accessToken);
return this.accessToken;
} catch (error) {
this.log.error(`Error fetching access token: ${error}`);
throw error;
}
}
/*

async refreshAccessToken() {
try {
const response = await this.got.post('https://remehalogin.bdrthermea.net/bdrb2cprod.onmicrosoft.com/oauth2/v2.0/token', qs.stringify({
const grantParams = {
grant_type: 'refresh_token',
refresh_token: this.refreshToken,
client_id: '6ce007c6-0628-419e-88f4-bee2e6418eec'
}), {
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
};

const response = await this.client.post('bdrb2cprod.onmicrosoft.com/oauth2/v2.0/token', {
form: grantParams,
followRedirect: true,
responseType: 'json'
});

this.accessToken = response.data.access_token;
this.log.debug('Refreshed Access Token:', this.accessToken);
this.accessToken = response.body.access_token;
this.log.debug(`Refreshed Access Token: ${this.accessToken}`);
} catch (error) {
this.log.error('Error refreshing access token:', error.response ? error.response.data : error.message);
this.log.error(`Error refreshing access token: ${error}`);
throw error;
}
}
*/

async updateDevices() {
try {
if (!this.accessToken === null || await this.checkTokenValidity(this.accessToken) !== 200) {
await this.fetchAccessToken(); // or refreshAccessToken()
if (this.accessToken === null) {
await this.fetchAccessToken();
} else if (await this.checkTokenValidity(this.accessToken) !== 200) {
await this.refreshAccessToken();
}

const response = await this.got.get('https://api.bdrthermea.net/Mobile/api/homes/dashboard', {
@@ -364,10 +352,11 @@ class RemehaHomeAdapter extends utils.Adapter {
'x-csrf-token': this.csrfToken
}
});
this.log.debug('checkTokenValidity Status:' + response.statusCode)
//this.log.debug('checkTokenValidity:' + response.body);
this.log.debug('checkTokenValidity Status:' + response.statusCode);
await this.setStateAsync('info.connection', response.statusCode === 200 ? true : false, true);

await this.sleep(2000)
return 200;
return response.statusCode;
} catch (error) {
this.log.error(`Token validity check failed: ${error}`);
return false;
@@ -396,6 +385,7 @@ class RemehaHomeAdapter extends utils.Adapter {

onUnload(callback) {
try {
this.setState('info.connection', false, true);
clearInterval(this.interval);
callback();
} catch (e) {
16 changes: 0 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -25,9 +25,7 @@
},
"dependencies": {
"@iobroker/adapter-core": "^3.1.6",
"crypto": "^1.0.1",
"url": "^0.11.4",
"base64url": "^3.0.1",
"got": "^14.4.2",
"tough-cookie": "^4.1.4"
},