Skip to content

Commit

Permalink
chore: release v1.3.2
Browse files Browse the repository at this point in the history
- fix for login. If settings page is not loading, delete the instance and create a new instance.
  • Loading branch information
TA2k committed Jan 3, 2025
1 parent f086e13 commit f61c426
Show file tree
Hide file tree
Showing 6 changed files with 209 additions and 27 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ Use id.remote.\* to control the mower
Placeholder for the next version (at the beginning of the line):
### **WORK IN PROGRESS**
-->
### 1.3.2 (2025-01-03)

- fix for login. If settings page is not loading, delete the instance and create a new instance.

### 1.3.1 (2024-11-28)

- Fix for Login
Expand Down
142 changes: 142 additions & 0 deletions admin/index_m.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
<html>
<head>
<!-- Load ioBroker scripts and styles-->
<link rel="stylesheet" type="text/css" href="../../css/adapter.css" />
<link rel="stylesheet" type="text/css" href="../../lib/css/materialize.css" />

<script type="text/javascript" src="../../lib/js/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="../../socket.io/socket.io.js"></script>

<script type="text/javascript" src="../../js/translate.js"></script>
<script type="text/javascript" src="../../lib/js/materialize.js"></script>
<script type="text/javascript" src="../../js/adapter-settings.js"></script>

<!-- Load our own files -->
<link rel="stylesheet" type="text/css" href="style.css" />
<script type="text/javascript" src="words.js"></script>

<script type="text/javascript">
// This will be called by the admin adapter when the settings page loads
function load(settings, onChange) {
// example: select elements with id=key and class=value and insert value
if (!settings) return;
$('.value').each(function () {
var $key = $(this);
var id = $key.attr('id');
if ($key.attr('type') === 'checkbox') {
// do not call onChange direct, because onChange could expect some arguments
$key.prop('checked', settings[id]).on('change', () => onChange());
} else {
// do not call onChange direct, because onChange could expect some arguments
$key
.val(settings[id])
.on('change', () => onChange())
.on('keyup', () => onChange());
}
});
onChange(false);
// reinitialize all the Materialize labels on the page if you are dynamically adding inputs:
if (M) M.updateTextFields();
}

// This will be called by the admin adapter when the user presses the save button
function save(callback) {
// example: select elements with class=value and build settings object
var obj = {};
$('.value').each(function () {
var $this = $(this);
if ($this.attr('type') === 'checkbox') {
obj[$this.attr('id')] = $this.prop('checked');
} else if ($this.attr('type') === 'number') {
obj[$this.attr('id')] = parseFloat($this.val());
} else {
obj[$this.attr('id')] = $this.val();
}
});
callback(obj);
}
</script>
</head>

<body>
<div class="m adapter-container">
<div class="row">
<div class="col s12 m4 l2">
<img src="boschindego.png" class="logo" />
</div>
</div>

<!-- Put your content here -->

<!-- For example columns with settings: -->
<div class="row">
<div class="col s6 input-field">
<input type="text" class="value" id="username" />
<label for="username" class="translate">App Email</label>
</div>
</div>
<div class="row">
<div class="col s6 input-field">
<input type="password" class="value" id="password" />
<label for="password" class="translate">App Password</label>
</div>
</div>
<div class="row">
<div class="col s6 input-field" id="captchaResponse">
Check Captcha Box and press Submit. Save the form.
<p></p>
If this is not working use the IP of the ioBroker instance in the browser and try again.
<p></p>

<p></p>
<div>
<form id="captcha_form" action="#" method="post">
<!-- hCaptcha widget -->
<div class="h-captcha" data-sitekey="f8fe2d56-ad42-4f44-b9fe-5b30fcb0dd38"></div>
<br />
<button type="submit" class="btn">Submit</button>
</form>

<!-- hCaptcha script -->
<script src="https://hcaptcha.com/1/api.js" async defer></script>
</div>
</div>
<p></p>
<script>
document.getElementById('captcha_form').addEventListener('submit', function (event) {
event.preventDefault(); // Prevent the default form submission

const hCaptchaResponse = document.querySelector('[name="h-captcha-response"]').value;
const responseElement = document.getElementById('captchaResponse');

if (hCaptchaResponse) {
if (typeof hCaptchaResponse === 'object') {
hCaptchaResponse = JSON.stringify(hCaptchaResponse);
}
document.getElementById('captcha').value = hCaptchaResponse;
//trigger change event
var event = new Event('change');
document.getElementById('captcha').dispatchEvent(event);
}
});
</script>

<input type="text" class="value" id="captcha" />
<label for="captcha" class="translate">Captcha</label>
</div>

