Skip to content

Commit

Permalink
admin5 UI ok
Browse files Browse the repository at this point in the history
  • Loading branch information
git-kick committed Sep 7, 2024
1 parent 7a58e98 commit 049fa02
Show file tree
Hide file tree
Showing 4 changed files with 175 additions and 31 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,9 @@ MODIFIED ADAPTER SETTINGS - do not re-use settings stored in json-file!
* \[E605\]: updated copyright to 2024 in README.md
* \[E605\]: removed .npmignore from project directory
* \[W040\]: added keyword "ioBroker" in package.json
* \[W130\]: deleted all but some recent common.news in io-packege.json
* \[W130\]: deleted all but some recent common.news in io-package.json
* \[S522\]: migrated to admin5 UI (jsonConfig.json5)


### 1.2.6

Expand Down
151 changes: 151 additions & 0 deletions admin/jsonConfig.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
{
"type": "tabs",
"i18n": true,
"items": {
"Tab_Options": {
"type": "panel",
"label": "options",
"items": {
"title_connection": {
"newLine": true,
"type": "header",
"text": "title_connection",
"size": 2
},
"portal_user": {
"type": "text",
"label": "portal_user",
"newLine": true,
"xs": 12, "sm": 6, "md": 3, "lg": 3
},
"portal_password": {
"type": "password",
"label": "portal_password",
"xs": 12, "sm": 6, "md": 3, "lg": 3
},
"e3dc_ip": {
"type": "text",
"label": "e3dc_ip",
"newLine": true,
"xs": 12, "sm": 6, "md": 3, "lg": 3
},
"e3dc_port": {
"type": "port",
"label": "e3dc_port",
"xs": 12, "sm": 6, "md": 3, "lg": 3
},
"rscp_password": {
"type": "password",
"label": "rscp_password",
"xs": 12, "sm": 6, "md": 3, "lg": 3
},
"title_intervals": {
"newLine": true,
"type": "header",
"text": "title_intervals",
"size": 2
},
"setpower_interval": {
"type": "number",
"label": "setpower_interval",
"min": 0,
"xs": 12, "sm": 6, "md": 3, "lg": 3
},
"send_tuple_delay": {
"type": "number",
"label": "send_tuple_delay",
"min": 0,
"xs": 12, "sm": 6, "md": 3, "lg": 3
},
"title_namespaces": {
"newLine": true,
"type": "header",
"text": "title_namespaces",
"size": 2
},
"query_bat": {
"type": "checkbox",
"label": "query_bat",
"xs": 12, "sm": 12,"md": 6, "lg": 3
},
"query_ems": {
"type": "checkbox",
"label": "query_ems",
"xs": 12, "sm": 12,"md": 6, "lg": 3
},
"query_ep": {
"type": "checkbox",
"label": "query_ep",
"xs": 12, "sm": 12,"md": 6, "lg": 3
},
"query_pvi": {
"type": "checkbox",
"label": "query_pvi",
"xs": 12, "sm": 12,"md": 6, "lg": 3
},
"query_sys": {
"type": "checkbox",
"label": "query_sys",
"xs": 12, "sm": 12,"md": 6, "lg": 3
},
"query_wb": {
"type": "checkbox",
"label": "query_wb",
"xs": 12, "sm": 12,"md": 6, "lg": 3
},
"query_db": {
"type": "checkbox",
"label": "query_db",
"xs": 12, "sm": 12,"md": 6, "lg": 3
},
"query_info": {
"type": "checkbox",
"label": "query_info",
"xs": 12, "sm": 12,"md": 6, "lg": 3
}
}
},
"Tab_Polling_Intervals": {
"type": "panel",
"label": "polling_intervals",
"noDelete": true,
"items": {
"title_polling_intervals": {
"newLine": true,
"type": "header",
"text": "title_polling_intervals",
"size": 2
},
"polling_intervals": {
"type": "table",
"label": "",
"xs": 12, "sm": 12,"md": 12, "lg": 9,
"items": [
{
"type": "text",
"attr": "tag",
"width": "80% ",
"title": "column_tag",
"filter": true,
"sort": true,
"readOnly": true,
"default": ""
},
{
"type": "text",
"attr": "interval",
"width": "20% ",
"title": "column_interval",
"tooltip": "S/M/L/N",
"filter": false,
"sort": false,
"default": "L",
"validator": "return (data.intervall==='') || data.interval.match(/^[SMLN]$/);",
"validatorNoSaveOnError": true
}
]
}
}
}
}
}
31 changes: 20 additions & 11 deletions io-package.json
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,9 @@
"compact": true,
"connectionType": "local",
"dataSource": "poll",
"materialize": true,
"materializeTab": false,
"adminUI": {
"config": "json"
},
"dependencies": [
{
"js-controller": ">=5.0.19"
Expand All @@ -179,6 +180,14 @@
}
}
},
"protectedNative": [
"rscp_password",
"portal_password"
],
"encryptedNative": [
"rscp_password",
"portal_password"
],
"native": {
"e3dc_ip": "192.168.178.1",
"e3dc_port": 5033,
Expand Down Expand Up @@ -909,15 +918,15 @@
"polling_interval_long": 12,
"setpower_interval": 10,
"send_tuple_delay": 10,
"query_bat": "true",
"query_ems": "true",
"query_pm": "true",
"query_ep": "true",
"query_pvi": "true",
"query_sys": "true",
"query_wb": "true",
"query_info": "true",
"query_db": "true"
"query_bat": true,
"query_ems": true,
"query_pm": true,
"query_ep": true,
"query_pvi": true,
"query_sys": true,
"query_wb": true,
"query_info": true,
"query_db": true
},
"objects": [],
"instanceObjects": []
Expand Down
20 changes: 1 addition & 19 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -1726,15 +1726,6 @@ class E3dcRscp extends utils.Adapter {
}
}

// ioBroker best practice for password encryption, using key native.secret
decryptPassword( key="", value="" ) {
let result = "";
for ( let i = 0; i < value.length; ++i ) {
result += String.fromCharCode( key[i % key.length].charCodeAt( 0 ) ^ value.charCodeAt( i ) );
}
return result;
}

clearAllIntervals() {
if( this.dataPollingTimerS ) clearInterval( this.dataPollingTimerS );
if( this.dataPollingTimerM ) clearInterval( this.dataPollingTimerM );
Expand Down Expand Up @@ -2110,16 +2101,7 @@ class E3dcRscp extends utils.Adapter {

// Initialize your adapter here
this.log.debug( `config.*: (${this.config.e3dc_ip}, ${this.config.e3dc_port}, ${this.config.portal_user}, ${this.config.polling_interval_short}, ${this.config.polling_interval_medium}, ${this.config.polling_interval_long}, ${this.config.setpower_interval})` );
// @ts-ignore
this.getForeignObject( "system.config", ( err, obj ) => {
if ( obj && obj.native && obj.native.secret ) {
this.config.rscp_password = this.decryptPassword( obj.native.secret,this.config.rscp_password );
this.config.portal_password = this.decryptPassword( obj.native.secret,this.config.portal_password );
this.initChannel();
} else {
this.log.error( "Cannot initialize adapter because obj.native.secret is null." );
}
} );
this.initChannel();

// In order to get state updates, you need to subscribe to them. The following line adds a subscription for our variable we have created above.
this.subscribeStates( "RSCP.AUTHENTICATION" );
Expand Down

0 comments on commit 049fa02

Please sign in to comment.