Skip to content

Commit

Permalink
fixed DMP120 file handling
Browse files Browse the repository at this point in the history
  • Loading branch information
mschlgl committed Mar 1, 2024
1 parent 30c7ac5 commit 780b869
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 31 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ If you are a non commercial organisation or use it for private use you can get a
* (Bannsaenger) updated to adapter-dev and release script
* (Bannsaenger) updated dependencies

### 0.2.3
* (mschlgl) fixed DMP120 file handling

### 0.2.2
* (mschlgl) fixed SMD202 loopmode command

Expand Down
6 changes: 5 additions & 1 deletion io-package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
{
"common": {
"name": "extron",
"version": "0.2.2",
"version": "0.2.3",
"news": {
"0.2.3": {
"en": "fixed DMP 128 file handling",
"de": "Dateiverwaltung für DMP!128 korrigiert"
},
"0.2.2": {
"en": "fixed SMD202 loopmode command",
"de": "Fehler im Befehl loopmode für den SMD202 behoben"
Expand Down
41 changes: 13 additions & 28 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
*
* iobroker extron (SIS) Adapter V0.2.2
* iobroker extron (SIS) Adapter V0.2.3
*
* Copyright (c) 2020-2024, Bannsaenger <[email protected]>
*
Expand Down Expand Up @@ -2015,32 +2015,16 @@ class Extron extends utils.Adapter {
*/
async setUserFilesAsync(userFileList) {
try {
/**
switch (this.config.type) {
case 'ssh' :
userFileList = data.toString().split('\r\r\n'); // split the list into separate lines
break;
case 'telnet' :
userFileList = data.toString().split('\r\n'); // split the list into separate lines
break;
}
*/
//const actFiles = userFileList.length;
let i;
/**
for (i=1; i<= this.fileList.files.length; i++) {
await this.delObjectAsync(`fs.files.${i}.filename`); // delete filename state from database
await this.delObjectAsync(`fs.files.${i}`); // delete file object from database
}
**/
//await this.delObjectAsync(`fs.files`,{recursive: true}); // delete files object from database
//await this.setObjectAsync(`fs.files`, this.objectsTemplate.userflash.file); // recreate files object
i = 0;
let i = 0;
userFileList.sort(); // sort list alphabetically to resemble DSP configurator display
this.setObjectNotExistsAsync(this.objectsTemplate.userflash.file._id, this.objectsTemplate.userflash.file);
for (const userFile of userFileList) { // check each line
if (this.fileList.freeSpace) continue; // skip remaining lines if last entry already found
this.log.debug(`freespace: ${this.fileList.freespace}`)
//if (this.fileList.freeSpace) continue; // skip remaining lines if last entry already found
// @ts-ignore
else this.fileList.freeSpace = userFile.match(/(\d+\b Bytes Left)/g)?`${userFile.match(/(\d+\b Bytes Left)/g)[0]}`:''; //check for last line containing remaining free space
if (this.fileList.freeSpace) continue; // skip remaining lines if last entry already found
//this.fileList.freeSpace = userFile.match(/(\d+\b Bytes Left)/g)?`${userFile.match(/(\d+\b Bytes Left)/g)[0]}`:''; //check for last line containing remaining free space
if (userFile.match(/(\d+\b Bytes Left)/g)) this.fileList.freeSpace = userFile.match(/(\d+\b Bytes Left)/g)[0];
//if (this.fileList.freeSpace) continue; // skip remaining lines if last entry already found
// @ts-ignore
this.file.fileName = userFile.match(/^(.+\.\w{3}\b)/g)?`${userFile.match(/^(.+\.\w{3}\b)/g)[0]}`:''; // extract filename
// @ts-ignore
Expand All @@ -2050,15 +2034,16 @@ class Extron extends utils.Adapter {
if (this.file.fileName.match(/.raw$/)) { // check if AudioFile
i++;
this.fileList.files[i] = this.file; // add to filelist array
await this.setObjectAsync(`fs.files.${i}`, this.objectsTemplate.userflash.files[0]);
await this.setObjectAsync(`fs.files.${i}.filename`, this.objectsTemplate.userflash.files[1]);
await this.setObjectAsync(`fs.files.${i}`, this.objectsTemplate.userflash.files.channel);
await this.setObjectAsync(`fs.files.${i}.filename`, this.objectsTemplate.userflash.files.filename);
this.setState(`fs.files.${i}.filename`, this.file.fileName, true);
//this.setState(`fs.filecount`, i, true);
this.log.debug(`Object "fs.files.${i}.filename ${this.file.fileName}" updated`);
}
}
this.setState(`fs.filecount`, i, true);
this.setState('fs.freespace',this.fileList.freeSpace,true);
this.setState('fs.dir',false,true);
this.log.debug(`Extron userFlash filelist updated: ${userFileList.join('; ')}`);
} catch (err) {
this.requestDir = false;
this.errorHandler(err, 'setUserFiles');
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "iobroker.extron",
"version": "0.2.2",
"version": "0.2.3",
"description": "Extron SIS adapter",
"author": "Bannsaenger <[email protected]>",
"homepage": "https://github.com/Bannsaenger/ioBroker.extron",
Expand Down

0 comments on commit 780b869

Please sign in to comment.