Skip to content

Commit

Permalink
Merge pull request #63 from Grizzelbee/Development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
Grizzelbee authored Jan 6, 2022
2 parents 9f1bd37 + 0650b1a commit c6bb287
Show file tree
Hide file tree
Showing 6 changed files with 128 additions and 125 deletions.
75 changes: 41 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ the [plugin homepage](https://github.com/ioBroker/plugin-sentry) for detailed in
### Examples:
#### Connection via USB/Serial

| Operating System | Connectiondevice | Device-address | Port | DL3-Channel | Via-Tag |
|------------------|------------------|----------------|------|-------------|---------|
| Windows | USB/Serial | COMx | | None | |
| Linux | | /dev/tty.usbserial/ | | None | |
| Operating System | Connectiondevice | Device-address | Port | DL3-Channel | Via-Tag |
|------------------|------------------|---------------------|------|-------------|---------|
| Windows | USB/Serial | COMx | | None | |
| Linux | | /dev/tty.usbserial/ | | None | |

#### Connection via LAN
This includes:
Expand All @@ -76,23 +76,23 @@ This includes:
* DL3 Devices (Selection of Channel is important, Channel 0 is not supported)
* Serial to LAN Gateways

| | Connectiondevice | Device-address | Port | DL3-Channel | Via-Tag |
|------------------|------------------|----------------|------|-------------|---------|
| | select your Device from List | IP-Address of your Device | TCP Port | DL3 Channel to use, when applicable | leave blank |
| Example | KM2 | 192.168.17x.xxx | 7053 (Default) | None | |
| Example | DL2 | 192.168.17x.xxx | 7053 (Default) | None | |
| Example | DL3 | 192.168.17x.xxx | 7053 (Default) | Channel x | |
| | Connectiondevice | Device-address | Port | DL3-Channel | Via-Tag |
|---------|------------------------------|---------------------------|----------------|-------------------------------------|-------------|
| | select your Device from List | IP-Address of your Device | TCP Port | DL3 Channel to use, when applicable | leave blank |
| Example | KM2 | 192.168.17x.xxx | 7053 (Default) | None | |
| Example | DL2 | 192.168.17x.xxx | 7053 (Default) | None | |
| Example | DL3 | 192.168.17x.xxx | 7053 (Default) | Channel x | |

#### Connection via vbus.net by Resol
You'll find your personal per device Via-tag on the vbus.net homepage under: My VBus.net - My devices.
Best is to copy/paste it from there - **without http://**

| | Connectiondevice | Device-address | Port | DL3-Channel | Via-Tag |
|------------------|------------------|----------------|------|-------------|---------|
| | select vbus.net from List | leave blank | TCP Port | None | your Via-tag from resol vbus.net |
| Example KM2 / DL2 | vbus.net | | 7053 (Default) | None | d01234567890.vbus.net |
| Example KM2 / DL2| vbus.net | | 7053 (Default) | None | d01234567890.vbus.io |
| Example Dl3| vbus.net | | 7053 (Default) | Channel x | d01234567890.vbus.io |
| | Connectiondevice | Device-address | Port | DL3-Channel | Via-Tag |
|-------------------|---------------------------|----------------|----------------|-------------|----------------------------------|
| | select vbus.net from List | leave blank | TCP Port | None | your Via-tag from resol vbus.net |
| Example KM2 / DL2 | vbus.net | | 7053 (Default) | None | d01234567890.vbus.net |
| Example KM2 / DL2 | vbus.net | | 7053 (Default) | None | d01234567890.vbus.io |
| Example Dl3 | vbus.net | | 7053 (Default) | Channel x | d01234567890.vbus.io |


#### Sending commands to resol device
Expand Down Expand Up @@ -145,43 +145,51 @@ The file should look like this

Save the file and restart the adapter, you will find now a new object Rueckkuehlung.



## Todo

## Changelog

### 0.4.0 (2021-11-08)
### v0.4.2 (2022-01-05)
* (grizzelbee) Fix: Removed password encryption stuff from admin to avoid double encryption

### v0.4.1 (2022-01-05)
* (grizzelbee) Fix: switched action roles from "indicator" to "switch" to be compliant with ioBroker rules
* (grizzelbee) Fix: Removed password encryption stuff and added dependency Admin >=4.0.9
* (grizzelbee) Fix: Fixed a few code warnings
* (grizzelbee) Fix: Fixed: info.connection has been written w/o ACK
* (grizzelbee) Upd: updated dependencies

### v0.4.0 (2021-11-08)
* (grizzelbee) Upd: updated dependencies
* (grizzelbee) New: Trying more than one time to connect when network isn't setup properly. E.g. on router startup.

### 0.3.3 (2021-11-04)
### v0.3.3 (2021-11-04)
* (grizzelbee) Upd: updated dependencies
* (grizzelbee) Upd: Switched from adapter-type climate-control to energy

### 0.3.2 (2021-09-16)
### v0.3.2 (2021-09-16)
* (grizzelbee) Upd: updated dependencies
* (grizzelbee) Fix: [#27](https://github.com/Grizzelbee/ioBroker.resol/issues/27) Fixed: State value to set for "resol.0.xxx.010221110010002220" has to be type "number" but received type "string" - it may be needed to delete datapoints manually
* (grizzelbee) Upd: set correct tier in io-package
* (grizzelbee) New: Writing value null when received value is <= -999 and >= 999. This is to avoid writing crap when no sensors are connected.
* (grizzelbee) New: Making use of adapter internal decrypt function (req. at least js-controller >= 3.0)

### 0.3.1 (2021-05-07)
### v0.3.1 (2021-05-07)
* (gargano) Fix: wrong object types fixed according JS-Controller 3.x
* (gargano) Fix: prevent setState if value = undefined
* (gargano) Upd: Updated resol lib by Daniel Wippermann to v0.22.0
* (grizzelbee) New: Added sentry
* (grizzelbee) Fix: Made eslint happy
* (grizzelbee) Upd: updated dependencies

### 0.3.0 (2021-01-xx)
### v0.3.0 (2021-01-xx)
* (grizzelbee) Upd: Updated dependencies
* (grizzelbee) New: Log connection-losts as info

### 0.2.1 (2021-01-23)
### v0.2.1 (2021-01-23)
* (gargano) New: write function to resol device added

### 0.2.0 (2021-01-18)
### v0.2.0 (2021-01-18)
* (grizzelbee) New: New Icon
* (grizzelbee) Upd: Update resol-Bus lib to V0.21.0
* (grizzelbee) Upd: Security-Update to lodash lib
Expand All @@ -191,7 +199,7 @@ Save the file and restart the adapter, you will find now a new object Rueckkuehl
* (grizzelbee) New: Extended documentation
* (grizzelbee) Fix: Adapter doesn't crash on connection losts anymore

### 0.1.0 (2020-03-29)
### v0.1.0 (2020-03-29)
* (grizzelbee) Fix: config page shows current settings now (not default anymore) **May raise the need to reenter the password!**
* (grizzelbee) Fix: "Connected" state is updated correctly now if connection is disrupted.
* (grizzelbee) New: Added Badge for latest(npm) version to readme
Expand All @@ -201,23 +209,22 @@ Save the file and restart the adapter, you will find now a new object Rueckkuehl
* (grizzelbee) New: added new activity indicator states for each relais.
* (grizzelbee) New: testing configuration to avoid start with invalid config

### 0.0.6
### v0.0.6
* (pdbjjens) alpha 6 release updated dependencies

### 0.0.5
### v0.0.5
* (pdbjjens) alpha 5 release improved type and role mapping of adapter values

### 0.0.4
### v0.0.4
* (pdbjjens) alpha 4 release updated dependency on resol-vbus library to 0.21.0

### 0.0.3
### v0.0.3
* (pdbjjens) alpha 3 release tested with DL3 over local LAN and VBus.net and DeltaSol SLT (0x1001) incl. HQM (0x1011)

### 0.0.2
### v0.0.2
* (pdbjjens) alpha 2 release tested with VBus/LAN, KM2, VBus.net and DeltaSol E (0x7721 & 0x7722), DeltaSol M (0x7311 & 0x716), DeltaSol CS Plus (0x2211), Oventrop RQXXL (0x7541)

### 0.0.1

### v0.0.1
* (pdbjjens) initial release tested only with VBus/USB (Serial) and DeltaSol(R) BS2009 (0x427B)

## Legal Notices
Expand Down Expand Up @@ -252,5 +259,5 @@ SOFTWARE.

## Copyright

Copyright (c) 2021 grizzelbee <open.source@hingsen.de>
Copyright (c) 2022 grizzelbee <open.source@hingsen.de>

16 changes: 0 additions & 16 deletions admin/index_m.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@
<script type="text/javascript" src="words.js"></script>

<script type="text/javascript">


// Create secrect for encrypted password storage
var secret = '';

function load(settings, onChange) {
if (!settings) return;
$('.value').each(function () {
Expand All @@ -34,14 +29,6 @@
$key.prop('checked', settings[id])
.on('change', () => onChange());
} else {
if (id === 'vbusPassword') {
// get the system secret for pwd de-/encryption
socket.emit('getObject', 'system.config', function (err, obj) {
secret = (obj.native ? obj.native.secret : '');
settings[id] = decrypt(secret, settings[id]);
$key.val(settings[id]).on('change', () => onChange());
});
}
// do not call onChange direct, because onChange could expect some arguments
$key.val(settings[id])
.on('change', () => onChange())
Expand All @@ -64,9 +51,6 @@
obj[id] = $this.prop('checked');
} else {
let value = $this.val();
if ( id === 'vbusPassword') {
value = encrypt(secret, value);
}
obj[id] = value;
}
});
Expand Down
17 changes: 15 additions & 2 deletions io-package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
{
"common": {
"name": "resol",
"version": "0.4.0",
"version": "0.4.2",
"news": {
"0.4.2": {
"en": "Fixed some issues shown up at review.",
"de": "Einige Probleme behoben, die bei der Überprüfung auftauchten.",
"ru": "Исправлены некоторые проблемы, обнаруженные при проверке.",
"pt": "Corrigidos alguns problemas mostrados na revisão.",
"nl": "Enkele problemen opgelost die tijdens de beoordeling werden weergegeven.",
"fr": "Correction de certains problèmes signalés lors de la révision.",
"it": "Risolti alcuni problemi mostrati durante la revisione.",
"es": "Se corrigieron algunos problemas que se mostraron en la revisión.",
"pl": "Naprawiono niektóre problemy, które pojawiły się podczas przeglądu.",
"zh-cn": "修复了审查时出现的一些问题。"
},
"0.4.0": {
"en": "Trying more than one time to connect when network isn't setup properly. E.g. on router startup.",
"de": "Versuchen Sie mehr als einmal, eine Verbindung herzustellen, wenn das Netzwerk nicht richtig eingerichtet ist. ",
Expand Down Expand Up @@ -130,7 +142,8 @@
"dataSource": "push",
"dependencies": [
{
"js-controller": ">=3.0.0"
"js-controller": ">=3.0.0",
"admin": ">=4.0.9"
}
],
"plugins": {
Expand Down
47 changes: 23 additions & 24 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ class resol extends utils.Adapter {
const optimizer = await vbus.ConfigurationOptimizerFactory.createOptimizerByDeviceAddress(context.deviceAddress);
context.optimizer = optimizer;
if (!optimizer) {
throw new Error('Unable to create optimizer for master with address 0x' + context.deviceAddress.toString(16));
// log error and exit function
this.log.error('Unable to create optimizer for master with address 0x' + context.deviceAddress.toString(16));
return;
}
context.customizer = new vbus.ConnectionCustomizer({
deviceAddress: context.deviceAddress,
Expand All @@ -75,9 +77,9 @@ class resol extends utils.Adapter {
optimize: false,
};
this.log.debug('Start Optimizer');
savedConfig = await context.customizer.saveConfiguration(saveConfig, oldConfig, options);
savedConfig = await context.customizer.saveConfiguration(saveConfig, oldConfig, options) ;
} else {
this.log.debug('Optimizer savedConfig = loadedConfig ', savedConfig);
this.log.debug('Optimizer savedConfig = loadedConfig ', savedConfig || 'Not initialized!');
}
this.log.debug('Save config ' + JSON.stringify(savedConfig));
savedConfig.reduce((memo, value) => {
Expand Down Expand Up @@ -147,7 +149,7 @@ class resol extends utils.Adapter {
type: 'string'
},
native: {}
}, undefined);
}, null);

this.log.debug('[generateDP]->Resol-Address/Resol-ID: [' + resolAddr + '] : [' + resolId + ']');
const setupResolType = await this.getJSONByResolId(resolAddr);
Expand All @@ -163,7 +165,7 @@ class resol extends utils.Adapter {
this.log.debug('[generateDP]->item ' + JSON.stringify(item));
// create dp
let thisRole = 'value';
if (item.states) thisRole = 'indicator';
if (item.states) thisRole = 'switch';

this.createOrExtendObject(resolId + actionPath + item.dpName, {
type: 'state',
Expand All @@ -178,7 +180,7 @@ class resol extends utils.Adapter {
write: true
},
native: {}
}, undefined);
}, null);
this.subscribeStates(resolId + actionPath + item.dpName);
});
})
Expand Down Expand Up @@ -274,20 +276,22 @@ class resol extends utils.Adapter {
let result;
jsoncontrollerSetupItems.dp.forEach(item => {
if (item.dpName===thisName) {
this.log.debug('dp->Name found'+JSON.stringify(item));
this.log.debug('dp->Name found'+JSON.stringify(item));
result=item.type;
}
});
return result;
});
return result;
}

