Skip to content

Commit

Permalink
Merge pull request #129 from Grizzelbee/Development
Browse files Browse the repository at this point in the history
V0.9.5 (2021-08-23) (Marching on)
  • Loading branch information
Grizzelbee authored Aug 23, 2021
2 parents e05d25d + 5530de5 commit ec199a4
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 23 deletions.
16 changes: 9 additions & 7 deletions admin/index_m.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@
} else if ($this.attr('type') === 'number') {
obj[id] = parseFloat($this.val());
} else {
let value = String.prototype.trim($this.val());
let value = $this.val().trim();
if (M) M.updateTextFields();
if (id === 'Password') {
obj[id] = encrypt(secret, value);
} else {
Expand All @@ -91,8 +92,8 @@

async function getDyson2faMail(){
let payload = {};
payload.email = document.getElementById("email").value;
payload.password = document.getElementById("Password").value;
payload.email = document.getElementById("email").value.trim();
payload.password = document.getElementById("Password").value.trim();
payload.country = document.getElementById("country").value;
switch (payload.country){
case 'DE': payload.locale = 'de-DE';
Expand Down Expand Up @@ -133,18 +134,18 @@
console.log(`Setting challengeId [${response.challengeId}] to input.`);
$('input[id=challengeId]').val(response.challengeId).change();
if (M) M.updateTextFields();
showError('Received challengeId from dyson. Please check your eMails now and enter the code you received from dyson to the according field. When done click "finish".');
showMessage('Received challengeId from dyson. Please check your eMails now and enter the code you received from dyson to the according field. When done click "finish".');
}
});
};

async function getDysonToken(){
let payload = {};
payload.email = document.getElementById("email").value;
payload.password = document.getElementById("Password").value;
payload.email = document.getElementById("email").value.trim();
payload.password = document.getElementById("Password").value.trim();
payload.country = document.getElementById("country").value;
payload.challengeId = document.getElementById("challengeId").value;
payload.PIN = document.getElementById("dyson_code").value;
payload.PIN = document.getElementById("dyson_code").value.trim();
sendTo(null, 'getDysonToken', payload, (response) => {
if (response.error) {
showError(response.error);
Expand All @@ -154,6 +155,7 @@
console.log(`Setting token [${JSON.stringify(response)}] to input.`);
$('input[id=token]').val(response.token).change();
if (M) M.updateTextFields();
showMessage(`Received token [${JSON.stringify(response)}] from dyson and saved it to config.`);
}
});
};
Expand Down
4 changes: 2 additions & 2 deletions dysonConstants.js

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