<div class="row">
<div class="col s2 input-field">
<input type="number" class="value" id="interval" />
<label for="interval" class="translate">Update interval (in minutes)</label>
</div>
</div>
<div class="row">
<div class="col s2 input-field">
<input type="checkbox" class="value" id="getMap" />
<label for="getMap" class="translate">Get Map</label>
</div>
</div>
</div>
</body>
</html>
34 changes: 16 additions & 18 deletions io-package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
{
"common": {
"name": "boschindego",
"version": "1.3.1",
"version": "1.3.2",
"news": {
"1.3.2": {
"en": "fix for login. If settings page is not loading, delete the instance and create a new instance.",
"de": "fix für Anmeldung. Wenn die Einstellungen nicht geladen werden, löschen Sie die Instanz und erstellen Sie eine neue Instanz.",
"ru": "починить для входа. Если страница настроек не загружается, удалите экземпляр и создайте новый экземпляр.",
"pt": "corrigir para login. Se a página de configurações não estiver carregando, exclua a instância e crie uma nova instância.",
"nl": "fix voor login. Als de instellingenpagina niet wordt geladen, verwijder dan de instantie en maak een nieuwe instantie aan.",
"fr": "correction pour la connexion. Si la page de configuration n'est pas chargée, supprimez l'instance et créez une nouvelle instance.",
"it": "fix per il login. Se la pagina delle impostazioni non viene caricata, cancella l'istanza e crea una nuova istanza.",
"es": "para iniciar sesión. Si la página de configuración no está cargando, elimine la instancia y cree una nueva instancia.",
"pl": "naprawić logowanie. Jeśli strona ustawień nie jest wczytywanie, usunąć instancję i utworzyć nową instancję.",
"uk": "фіксувати логін. Якщо сторінка налаштувань не завантажується, видаліть екземпляр і створіть новий екземпляр.",
"zh-cn": "用于登录的固定。 如果设置页面没有加载,请删除实例并创建新实例."
},
"1.3.1": {
"en": "Fix for Login",
"de": "Fix für den Login",
Expand Down Expand Up @@ -80,19 +93,6 @@
"pl": "Napraw lokalizację mapy",
"uk": "Карта сайту",
"zh-cn": "修复地图位置"
},
"1.1.1": {
"en": "fix Login",
"de": "Login Fix",
"ru": "исправление",
"pt": "corrigir Login",
"nl": "aanmelden repareren",
"fr": "correction de la connexion",
"it": "correzione Login",
"es": "fijación Iniciar sesión",
"pl": "fix Login",
"uk": "увійти",
"zh-cn": "固定登录"
}
},
"titleLang": {
Expand Down Expand Up @@ -139,9 +139,6 @@
"compact": true,
"connectionType": "cloud",
"dataSource": "poll",
"adminUI": {
"config": "json"
},
"dependencies": [
{
"js-controller": ">=5.0.19"
Expand All @@ -164,7 +161,8 @@
"username": "",
"password": "",
"interval": 30,
"getMap": false
"getMap": false,
"captcha": ""
},
"objects": [],
"instanceObjects": [
Expand Down
49 changes: 44 additions & 5 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,18 @@ class Boschindego extends utils.Adapter {
this.session = {};
this.subscribeStates('*.remote.*');

this.log.info('Login to Bosch Indego');
await this.login();

const sessionState = await this.getStateAsync('auth.session');
if (sessionState && sessionState.val) {
this.session = JSON.parse(sessionState.val);
this.log.info(
'Session found. If the login fails please delete boschindego.0.auth.session and restart the adapter',
);
this.log.debug(JSON.stringify(this.session));
await this.refreshToken();
} else {
this.log.info('Login to Bosch Indego');
await this.login();
}
if (this.session.access_token) {
await this.getDeviceList();
await this.updateDevices();
Expand All @@ -125,6 +134,10 @@ class Boschindego extends utils.Adapter {
}

async login() {
if (!this.config.captcha) {
this.log.error('Please set capcha in the instance settings');
return;
}
const loginForm = await this.requestClient({
method: 'get',
url: 'https://prodindego.b2clogin.com/prodindego.onmicrosoft.com/b2c_1a_signup_signin/oauth2/v2.0/authorize',
Expand Down Expand Up @@ -216,6 +229,7 @@ class Boschindego extends utils.Adapter {
params: loginParams,
data: {
'UserIdentifierInput.EmailInput.StringValue': this.config.username,
'h-captcha-response': this.config.captcha,
__RequestVerificationToken: formData['undefined'],
},
})
Expand Down Expand Up @@ -305,11 +319,23 @@ class Boschindego extends utils.Adapter {
response.code +
'&code_verifier=nw0c1JmU5rIszzrUOFj1BFvaqOynWrZ6ZHSVOMisZ7o&redirect_uri=msauth.com.bosch.indegoconnect.cloud://auth/&grant_type=authorization_code',
})
.then((res) => {
.then(async (res) => {
this.log.debug(JSON.stringify(res.data));
this.session = res.data;
this.log.info('Login successful');
this.setState('info.connection', true, true);
await this.extendObject('auth.session', {
type: 'state',
common: {
name: 'Session Token',
type: 'string',
role: 'value',
read: true,
write: false,
},
native: {},
});
this.setState('auth.session', JSON.stringify(this.session), true);
})
.catch((error) => {
this.log.error('Code Exchange step faild');
Expand Down Expand Up @@ -679,13 +705,26 @@ class Boschindego extends utils.Adapter {
grant_type: 'refresh_token',
}),
})
.then((res) => {
.then(async (res) => {
this.log.debug(JSON.stringify(res.data));
this.session = res.data;
this.log.debug('Refresh successful');
this.setState('info.connection', true, true);
await this.extendObject('auth.session', {
type: 'state',
common: {
name: 'Session Token',
type: 'string',
role: 'value',
read: true,
write: false,
},
native: {},
});
this.setState('auth.session', JSON.stringify(this.session), true);
})
.catch(async (error) => {
this.log.error('Refresh token faild. Please delete boschindego.0.auth.session and restart the adapter');
this.log.error(error);
error.response && this.log.error(JSON.stringify(error.response.data));
this.setStateAsync('info.connection', false, true);
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

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

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "iobroker.boschindego",
"version": "1.3.1",
"version": "1.3.2",
"description": "Adapter for Bosch Indego Mower",
"author": {
"name": "TA2k",
Expand Down Expand Up @@ -69,5 +69,4 @@
"url": "https://github.com/iobroker-community-adapters/ioBroker.boschindego/issues"
},
"readmeFilename": "README.md"

}

0 comments on commit f61c426

Please sign in to comment.