iobroker.squeezeboxrpc 1.3.8 → 1.3.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/io-package.json +4 -1
- package/lib/iosbplayer.js +15 -14
- package/lib/iosbserver.js +9 -14
- package/package.json +1 -1
package/README.md
CHANGED
package/io-package.json
CHANGED
package/lib/iosbplayer.js
CHANGED
|
@@ -496,7 +496,7 @@ function ioSBPlayer(server,playerdata) {
|
|
|
496
496
|
this.doAlarmsUpdateStatus = function(result) {
|
|
497
497
|
this.log.silly('doAlarmsUpdateStatus');
|
|
498
498
|
let alarmdata = JSON.stringify(result.result);
|
|
499
|
-
this.setState(this.sbPlayerStatusMain['alarms'].name,alarmdata,this.statePath,this.playername);
|
|
499
|
+
this.setState(this.sbPlayerStatusMain['alarms'].name,this.convertState(this.sbPlayerStatusMain['alarms'],alarmdata),this.statePath,this.playername);
|
|
500
500
|
};
|
|
501
501
|
this.doPlayerUpdateStatus = function(result) {
|
|
502
502
|
this.log.silly('doPlayerUpdateStatus');
|
|
@@ -504,7 +504,7 @@ function ioSBPlayer(server,playerdata) {
|
|
|
504
504
|
let playerdata = result.result;
|
|
505
505
|
|
|
506
506
|
for (const key in this.sbPlayerStatusMain) {
|
|
507
|
-
let value =
|
|
507
|
+
let value = "";
|
|
508
508
|
if (key == 'state') continue;
|
|
509
509
|
if (key == 'playlist') continue;
|
|
510
510
|
if (key == 'playerid') continue;
|
|
@@ -529,13 +529,13 @@ function ioSBPlayer(server,playerdata) {
|
|
|
529
529
|
if (key == 'remote') value = 0;
|
|
530
530
|
if (key == 'remote') this.remote = 0;
|
|
531
531
|
}
|
|
532
|
-
this.setState(this.sbPlayerStatusMain[key].name,value,this.statePath,this.playername);
|
|
532
|
+
this.setState(this.sbPlayerStatusMain[key].name,this.convertState(this.sbPlayerStatusMain[key],value),this.statePath,this.playername);
|
|
533
533
|
}
|
|
534
|
-
this.setState(this.sbPlayerStatusMain['playerid'].name,this.playerid,this.statePath,this.playername);
|
|
534
|
+
this.setState(this.sbPlayerStatusMain['playerid'].name,this.convertState(this.sbPlayerStatusMain['playerid'],this.playerid),this.statePath,this.playername);
|
|
535
535
|
if (!result.result.playlist_loop) return;
|
|
536
536
|
playerdata = result.result.playlist_loop.find(function(el){return el['playlist index']==this.playlist_cur_index;}.bind(result.result));
|
|
537
537
|
for (const key in this.sbPlayerStatusLoop) {
|
|
538
|
-
let value =
|
|
538
|
+
let value = "";
|
|
539
539
|
if (playerdata.hasOwnProperty(key)) {
|
|
540
540
|
value = playerdata[key];
|
|
541
541
|
if (key == 'coverid') {
|
|
@@ -555,12 +555,12 @@ function ioSBPlayer(server,playerdata) {
|
|
|
555
555
|
value = decodeURIComponent(m[1]);
|
|
556
556
|
}
|
|
557
557
|
}
|
|
558
|
-
this.setState(this.sbPlayerStatusLoop[key].name,value,this.statePath,this.playername);
|
|
558
|
+
this.setState(this.sbPlayerStatusLoop[key].name,this.convertState(this.sbPlayerStatusLoop[key],value),this.statePath,this.playername);
|
|
559
559
|
} else {
|
|
560
560
|
if (key == 'remote_title' && this.remote == 0 ) {
|
|
561
561
|
value = '';
|
|
562
562
|
}
|
|
563
|
-
if (fullStatus) this.setState(this.sbPlayerStatusLoop[key].name,value,this.statePath,this.playername);
|
|
563
|
+
if (fullStatus) this.setState(this.sbPlayerStatusLoop[key].name,this.convertState(this.sbPlayerStatusLoop[key],value),this.statePath,this.playername);
|
|
564
564
|
}
|
|
565
565
|
}
|
|
566
566
|
if (fullStatus) {
|
|
@@ -596,9 +596,9 @@ function ioSBPlayer(server,playerdata) {
|
|
|
596
596
|
pla.push(pli);
|
|
597
597
|
}
|
|
598
598
|
if (this.adapter.config.useplaylist) {
|
|
599
|
-
this.setState(this.sbPlayerStatusMain['playlist'].name,JSON.stringify(pla),this.statePath,this.playername);
|
|
599
|
+
this.setState(this.sbPlayerStatusMain['playlist'].name,this.convertState(this.sbPlayerStatusMain['playlist'],JSON.stringify(pla)),this.statePath,this.playername);
|
|
600
600
|
} else {
|
|
601
|
-
this.setState(this.sbPlayerStatusMain['playlist'].name,'',this.statePath,this.playername);
|
|
601
|
+
this.setState(this.sbPlayerStatusMain['playlist'].name,this.convertState(this.sbPlayerStatusMain['playlist'],''),this.statePath,this.playername);
|
|
602
602
|
}
|
|
603
603
|
}
|
|
604
604
|
return;
|
|
@@ -772,11 +772,6 @@ function ioSBPlayer(server,playerdata) {
|
|
|
772
772
|
stateTemplate.exist = true;
|
|
773
773
|
return stateTemplate;
|
|
774
774
|
}
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
775
|
this.request = function(playerid,params, callback) {
|
|
781
776
|
if (this.connected) this.server.request(playerid, params, callback);
|
|
782
777
|
};
|
|
@@ -793,6 +788,12 @@ function ioSBPlayer(server,playerdata) {
|
|
|
793
788
|
this.adapter.setState(name, value, true);
|
|
794
789
|
}
|
|
795
790
|
};
|
|
791
|
+
this.convertState = function(stateTemplate,value) {
|
|
792
|
+
if (stateTemplate.type == "string") return String(value);
|
|
793
|
+
if (stateTemplate.type == "number") return Number(value);
|
|
794
|
+
this.log.debug('Missing conversion function for type ' + stateTemplate.type + ' Please report.');
|
|
795
|
+
return value;
|
|
796
|
+
}
|
|
796
797
|
this.log.silly = function(s) {
|
|
797
798
|
if (this.logsilly) this.adapter.log.silly(s);
|
|
798
799
|
}.bind(this);
|
package/lib/iosbserver.js
CHANGED
|
@@ -417,15 +417,12 @@ function IoSbServer(adapter) {
|
|
|
417
417
|
this.checkServerstatusStates(result);
|
|
418
418
|
for (const key in this.sbServerStatus){
|
|
419
419
|
if (result.result.hasOwnProperty(key)) {
|
|
420
|
-
this.setState(this.sbServerStatus[key].name,result.result[key],this.ServerStatePath);
|
|
420
|
+
this.setState(this.sbServerStatus[key].name,this.convertState(this.sbServerStatus[key],result.result[key]),this.ServerStatePath);
|
|
421
421
|
}
|
|
422
422
|
}
|
|
423
423
|
this.checkNewPlayer(result.result.players_loop);
|
|
424
424
|
this.checkPlayer(result.result.players_loop);
|
|
425
425
|
};
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
426
|
this.newgetFavorites = function() {
|
|
430
427
|
this.log.silly('newgetFavorites');
|
|
431
428
|
this.newgetFavoritesDP(
|
|
@@ -469,7 +466,7 @@ function IoSbServer(adapter) {
|
|
|
469
466
|
}
|
|
470
467
|
Promise.all(promises).then(function(){
|
|
471
468
|
this.log.debug(`All favorite objects deleted`);
|
|
472
|
-
callback();
|
|
469
|
+
if (callback) callback();
|
|
473
470
|
}.bind(this));
|
|
474
471
|
};
|
|
475
472
|
this.newsetFavoritesDP = function(favorites) {
|
|
@@ -490,7 +487,7 @@ function IoSbServer(adapter) {
|
|
|
490
487
|
}
|
|
491
488
|
const stateTemplate = this.sbFavoritesState[key];
|
|
492
489
|
this.createObject(stateTemplate,this.FavoritesStatePath,id,
|
|
493
|
-
()=>this.setState(this.sbFavoritesState[key].name,favorite[key],this.FavoritesStatePath,id,false)
|
|
490
|
+
()=>this.setState(this.sbFavoritesState[key].name,this.convertState(this.sbFavoritesState[key],favorite[key]),this.FavoritesStatePath,id,false)
|
|
494
491
|
);
|
|
495
492
|
}
|
|
496
493
|
}
|
|
@@ -754,13 +751,12 @@ function IoSbServer(adapter) {
|
|
|
754
751
|
stateTemplate.exist = true;
|
|
755
752
|
return stateTemplate;
|
|
756
753
|
};
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
};
|
|
754
|
+
this.convertState = function(stateTemplate,value) {
|
|
755
|
+
if (stateTemplate.type == "string") return String(value);
|
|
756
|
+
if (stateTemplate.type == "number") return Number(value);
|
|
757
|
+
this.log.debug('Missing conversion function for type ' + stateTemplate.type + ' Please report.');
|
|
758
|
+
return value;
|
|
759
|
+
}
|
|
764
760
|
this.log.silly = function(s) {
|
|
765
761
|
if (this.logsilly) this.adapter.log.silly(s);
|
|
766
762
|
}.bind(this);
|
|
@@ -773,7 +769,6 @@ function IoSbServer(adapter) {
|
|
|
773
769
|
this.log.info = function(s) {
|
|
774
770
|
this.adapter.log.info(s);
|
|
775
771
|
}.bind(this);
|
|
776
|
-
this.test();
|
|
777
772
|
this.getDiscoverServers();
|
|
778
773
|
this.sbServer.on('register', this.init.bind(this));
|
|
779
774
|
}
|