async loadMyConfig (context) {
try{
if (jsoncontrollerSetupItems) {
if (jsoncontrollerSetupItems) {
const optimizer = await vbus.ConfigurationOptimizerFactory.createOptimizerByDeviceAddress(context.deviceAddress);
context.optimizer = optimizer;
if (!optimizer) {
throw new Error('Unable to create optimizer for master with address 0x' + context.deviceAddress.toString(16));
// log error and exit function
this.log.error('Unable to create optimizer for master with address 0x' + context.deviceAddress.toString(16));
return;
}
context.customizer = new vbus.ConnectionCustomizer({
deviceAddress: context.deviceAddress,
Expand All @@ -300,7 +304,7 @@ class resol extends utils.Adapter {
jsoncontrollerSetupItems.dp.forEach(item => {
const fct = this.searchForFctItem(item.dpName);
if (fct.cmd) {
// generate readConfig
// generate readConfig
const thisConfig = {valueId: fct.cmd};
readConfig.push(thisConfig);
}
Expand Down Expand Up @@ -374,7 +378,10 @@ class resol extends utils.Adapter {
}
}


/*
* @param {object} config Current active config for adapter
* @returns {string} Result of the check
* */
async configIsValid(config) {
this.log.debug('configIsValid Function ');
this.log.debug('Entering Function [configIsValid]');
Expand Down Expand Up @@ -716,7 +723,7 @@ class resol extends utils.Adapter {
this.createOrExtendObject(objectId, {type: 'state', common}, value);
});
});
// Establish connection
// Establish connection
this.log.info('Waiting for Connection...');
let connected = false;
do {
Expand Down Expand Up @@ -744,19 +751,11 @@ class resol extends utils.Adapter {
this.configIsValid(this.config)
.then(result => {
this.log.info(result);
this.getForeignObject('system.config', (err, obj) => {
if (this.supportsFeature && this.supportsFeature('ADAPTER_AUTO_DECRYPT_NATIVE')) {
if (obj && obj.native && obj.native.secret) {
//noinspection JSUnresolvedVariable
this.config.vbusPassword = this.decrypt(obj.native.secret, this.config.vbusPassword);
}
this.main();
}
});
this.main();
})
.catch(err => {
this.log.error(err);
this.setStateAsync('info.connection', false);
this.setStateAsync('info.connection', false, true);
this.terminate('Terminating Adapter until Configuration is completed', 11);
});
} catch (error) {
Expand Down
Loading

0 comments on commit c6bb287

Please sign in to comment.