16 changes: 14 additions & 2 deletions io-package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
{
"common": {
"name": "dysonairpurifier",
"version": "0.9.4",
"version": "0.9.5",
"news": {
"0.9.5": {
"en": "Fixed some new and some old bugs.",
"de": "Einige neue und einige alte Fehler behoben.",
"ru": "Исправлены некоторые новые и некоторые старые ошибки.",
"pt": "Corrigido alguns bugs novos e antigos.",
"nl": "Enkele nieuwe en enkele oude bugs verholpen.",
"fr": "Correction de quelques nouveaux et anciens bugs.",
"it": "Risolti alcuni bug nuovi e alcuni vecchi.",
"es": "Se corrigieron algunos errores nuevos y algunos viejos.",
"pl": "Naprawiono kilka nowych i kilka starych błędów.",
"zh-cn": "修复了一些新的和一些旧的错误。"
},
"0.9.4": {
"en": "Added some debug code - no new features.",
"de": "Debug-Code hinzugefügt - keine neuen Funktionen.",
Expand Down Expand Up @@ -106,7 +118,7 @@
"platform": "Javascript/Node.js",
"icon": "dyson_logo.svg",
"adminUI": {
"config":"materialize"
"config": "materialize"
},
"enabled": true,
"extIcon": "https://github.com/Grizzelbee/ioBroker.dysonairpurifier/blob/master/admin/dyson_logo.svg",
Expand Down
17 changes: 7 additions & 10 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class dysonAirPurifier extends utils.Adapter {
if (state && !state.ack) {
// you can use the ack flag to detect if it is status (true) or command (false)
// get the whole data field array
let dysonAction = this.getDatapoint( action );
let dysonAction = await this.getDatapoint( action );
if ( typeof dysonAction === 'undefined' ) {
// if dysonAction is undefined it's an adapter internal action and has to be handled with the given Name
dysonAction = action;
Expand Down Expand Up @@ -211,12 +211,12 @@ class dysonAirPurifier extends utils.Adapter {
this.log.debug('Creating device folder.');
await this.createOrExtendObject(device.Serial, {
type: 'device',
common: {name: dysonConstants.PRODUCTS[device.ProductType].name, icon: dysonConstants.PRODUCTS[device.ProductType].icon},
common: {name: dysonConstants.PRODUCTS[device.ProductType].name, icon: dysonConstants.PRODUCTS[device.ProductType].icon, type:'string'},
native: {}
}, null);
await this.createOrExtendObject(device.Serial + '.Firmware', {
type: 'channel',
common: {name: 'Information on device\'s firmware', 'read': true, 'write': false},
common: {name: 'Information on device\'s firmware', 'read': true, 'write': false, type:'string', role:'value'},
native: {}
}, null);
await this.createOrExtendObject(device.Serial + '.Firmware.Version', {
Expand Down Expand Up @@ -259,7 +259,7 @@ class dysonAirPurifier extends utils.Adapter {
'read': true,
'write': false,
'role': 'value',
'type': 'number'
'type': 'string'
},
native: {}
}, device.ProductType);
Expand Down Expand Up @@ -329,7 +329,7 @@ class dysonAirPurifier extends utils.Adapter {
// Is this a "product-state" message?
if ( row === 'product-state'){
await this.processMsg(device, '', message[row]);
continue;
return;
}
// Is this a "data" message?
if ( row === 'data'){
Expand All @@ -349,11 +349,11 @@ class dysonAirPurifier extends utils.Adapter {
if (Object.prototype.hasOwnProperty.call(message[row], 'noxl')) {
this.createNO2(message, row, device);
}
continue;
return;
}
// Handle all other message types
this.log.debug('Processing Message: ' + ((typeof message === 'object')? JSON.stringify(message) : message) );
const deviceConfig = this.getDatapoint(row);
const deviceConfig = await this.getDatapoint(row);
if ( deviceConfig === undefined){
this.log.debug('Skipped creating unknown data field for: [' + row + '] Value: |-> ' + ((typeof( message[row] ) === 'object')? JSON.stringify(message[row]) : message[row]) );
continue;
Expand Down Expand Up @@ -402,9 +402,6 @@ class dysonAirPurifier extends utils.Adapter {
}
// deviceConfig.length>7 means the data field has predefined states attached, that need to be handled
if (deviceConfig.length > 7) {
if (deviceConfig[3]==='number'){
this.log.debug(`This should be type number: ${typeof value}`);
}
this.createOrExtendObject( device.Serial + path + '.'+ deviceConfig[1], { type: 'state', common: {name: deviceConfig[2], 'read':true, 'write': deviceConfig[4]==='true', 'role': deviceConfig[5], 'type':deviceConfig[3], 'unit':deviceConfig[6], 'states': deviceConfig[7]}, native: {} }, value);
} else {
this.createOrExtendObject( device.Serial + path + '.'+ deviceConfig[1], { type: 'state', common: {name: deviceConfig[2], 'read':true, 'write': deviceConfig[4]==='true', 'role': deviceConfig[5], 'type':deviceConfig[3], 'unit':deviceConfig[6] }, native: {} }, value);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "iobroker.dysonairpurifier",
"version": "0.9.4",
"version": "0.9.5",
"description": "dyson air purifiers and fans",
"author": {
"name": "grizzelbee",
Expand Down
15 changes: 14 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,14 @@ and probably show some errors in the log - that's fine for now.
All the values will be saved and shown furthermore.
> Usually you don't need to do this 2 FA on a scheduled basis - but you may repeat it when needed.
>If you are facing problems during 2-FA. Please refer to [Issue #124](https://github.com/Grizzelbee/ioBroker.dysonairpurifier/issues/124) for a possible workaround.
#### If you are facing the 401 issue during 2-FA. Please try this workaround:
1. Log out of your dyson smartphone app
2. Wait a few minutes
3. Enter your login data to the adapter (if not already done) and follow the 2FA procedure to the end.
4. Adapter should start and turn green.
5. wait a while (up to an hour or maybe more since dyson has a blocker for too many requests in a short time frame)
6. Login back into your dyson smartphone app if you like to use it.

## Controlling your device(s)
This adapter is currently able to control the following states of your devices:
* FanSpeed , Current fan speed
Expand Down Expand Up @@ -132,6 +139,12 @@ Which is what the dyson app does also.

## Changelog

### V0.9.5 (2021-08-23) (Marching on)
* (grizzelbee) Doc: [#124](https://github.com/Grizzelbee/ioBroker.dysonairpurifier/issues/124) Documented workaround for 2FA 401 Issue in ReadMe
* (grizzelbee) Fix: [#128](https://github.com/Grizzelbee/ioBroker.dysonairpurifier/issues/128) Fixed saving of config data
* (grizzelbee) Fix: [#107](https://github.com/Grizzelbee/ioBroker.dysonairpurifier/issues/107) Fixed type error on temperatures
* (grizzelbee) Fix: fixed warnings on startup

### V0.9.4 (2021-08-20) ()
* (grizzelbee) New: [#124](https://github.com/Grizzelbee/ioBroker.dysonairpurifier/issues/124) Credentials won't get logged but shown in a popup in admin when failing 2FA process.
* (grizzelbee) New: Added adminUI tag to io-package
Expand Down

0 comments on commit ec199a4

Please sign in to comment.