Merge pull request #1116 from ticaki/main

some more types
This commit is contained in:
Armilar
2024-01-03 21:01:29 +01:00
committed by GitHub
3 changed files with 2730 additions and 783 deletions

1732
ioBroker/.iobroker/types/javascript.d.ts vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------- /*-----------------------------------------------------------------------
TypeScript v4.3.3.30 zur Steuerung des SONOFF NSPanel mit dem ioBroker by @Armilar / @TT-Tom / @ticaki / @Sternmiere / @Britzelpuf / @ravenS0ne TypeScript v4.3.3.31 zur Steuerung des SONOFF NSPanel mit dem ioBroker by @Armilar / @TT-Tom / @ticaki / @Sternmiere / @Britzelpuf / @ravenS0ne
- abgestimmt auf TFT 53 / v4.3.3 / BerryDriver 9 / Tasmota 13.3.0 - abgestimmt auf TFT 53 / v4.3.3 / BerryDriver 9 / Tasmota 13.3.0
@joBr99 Projekt: https://github.com/joBr99/nspanel-lovelace-ui/tree/main/ioBroker @joBr99 Projekt: https://github.com/joBr99/nspanel-lovelace-ui/tree/main/ioBroker
NsPanelTs.ts (dieses TypeScript in ioBroker) Stable: https://github.com/joBr99/nspanel-lovelace-ui/blob/main/ioBroker/NsPanelTs.ts NsPanelTs.ts (dieses TypeScript in ioBroker) Stable: https://github.com/joBr99/nspanel-lovelace-ui/blob/main/ioBroker/NsPanelTs.ts
@@ -91,6 +91,11 @@ ReleaseNotes:
- 02.01.2024 - v4.3.3.29 Add Tasmota Buzzer for NotifyPage - 02.01.2024 - v4.3.3.29 Add Tasmota Buzzer for NotifyPage
- 02.02.2024 - v4.3.3.29 Fix ThermoPage -> UnSubScribsWatcher - 02.02.2024 - v4.3.3.29 Fix ThermoPage -> UnSubScribsWatcher
- 02.02.2024 - v4.3.3.30 Add stronger config type checks - 02.02.2024 - v4.3.3.30 Add stronger config type checks
- 03.02.2024 - v4.3.3.31 Remove: autoCreateAlias from cardMedia
- 03.02.2024 - v4.3.3.31 Remove: adapterPlayerInstance from every card except cardMedia
- 03.02.2024 - v4.3.3.31 [dev]: optional with type - cardMedia has adapterPlayerInstance all other not
- 03.02.2024 - v4.3.3.31 [dev]: add PlayerType some more work to do
- 03.02.2024 - v4.3.3.31 changed: adapterPlayerInstance instance 0-9 allowed. Always require a '.' at the end.
Todo: Todo:
- XX.XX.XXXX - v5.0.0 Change the bottomScreensaverEntity (rolling) if more than 6 entries are defined - XX.XX.XXXX - v5.0.0 Change the bottomScreensaverEntity (rolling) if more than 6 entries are defined
@@ -953,7 +958,7 @@ export const config: Config = {
// _________________________________ DE: Ab hier keine Konfiguration mehr _____________________________________ // _________________________________ DE: Ab hier keine Konfiguration mehr _____________________________________
// _________________________________ EN: No more configuration from here _____________________________________ // _________________________________ EN: No more configuration from here _____________________________________
const scriptVersion: string = 'v4.3.3.30'; const scriptVersion: string = 'v4.3.3.31';
const tft_version: string = 'v4.3.3'; const tft_version: string = 'v4.3.3';
const desired_display_firmware_version = 53; const desired_display_firmware_version = 53;
const berry_driver_version = 9; const berry_driver_version = 9;
@@ -3022,7 +3027,9 @@ function HandleMessage(typ: string, method: string, page: number | undefined, wo
} }
let pageItem: PageItem = findPageItem(tempId); let pageItem: PageItem = findPageItem(tempId);
if (pageItem !== undefined) { if (pageItem !== undefined) {
SendToPanel(GenerateDetailPage(words[2], tempPageItem[1], pageItem, placeId)); let temp: string | mediaOptional | undefined = tempPageItem[1]
if (isMediaOptional(temp)) SendToPanel(GenerateDetailPage(words[2], temp, pageItem, placeId));
else SendToPanel(GenerateDetailPage(words[2], undefined, pageItem, placeId));
} }
} }
break; break;
@@ -4286,8 +4293,8 @@ function GenerateThermoPage(page: PageThermo): Payload[] {
if ((i_list.length - 3) != 0) { if ((i_list.length - 3) != 0) {
let i = 0; let i = 0;
switch (o.common.role) {
if (o.common.role == 'thermostat') { case 'thermostat': {
if (existsState(id + '.AUTOMATIC') && getState(id + '.AUTOMATIC').val != null) { if (existsState(id + '.AUTOMATIC') && getState(id + '.AUTOMATIC').val != null) {
if (getState(id + '.AUTOMATIC').val) { if (getState(id + '.AUTOMATIC').val) {
@@ -4429,31 +4436,31 @@ function GenerateThermoPage(page: PageThermo): Payload[] {
bt[j] = '~~~~'; bt[j] = '~~~~';
} }
} }
break;
if (o.common.role == 'airCondition') { case 'airCondition': {
if (existsState(id + '.MODE') && getState(id + '.MODE').val != null) { if (existsState(id + '.MODE') && getState(id + '.MODE').val != null) {
let Mode = getState(id + '.MODE').val let Mode = getState(id + '.MODE').val
let States = getObject(id + '.MODE').common.states; let States = getObject(id + '.MODE').common.states;
let iconIndex: number = 1; let iconIndex: number = 1;
for(const statekey in States) { for (const statekey in States) {
let stateName: string = States[statekey]; let stateName: string = States[statekey];
let stateKeyNumber: number = parseInt(statekey); let stateKeyNumber: number = parseInt(statekey);
if(stateName == 'OFF' || stateKeyNumber > 6) { if (stateName == 'OFF' || stateKeyNumber > 6) {
continue; continue;
} }
if(stateKeyNumber == Mode) { if (stateKeyNumber == Mode) {
statusStr = stateName.replace('_', ' '); statusStr = stateName.replace('_', ' ');
} }
switch(stateName) { switch (stateName) {
case 'AUTO': case 'AUTO':
if (page.items[0].iconArray !== undefined && page.items[0].iconArray[1] !== '') { if (page.items[0].iconArray !== undefined && page.items[0].iconArray[1] !== '') {
tempIcon = page.items[0].iconArray[1]; tempIcon = page.items[0].iconArray[1];
} else { } else {
tempIcon = 'air-conditioner'; tempIcon = 'air-conditioner';
} }
if(stateKeyNumber == Mode) { if (stateKeyNumber == Mode) {
bt[iconIndex] = Icons.GetIcon(tempIcon) + '~1024~1~' + 'AUTO' + '~'; bt[iconIndex] = Icons.GetIcon(tempIcon) + '~1024~1~' + 'AUTO' + '~';
} else { } else {
bt[iconIndex] = Icons.GetIcon(tempIcon) + '~35921~0~' + 'AUTO' + '~'; bt[iconIndex] = Icons.GetIcon(tempIcon) + '~35921~0~' + 'AUTO' + '~';
@@ -4465,7 +4472,7 @@ function GenerateThermoPage(page: PageThermo): Payload[] {
} else { } else {
tempIcon = 'snowflake'; tempIcon = 'snowflake';
} }
if(stateKeyNumber == Mode) { if (stateKeyNumber == Mode) {
bt[iconIndex] = Icons.GetIcon(tempIcon) + '~11487~1~' + 'COOL' + '~'; bt[iconIndex] = Icons.GetIcon(tempIcon) + '~11487~1~' + 'COOL' + '~';
} else { } else {
bt[iconIndex] = Icons.GetIcon(tempIcon) + '~35921~0~' + 'COOL' + '~'; bt[iconIndex] = Icons.GetIcon(tempIcon) + '~35921~0~' + 'COOL' + '~';
@@ -4477,7 +4484,7 @@ function GenerateThermoPage(page: PageThermo): Payload[] {
} else { } else {
tempIcon = 'fire'; tempIcon = 'fire';
} }
if(stateKeyNumber == Mode) { if (stateKeyNumber == Mode) {
bt[iconIndex] = Icons.GetIcon(tempIcon) + '~64512~1~' + 'HEAT' + '~'; bt[iconIndex] = Icons.GetIcon(tempIcon) + '~64512~1~' + 'HEAT' + '~';
} else { } else {
bt[iconIndex] = Icons.GetIcon(tempIcon) + '~35921~0~' + 'HEAT' + '~'; bt[iconIndex] = Icons.GetIcon(tempIcon) + '~35921~0~' + 'HEAT' + '~';
@@ -4489,7 +4496,7 @@ function GenerateThermoPage(page: PageThermo): Payload[] {
} else { } else {
tempIcon = 'alpha-e-circle-outline'; tempIcon = 'alpha-e-circle-outline';
} }
if(stateKeyNumber == Mode) { if (stateKeyNumber == Mode) {
bt[iconIndex] = Icons.GetIcon(tempIcon) + '~2016~1~' + 'ECO' + '~'; bt[iconIndex] = Icons.GetIcon(tempIcon) + '~2016~1~' + 'ECO' + '~';
} else { } else {
bt[iconIndex] = Icons.GetIcon(tempIcon) + '~35921~0~' + 'ECO' + '~'; bt[iconIndex] = Icons.GetIcon(tempIcon) + '~35921~0~' + 'ECO' + '~';
@@ -4501,7 +4508,7 @@ function GenerateThermoPage(page: PageThermo): Payload[] {
} else { } else {
tempIcon = 'fan'; tempIcon = 'fan';
} }
if(stateKeyNumber == Mode) { if (stateKeyNumber == Mode) {
bt[iconIndex] = Icons.GetIcon(tempIcon) + '~11487~1~' + 'FAN_ONLY' + '~'; bt[iconIndex] = Icons.GetIcon(tempIcon) + '~11487~1~' + 'FAN_ONLY' + '~';
} else { } else {
bt[iconIndex] = Icons.GetIcon(tempIcon) + '~35921~0~' + 'FAN_ONLY' + '~'; bt[iconIndex] = Icons.GetIcon(tempIcon) + '~35921~0~' + 'FAN_ONLY' + '~';
@@ -4513,7 +4520,7 @@ function GenerateThermoPage(page: PageThermo): Payload[] {
} else { } else {
tempIcon = 'water-percent'; tempIcon = 'water-percent';
} }
if(stateKeyNumber == Mode) { if (stateKeyNumber == Mode) {
bt[iconIndex] = Icons.GetIcon(tempIcon) + '~60897~1~' + 'DRY' + '~'; bt[iconIndex] = Icons.GetIcon(tempIcon) + '~60897~1~' + 'DRY' + '~';
} else { } else {
bt[iconIndex] = Icons.GetIcon(tempIcon) + '~35921~0~' + 'DRY' + '~'; bt[iconIndex] = Icons.GetIcon(tempIcon) + '~35921~0~' + 'DRY' + '~';
@@ -4569,6 +4576,8 @@ function GenerateThermoPage(page: PageThermo): Payload[] {
} }
} }
} }
break;
}
} }
let destTemp2 = ''; let destTemp2 = '';
@@ -4703,29 +4712,39 @@ function subscribeMediaSubscriptionsAlexaAdd(id: string): void {
}); });
} }
async function createAutoMediaAlias(id: string, mediaDevice: string, adapterPlayerInstance: string) { async function createAutoMediaAlias (id: string, mediaDevice: string, adapterPlayerInstance: adapterPlayerInstanceType) {
if (autoCreateAlias) { if (autoCreateAlias) {
if (isSetOptionActive) { if (isSetOptionActive) {
if (adapterPlayerInstance == 'alexa2.0.') { switch (adapterPlayerInstance) {
if (existsObject(id) == false){ case "alexa2.0.":
case "alexa2.1.":
case "alexa2.2.":
case "alexa2.3.":
case "alexa2.4.":
case "alexa2.5.":
case "alexa2.6.":
case "alexa2.7.":
case "alexa2.8.":
case "alexa2.9.": {
if (existsObject(id) == false) {
log('Alexa Alias ' + id + ' does not exist - will be created now', 'info'); log('Alexa Alias ' + id + ' does not exist - will be created now', 'info');
let dpPath: string = adapterPlayerInstance + 'Echo-Devices.' + mediaDevice; const dpPath: string = adapterPlayerInstance + 'Echo-Devices.' + mediaDevice;
try { try {
setObject(id, {_id: id, type: 'channel', common: {role: 'media', name:'media'}, native: {}}); setObject(id, {_id: id, type: 'channel', common: {role: 'media', name: 'media'}, native: {}});
await createAliasAsync(id + '.ACTUAL', dpPath + '.Player.volume', true, <iobJS.StateCommon>{ type: 'number', role: 'value.volume', name: 'ACTUAL' }); await createAliasAsync(id + '.ACTUAL', dpPath + '.Player.volume', true, <iobJS.StateCommon> {type: 'number', role: 'value.volume', name: 'ACTUAL'});
await createAliasAsync(id + '.ALBUM', dpPath + '.Player.currentAlbum', true, <iobJS.StateCommon>{ type: 'string', role: 'media.album', name: 'ALBUM' }); await createAliasAsync(id + '.ALBUM', dpPath + '.Player.currentAlbum', true, <iobJS.StateCommon> {type: 'string', role: 'media.album', name: 'ALBUM'});
await createAliasAsync(id + '.ARTIST', dpPath + '.Player.currentArtist', true, <iobJS.StateCommon>{ type: 'string', role: 'media.artist', name: 'ARTIST' }); await createAliasAsync(id + '.ARTIST', dpPath + '.Player.currentArtist', true, <iobJS.StateCommon> {type: 'string', role: 'media.artist', name: 'ARTIST'});
await createAliasAsync(id + '.TITLE', dpPath + '.Player.currentTitle', true, <iobJS.StateCommon>{ type: 'string', role: 'media.title', name: 'TITLE' }); await createAliasAsync(id + '.TITLE', dpPath + '.Player.currentTitle', true, <iobJS.StateCommon> {type: 'string', role: 'media.title', name: 'TITLE'});
await createAliasAsync(id + '.NEXT', dpPath + '.Player.controlNext', true, <iobJS.StateCommon>{ type: 'boolean', role: 'button.next', name: 'NEXT' }); await createAliasAsync(id + '.NEXT', dpPath + '.Player.controlNext', true, <iobJS.StateCommon> {type: 'boolean', role: 'button.next', name: 'NEXT'});
await createAliasAsync(id + '.PREV', dpPath + '.Player.controlPrevious', true, <iobJS.StateCommon>{ type: 'boolean', role: 'button.prev', name: 'PREV' }); await createAliasAsync(id + '.PREV', dpPath + '.Player.controlPrevious', true, <iobJS.StateCommon> {type: 'boolean', role: 'button.prev', name: 'PREV'});
await createAliasAsync(id + '.PLAY', dpPath + '.Player.controlPlay', true, <iobJS.StateCommon>{ type: 'boolean', role: 'button.play', name: 'PLAY' }); await createAliasAsync(id + '.PLAY', dpPath + '.Player.controlPlay', true, <iobJS.StateCommon> {type: 'boolean', role: 'button.play', name: 'PLAY'});
await createAliasAsync(id + '.PAUSE', dpPath + '.Player.controlPause', true, <iobJS.StateCommon>{ type: 'boolean', role: 'button.pause', name: 'PAUSE' }); await createAliasAsync(id + '.PAUSE', dpPath + '.Player.controlPause', true, <iobJS.StateCommon> {type: 'boolean', role: 'button.pause', name: 'PAUSE'});
await createAliasAsync(id + '.STOP', dpPath + '.Commands.deviceStop', true, <iobJS.StateCommon>{ type: 'boolean', role: 'button.stop', name: 'STOP' }); await createAliasAsync(id + '.STOP', dpPath + '.Commands.deviceStop', true, <iobJS.StateCommon> {type: 'boolean', role: 'button.stop', name: 'STOP'});
await createAliasAsync(id + '.STATE', dpPath + '.Player.currentState', true, <iobJS.StateCommon>{ type: 'boolean', role: 'media.state', name: 'STATE' }); await createAliasAsync(id + '.STATE', dpPath + '.Player.currentState', true, <iobJS.StateCommon> {type: 'boolean', role: 'media.state', name: 'STATE'});
await createAliasAsync(id + '.VOLUME', dpPath + '.Player.volume', true, <iobJS.StateCommon>{ type: 'number', role: 'level.volume', name: 'VOLUME' }); await createAliasAsync(id + '.VOLUME', dpPath + '.Player.volume', true, <iobJS.StateCommon> {type: 'number', role: 'level.volume', name: 'VOLUME'});
await createAliasAsync(id + '.REPEAT', dpPath + '.Player.controlRepeat', true, <iobJS.StateCommon>{ type: 'boolean', role: 'media.mode.repeat', name: 'REPEAT' }); await createAliasAsync(id + '.REPEAT', dpPath + '.Player.controlRepeat', true, <iobJS.StateCommon> {type: 'boolean', role: 'media.mode.repeat', name: 'REPEAT'});
await createAliasAsync(id + '.SHUFFLE', dpPath + '.Player.controlShuffle', true, <iobJS.StateCommon>{ type: 'boolean', role: 'media.mode.shuffle', name: 'SHUFFLE' }); await createAliasAsync(id + '.SHUFFLE', dpPath + '.Player.controlShuffle', true, <iobJS.StateCommon> {type: 'boolean', role: 'media.mode.shuffle', name: 'SHUFFLE'});
} catch (err: any) { } catch (err: any) {
log('error at function createAutoMediaAlias Adapter Alexa2: ' + err.message, 'warn'); log('error at function createAutoMediaAlias Adapter Alexa2: ' + err.message, 'warn');
} }
@@ -4733,60 +4752,42 @@ async function createAutoMediaAlias(id: string, mediaDevice: string, adapterPlay
//Add Alexa Datapoints > v4.3.3.18 //Add Alexa Datapoints > v4.3.3.18
if (existsObject(id + '.DURATION') == false) { if (existsObject(id + '.DURATION') == false) {
let dpPath: string = adapterPlayerInstance + 'Echo-Devices.' + mediaDevice; let dpPath: string = adapterPlayerInstance + 'Echo-Devices.' + mediaDevice;
await createAliasAsync(id + '.DURATION', dpPath + '.Player.mediaLength', true, <iobJS.StateCommon>{ type: 'string', role: 'media.duration.text', name: 'DURATION' }); await createAliasAsync(id + '.DURATION', dpPath + '.Player.mediaLength', true, <iobJS.StateCommon> {type: 'string', role: 'media.duration.text', name: 'DURATION'});
await createAliasAsync(id + '.ELAPSED', dpPath + '.Player.mediaProgressStr', true, <iobJS.StateCommon>{ type: 'string', role: 'media.elapsed.text', name: 'ELAPSED' }); await createAliasAsync(id + '.ELAPSED', dpPath + '.Player.mediaProgressStr', true, <iobJS.StateCommon> {type: 'string', role: 'media.elapsed.text', name: 'ELAPSED'});
}
} }
if (adapterPlayerInstance == 'spotify-premium.0.') {
if (existsObject(id) == false){
log('Spotify Alias ' + id + ' does not exist - will be created now', 'info');
let dpPath: string = adapterPlayerInstance;
try {
setObject(id, {_id: id + 'player', type: 'channel', common: {role: 'media', name:'media'}, native: {}});
await createAliasAsync(id + '.ACTUAL', dpPath + 'player.volume', true, <iobJS.StateCommon>{ type: 'number', role: 'value.volume', name: 'ACTUAL' });
await createAliasAsync(id + '.ALBUM', dpPath + 'player.album', true, <iobJS.StateCommon>{ type: 'string', role: 'media.album', name: 'ALBUM' });
await createAliasAsync(id + '.ARTIST', dpPath + 'player.artistName', true, <iobJS.StateCommon>{ type: 'string', role: 'media.artist', name: 'ARTIST' });
await createAliasAsync(id + '.TITLE', dpPath + 'player.trackName', true, <iobJS.StateCommon>{ type: 'string', role: 'media.title', name: 'TITLE' });
await createAliasAsync(id + '.CONTEXT_DESCRIPTION', dpPath + 'player.contextDescription', true, <iobJS.StateCommon>{ type: 'string', role: 'media.station', name: 'CONTEXT_DESCRIPTION' });
await createAliasAsync(id + '.NEXT', dpPath + 'player.skipPlus', true, <iobJS.StateCommon>{ type: 'boolean', role: 'button.next', name: 'NEXT' });
await createAliasAsync(id + '.PREV', dpPath + 'player.skipMinus', true, <iobJS.StateCommon>{ type: 'boolean', role: 'button.prev', name: 'PREV' });
await createAliasAsync(id + '.PLAY', dpPath + 'player.play', true, <iobJS.StateCommon>{ type: 'boolean', role: 'button.play', name: 'PLAY' });
await createAliasAsync(id + '.PAUSE', dpPath + 'player.pause', true, <iobJS.StateCommon>{ type: 'boolean', role: 'button.pause', name: 'PAUSE' });
await createAliasAsync(id + '.STOP', dpPath + 'player.pause', true, <iobJS.StateCommon>{ type: 'boolean', role: 'button.stop', name: 'STOP' });
await createAliasAsync(id + '.STATE', dpPath + 'player.isPlaying', true, <iobJS.StateCommon>{ type: 'boolean', role: 'media.state', name: 'STATE' });
await createAliasAsync(id + '.VOLUME', dpPath + 'player.volume', true, <iobJS.StateCommon>{ type: 'number', role: 'level.volume', name: 'VOLUME' });
await createAliasAsync(id + '.REPEAT', dpPath + 'player.repeat', true, <iobJS.StateCommon>{ type: 'string', role: 'value', name: 'REPEAT' });
await createAliasAsync(id + '.SHUFFLE', dpPath + 'player.shuffle', true, <iobJS.StateCommon>{ type: 'string', role: 'value', name: 'SHUFFLE' });
} catch (err: any) {
log('error at function createAutoMediaAlias Adapter spotify-premium: ' + err.message, 'warn');
} }
} break;
} case "sonos.0.":
case "sonos.1.":
if (adapterPlayerInstance == 'sonos.0.') { case "sonos.2.":
if (existsObject(id) == false){ case "sonos.3.":
case "sonos.4.":
case "sonos.5.":
case "sonos.6.":
case "sonos.7.":
case "sonos.8.":
case "sonos.9.": {
if (existsObject(id) == false) {
log('Sonos Alias ' + id + ' does not exist - will be created now', 'info'); log('Sonos Alias ' + id + ' does not exist - will be created now', 'info');
let dpPath: string = adapterPlayerInstance + 'root.' + mediaDevice; const dpPath: string = adapterPlayerInstance + 'root.' + mediaDevice;
try { try {
setObject(id, {_id: id, type: 'channel', common: {role: 'media', name:'media'}, native: {}}); setObject(id, {_id: id, type: 'channel', common: {role: 'media', name: 'media'}, native: {}});
await createAliasAsync(id + '.ACTUAL', dpPath + '.volume', true, <iobJS.StateCommon>{ type: 'number', role: 'value.volume', name: 'ACTUAL' }); await createAliasAsync(id + '.ACTUAL', dpPath + '.volume', true, <iobJS.StateCommon> {type: 'number', role: 'value.volume', name: 'ACTUAL'});
await createAliasAsync(id + '.ALBUM', dpPath + '.current_album', true, <iobJS.StateCommon>{ type: 'string', role: 'media.album', name: 'ALBUM' }); await createAliasAsync(id + '.ALBUM', dpPath + '.current_album', true, <iobJS.StateCommon> {type: 'string', role: 'media.album', name: 'ALBUM'});
await createAliasAsync(id + '.ARTIST', dpPath + '.current_artist', true, <iobJS.StateCommon>{ type: 'string', role: 'media.artist', name: 'ARTIST' }); await createAliasAsync(id + '.ARTIST', dpPath + '.current_artist', true, <iobJS.StateCommon> {type: 'string', role: 'media.artist', name: 'ARTIST'});
await createAliasAsync(id + '.TITLE', dpPath + '.current_title', true, <iobJS.StateCommon>{ type: 'string', role: 'media.title', name: 'TITLE' }); await createAliasAsync(id + '.TITLE', dpPath + '.current_title', true, <iobJS.StateCommon> {type: 'string', role: 'media.title', name: 'TITLE'});
await createAliasAsync(id + '.CONTEXT_DESCRIPTION', dpPath + '.current_station', true, <iobJS.StateCommon>{ type: 'string', role: 'media.station', name: 'CONTEXT_DESCRIPTION' }); await createAliasAsync(id + '.CONTEXT_DESCRIPTION', dpPath + '.current_station', true, <iobJS.StateCommon> {type: 'string', role: 'media.station', name: 'CONTEXT_DESCRIPTION'});
await createAliasAsync(id + '.NEXT', dpPath + '.next', true, <iobJS.StateCommon>{ type: 'boolean', role: 'button.next', name: 'NEXT' }); await createAliasAsync(id + '.NEXT', dpPath + '.next', true, <iobJS.StateCommon> {type: 'boolean', role: 'button.next', name: 'NEXT'});
await createAliasAsync(id + '.PREV', dpPath + '.prev', true, <iobJS.StateCommon>{ type: 'boolean', role: 'button.prev', name: 'PREV' }); await createAliasAsync(id + '.PREV', dpPath + '.prev', true, <iobJS.StateCommon> {type: 'boolean', role: 'button.prev', name: 'PREV'});
await createAliasAsync(id + '.PLAY', dpPath + '.play', true, <iobJS.StateCommon>{ type: 'boolean', role: 'button.play', name: 'PLAY' }); await createAliasAsync(id + '.PLAY', dpPath + '.play', true, <iobJS.StateCommon> {type: 'boolean', role: 'button.play', name: 'PLAY'});
await createAliasAsync(id + '.PAUSE', dpPath + '.pause', true, <iobJS.StateCommon>{ type: 'boolean', role: 'button.pause', name: 'PAUSE' }); await createAliasAsync(id + '.PAUSE', dpPath + '.pause', true, <iobJS.StateCommon> {type: 'boolean', role: 'button.pause', name: 'PAUSE'});
await createAliasAsync(id + '.STOP', dpPath + '.stop', true, <iobJS.StateCommon>{ type: 'boolean', role: 'button.stop', name: 'STOP' }); await createAliasAsync(id + '.STOP', dpPath + '.stop', true, <iobJS.StateCommon> {type: 'boolean', role: 'button.stop', name: 'STOP'});
await createAliasAsync(id + '.STATE', dpPath + '.state_simple', true, <iobJS.StateCommon>{ type: 'boolean', role: 'media.state', name: 'STATE' }); await createAliasAsync(id + '.STATE', dpPath + '.state_simple', true, <iobJS.StateCommon> {type: 'boolean', role: 'media.state', name: 'STATE'});
await createAliasAsync(id + '.VOLUME', dpPath + '.volume', true, <iobJS.StateCommon>{ type: 'number', role: 'level.volume', name: 'VOLUME' }); await createAliasAsync(id + '.VOLUME', dpPath + '.volume', true, <iobJS.StateCommon> {type: 'number', role: 'level.volume', name: 'VOLUME'});
await createAliasAsync(id + '.REPEAT', dpPath + '.repeat', true, <iobJS.StateCommon>{ type: 'number', role: 'media.mode.repeat', name: 'REPEAT' }); await createAliasAsync(id + '.REPEAT', dpPath + '.repeat', true, <iobJS.StateCommon> {type: 'number', role: 'media.mode.repeat', name: 'REPEAT'});
await createAliasAsync(id + '.SHUFFLE', dpPath + '.shuffle', true, <iobJS.StateCommon>{ type: 'boolean', role: 'media.mode.shuffle', name: 'SHUFFLE' }); await createAliasAsync(id + '.SHUFFLE', dpPath + '.shuffle', true, <iobJS.StateCommon> {type: 'boolean', role: 'media.mode.shuffle', name: 'SHUFFLE'});
} catch (err: any) { } catch (err: any) {
log('error at function createAutoMediaAlias Adapter sonos: ' + err.message, 'warn'); log('error at function createAutoMediaAlias Adapter sonos: ' + err.message, 'warn');
} }
@@ -4794,63 +4795,168 @@ async function createAutoMediaAlias(id: string, mediaDevice: string, adapterPlay
//Add Sonos Datapoints > v4.3.3.15 //Add Sonos Datapoints > v4.3.3.15
if (existsObject(id + '.QUEUE') == false) { if (existsObject(id + '.QUEUE') == false) {
let dpPath: string = adapterPlayerInstance + 'root.' + mediaDevice; let dpPath: string = adapterPlayerInstance + 'root.' + mediaDevice;
await createAliasAsync(id + '.QUEUE', dpPath + '.queue', true, <iobJS.StateCommon>{ type: 'string', role: 'state', name: 'QUEUE' }); await createAliasAsync(id + '.QUEUE', dpPath + '.queue', true, <iobJS.StateCommon> {type: 'string', role: 'state', name: 'QUEUE'});
await createAliasAsync(id + '.DURATION', dpPath + '.current_duration_s', true, <iobJS.StateCommon>{ type: 'string', role: 'media.duration.text', name: 'DURATION' }); await createAliasAsync(id + '.DURATION', dpPath + '.current_duration_s', true, <iobJS.StateCommon> {type: 'string', role: 'media.duration.text', name: 'DURATION'});
await createAliasAsync(id + '.ELAPSED', dpPath + '.current_elapsed_s', true, <iobJS.StateCommon>{ type: 'string', role: 'media.elapsed.text', name: 'ELAPSED' }); await createAliasAsync(id + '.ELAPSED', dpPath + '.current_elapsed_s', true, <iobJS.StateCommon> {type: 'string', role: 'media.elapsed.text', name: 'ELAPSED'});
}
}
break;
case "spotify-premium.0.":
case "spotify-premium.1.":
case "spotify-premium.2.":
case "spotify-premium.3.":
case "spotify-premium.4.":
case "spotify-premium.5.":
case "spotify-premium.6.":
case "spotify-premium.7.":
case "spotify-premium.8.":
case "spotify-premium.9.": {
if (existsObject(id) == false) {
log('Spotify Alias ' + id + ' does not exist - will be created now', 'info');
const dpPath: string = adapterPlayerInstance;
try {
setObject(id, {_id: id + 'player', type: 'channel', common: {role: 'media', name: 'media'}, native: {}});
await createAliasAsync(id + '.ACTUAL', dpPath + 'player.volume', true, <iobJS.StateCommon> {type: 'number', role: 'value.volume', name: 'ACTUAL'});
await createAliasAsync(id + '.ALBUM', dpPath + 'player.album', true, <iobJS.StateCommon> {type: 'string', role: 'media.album', name: 'ALBUM'});
await createAliasAsync(id + '.ARTIST', dpPath + 'player.artistName', true, <iobJS.StateCommon> {type: 'string', role: 'media.artist', name: 'ARTIST'});
await createAliasAsync(id + '.TITLE', dpPath + 'player.trackName', true, <iobJS.StateCommon> {type: 'string', role: 'media.title', name: 'TITLE'});
await createAliasAsync(id + '.CONTEXT_DESCRIPTION', dpPath + 'player.contextDescription', true, <iobJS.StateCommon> {type: 'string', role: 'media.station', name: 'CONTEXT_DESCRIPTION'});
await createAliasAsync(id + '.NEXT', dpPath + 'player.skipPlus', true, <iobJS.StateCommon> {type: 'boolean', role: 'button.next', name: 'NEXT'});
await createAliasAsync(id + '.PREV', dpPath + 'player.skipMinus', true, <iobJS.StateCommon> {type: 'boolean', role: 'button.prev', name: 'PREV'});
await createAliasAsync(id + '.PLAY', dpPath + 'player.play', true, <iobJS.StateCommon> {type: 'boolean', role: 'button.play', name: 'PLAY'});
await createAliasAsync(id + '.PAUSE', dpPath + 'player.pause', true, <iobJS.StateCommon> {type: 'boolean', role: 'button.pause', name: 'PAUSE'});
await createAliasAsync(id + '.STOP', dpPath + 'player.pause', true, <iobJS.StateCommon> {type: 'boolean', role: 'button.stop', name: 'STOP'});
await createAliasAsync(id + '.STATE', dpPath + 'player.isPlaying', true, <iobJS.StateCommon> {type: 'boolean', role: 'media.state', name: 'STATE'});
await createAliasAsync(id + '.VOLUME', dpPath + 'player.volume', true, <iobJS.StateCommon> {type: 'number', role: 'level.volume', name: 'VOLUME'});
await createAliasAsync(id + '.REPEAT', dpPath + 'player.repeat', true, <iobJS.StateCommon> {type: 'string', role: 'value', name: 'REPEAT'});
await createAliasAsync(id + '.SHUFFLE', dpPath + 'player.shuffle', true, <iobJS.StateCommon> {type: 'string', role: 'value', name: 'SHUFFLE'});
} catch (err: any) {
log('error at function createAutoMediaAlias Adapter spotify-premium: ' + err.message, 'warn');
} }
} }
if (adapterPlayerInstance.startsWith('volumio')) { }
if (existsObject(id) == false){ break;
case "volumio.0.":
case "volumio.1.":
case "volumio.2.":
case "volumio.3.":
case "volumio.4.":
case "volumio.5.":
case "volumio.6.":
case "volumio.7.":
case "volumio.8.":
case "volumio.9.": {
if (existsObject(id) == false) {
log('Volumio Alias ' + id + ' does not exist - will be created now', 'info'); log('Volumio Alias ' + id + ' does not exist - will be created now', 'info');
let dpPath: string = adapterPlayerInstance; const dpPath: string = adapterPlayerInstance;
try { try {
setObject(id, {_id: id, type: 'channel', common: {role: 'media', name:'media'}, native: {}}); setObject(id, {_id: id, type: 'channel', common: {role: 'media', name: 'media'}, native: {}});
await createAliasAsync(id + '.ACTUAL', dpPath + 'playbackInfo.volume', true, <iobJS.StateCommon>{ type: 'number', role: 'value.volume', name: 'ACTUAL' }); await createAliasAsync(id + '.ACTUAL', dpPath + 'playbackInfo.volume', true, <iobJS.StateCommon> {type: 'number', role: 'value.volume', name: 'ACTUAL'});
await createAliasAsync(id + '.ALBUM', dpPath + 'playbackInfo.album', true, <iobJS.StateCommon>{ type: 'string', role: 'media.album', name: 'ALBUM' }); await createAliasAsync(id + '.ALBUM', dpPath + 'playbackInfo.album', true, <iobJS.StateCommon> {type: 'string', role: 'media.album', name: 'ALBUM'});
await createAliasAsync(id + '.ARTIST', dpPath + 'playbackInfo.artist', true, <iobJS.StateCommon>{ type: 'string', role: 'media.artist', name: 'ARTIST' }); await createAliasAsync(id + '.ARTIST', dpPath + 'playbackInfo.artist', true, <iobJS.StateCommon> {type: 'string', role: 'media.artist', name: 'ARTIST'});
await createAliasAsync(id + '.TITLE', dpPath + 'playbackInfo.title', true, <iobJS.StateCommon>{ type: 'string', role: 'media.title', name: 'TITLE' }); await createAliasAsync(id + '.TITLE', dpPath + 'playbackInfo.title', true, <iobJS.StateCommon> {type: 'string', role: 'media.title', name: 'TITLE'});
await createAliasAsync(id + '.NEXT', dpPath + 'player.next', true, <iobJS.StateCommon>{ type: 'boolean', role: 'button.next', name: 'NEXT' }); await createAliasAsync(id + '.NEXT', dpPath + 'player.next', true, <iobJS.StateCommon> {type: 'boolean', role: 'button.next', name: 'NEXT'});
await createAliasAsync(id + '.PREV', dpPath + 'player.prev', true, <iobJS.StateCommon>{ type: 'boolean', role: 'button.prev', name: 'PREV' }); await createAliasAsync(id + '.PREV', dpPath + 'player.prev', true, <iobJS.StateCommon> {type: 'boolean', role: 'button.prev', name: 'PREV'});
await createAliasAsync(id + '.PLAY', dpPath + 'player.play', true, <iobJS.StateCommon>{ type: 'boolean', role: 'button.play', name: 'PLAY' }); await createAliasAsync(id + '.PLAY', dpPath + 'player.play', true, <iobJS.StateCommon> {type: 'boolean', role: 'button.play', name: 'PLAY'});
await createAliasAsync(id + '.PAUSE', dpPath + 'player.toggle', true, <iobJS.StateCommon>{ type: 'boolean', role: 'button.pause', name: 'PAUSE' }); await createAliasAsync(id + '.PAUSE', dpPath + 'player.toggle', true, <iobJS.StateCommon> {type: 'boolean', role: 'button.pause', name: 'PAUSE'});
await createAliasAsync(id + '.STOP', dpPath + 'player.stop', true, <iobJS.StateCommon>{ type: 'boolean', role: 'button.stop', name: 'STOP' }); await createAliasAsync(id + '.STOP', dpPath + 'player.stop', true, <iobJS.StateCommon> {type: 'boolean', role: 'button.stop', name: 'STOP'});
await createAliasAsync(id + '.STATE', dpPath + 'playbackInfo.status', true, <iobJS.StateCommon>{ type: 'boolean', role: 'media.state', name: 'STATE' }); await createAliasAsync(id + '.STATE', dpPath + 'playbackInfo.status', true, <iobJS.StateCommon> {type: 'boolean', role: 'media.state', name: 'STATE'});
await createAliasAsync(id + '.VOLUME', dpPath + 'playbackInfo.volume', true, <iobJS.StateCommon>{ type: 'number', role: 'level.volume', name: 'VOLUME' }); await createAliasAsync(id + '.VOLUME', dpPath + 'playbackInfo.volume', true, <iobJS.StateCommon> {type: 'number', role: 'level.volume', name: 'VOLUME'});
await createAliasAsync(id + '.REPEAT', dpPath + 'playbackInfo.repeat', true, <iobJS.StateCommon>{ type: 'number', role: 'media.mode.repeat', name: 'REPEAT' }); await createAliasAsync(id + '.REPEAT', dpPath + 'playbackInfo.repeat', true, <iobJS.StateCommon> {type: 'number', role: 'media.mode.repeat', name: 'REPEAT'});
await createAliasAsync(id + '.SHUFFLE', dpPath + 'queue.shuffle', true, <iobJS.StateCommon>{ type: 'boolean', role: 'media.mode.shuffle', name: 'SHUFFLE' }); await createAliasAsync(id + '.SHUFFLE', dpPath + 'queue.shuffle', true, <iobJS.StateCommon> {type: 'boolean', role: 'media.mode.shuffle', name: 'SHUFFLE'});
await createAliasAsync(id + '.status', dpPath + 'playbackInfo.status', true, <iobJS.StateCommon>{ type: 'string', role: 'media.state', name: 'status' }); await createAliasAsync(id + '.status', dpPath + 'playbackInfo.status', true, <iobJS.StateCommon> {type: 'string', role: 'media.state', name: 'status'});
} catch (err: any) { } catch (err: any) {
log('error function createAutoMediaAlias Adapter volumio: ' + err.message, 'warn'); log('error function createAutoMediaAlias Adapter volumio: ' + err.message, 'warn');
} }
} }
}
if (adapterPlayerInstance.startsWith('squeezeboxrpc')) { }
if (existsObject(id) == false){ break;
case "squeezeboxrpc.0.":
case "squeezeboxrpc.1.":
case "squeezeboxrpc.2.":
case "squeezeboxrpc.3.":
case "squeezeboxrpc.4.":
case "squeezeboxrpc.5.":
case "squeezeboxrpc.6.":
case "squeezeboxrpc.7.":
case "squeezeboxrpc.8.":
case "squeezeboxrpc.9.": {
if (existsObject(id) == false) {
log('Squeezebox Alias ' + id + ' does not exist - will be created now', 'info'); log('Squeezebox Alias ' + id + ' does not exist - will be created now', 'info');
let dpPath: string = adapterPlayerInstance + '.Players.' + mediaDevice; const dpPath: string = adapterPlayerInstance + 'Players.' + mediaDevice;
try { try {
setObject(id, {_id: id, type: 'channel', common: {role: 'media', name:'media'}, native: {}}); setObject(id, {_id: id, type: 'channel', common: {role: 'media', name: 'media'}, native: {}});
await createAliasAsync(id + '.ALBUM', dpPath + '.Album', true, <iobJS.StateCommon>{ type: 'string', role: 'media.album', name: 'ALBUM'}); await createAliasAsync(id + '.ALBUM', dpPath + '.Album', true, <iobJS.StateCommon> {type: 'string', role: 'media.album', name: 'ALBUM'});
await createAliasAsync(id + '.ARTIST', dpPath + '.Artist', true, <iobJS.StateCommon>{ type: 'string', role: 'media.artist', name: 'ARTIST'}); await createAliasAsync(id + '.ARTIST', dpPath + '.Artist', true, <iobJS.StateCommon> {type: 'string', role: 'media.artist', name: 'ARTIST'});
await createAliasAsync(id + '.TITLE', dpPath + '.Title', true, <iobJS.StateCommon>{ type: 'string', role: 'media.title', name: 'TITLE'}); await createAliasAsync(id + '.TITLE', dpPath + '.Title', true, <iobJS.StateCommon> {type: 'string', role: 'media.title', name: 'TITLE'});
await createAliasAsync(id + '.NEXT', dpPath + '.btnForward', true, <iobJS.StateCommon>{ type: 'boolean', role: 'button.forward', name: 'NEXT'}); await createAliasAsync(id + '.NEXT', dpPath + '.btnForward', true, <iobJS.StateCommon> {type: 'boolean', role: 'button.forward', name: 'NEXT'});
await createAliasAsync(id + '.PREV', dpPath + '.btnRewind', true, <iobJS.StateCommon>{ type: 'boolean', role: 'button.reverse', name: 'PREV'}); await createAliasAsync(id + '.PREV', dpPath + '.btnRewind', true, <iobJS.StateCommon> {type: 'boolean', role: 'button.reverse', name: 'PREV'});
await createAliasAsync(id + '.PLAY', dpPath + '.state', true, <iobJS.StateCommon>{ type: 'boolean', role: 'media.state', name: 'PLAY', alias: { id: dpPath + '.state', read: 'val === 1 ? true : false' }}); await createAliasAsync(id + '.PLAY', dpPath + '.state', true, <iobJS.StateCommon> {type: 'boolean', role: 'media.state', name: 'PLAY', alias: {id: dpPath + '.state', read: 'val === 1 ? true : false'}});
await createAliasAsync(id + '.PAUSE', dpPath + '.state', true, <iobJS.StateCommon>{ type: 'boolean', role: 'media.state', name: 'PAUSE', alias: { id: dpPath + '.state', read: 'val === 0 ? true : false'}}); await createAliasAsync(id + '.PAUSE', dpPath + '.state', true, <iobJS.StateCommon> {type: 'boolean', role: 'media.state', name: 'PAUSE', alias: {id: dpPath + '.state', read: 'val === 0 ? true : false'}});
await createAliasAsync(id + '.STOP', dpPath + '.state', true, <iobJS.StateCommon>{ type: 'boolean', role: 'media.state', name: 'STOP', alias: { id: dpPath + '.state', read: 'val === 0 ? true : false'}}); await createAliasAsync(id + '.STOP', dpPath + '.state', true, <iobJS.StateCommon> {type: 'boolean', role: 'media.state', name: 'STOP', alias: {id: dpPath + '.state', read: 'val === 0 ? true : false'}});
await createAliasAsync(id + '.STATE', dpPath + '.Power', true, <iobJS.StateCommon>{ type: 'number', role: 'switch', name: 'STATE'}); await createAliasAsync(id + '.STATE', dpPath + '.Power', true, <iobJS.StateCommon> {type: 'number', role: 'switch', name: 'STATE'});
await createAliasAsync(id + '.VOLUME', dpPath + '.Volume', true, <iobJS.StateCommon>{ type: 'number', role: 'level.volume', name: 'VOLUME'}); await createAliasAsync(id + '.VOLUME', dpPath + '.Volume', true, <iobJS.StateCommon> {type: 'number', role: 'level.volume', name: 'VOLUME'});
await createAliasAsync(id + '.VOLUME_ACTUAL', dpPath + '.Volume', true, <iobJS.StateCommon>{ type: 'number', role: 'value.volume', name: 'VOLUME_ACTUAL'}); await createAliasAsync(id + '.VOLUME_ACTUAL', dpPath + '.Volume', true, <iobJS.StateCommon> {type: 'number', role: 'value.volume', name: 'VOLUME_ACTUAL'});
await createAliasAsync(id + '.SHUFFLE', dpPath + '.PlaylistShuffle', true, <iobJS.StateCommon>{ type: 'string', role: 'media.mode.shuffle', name: 'SHUFFLE', alias: { id: dpPath + '.PlaylistShuffle', read: 'val !== 0 ? \'on\' : \'off\'', write: 'val === \'off\' ? 0 : 1' }}); await createAliasAsync(id + '.SHUFFLE', dpPath + '.PlaylistShuffle', true, <iobJS.StateCommon> {type: 'string', role: 'media.mode.shuffle', name: 'SHUFFLE', alias: {id: dpPath + '.PlaylistShuffle', read: 'val !== 0 ? \'on\' : \'off\'', write: 'val === \'off\' ? 0 : 1'}});
await createAliasAsync(id + '.REPEAT', dpPath + '.PlaylistRepeat', true, <iobJS.StateCommon>{type: 'number', role: 'media.mode.repeat', name: 'REPEAT'}); await createAliasAsync(id + '.REPEAT', dpPath + '.PlaylistRepeat', true, <iobJS.StateCommon> {type: 'number', role: 'media.mode.repeat', name: 'REPEAT'});
} catch (err: any) { } catch (err: any) {
log('error at function createAutoMediaAlias Adapter Squeezebox: ' + err.message, 'warn'); log('error at function createAutoMediaAlias Adapter Squeezebox: ' + err.message, 'warn');
} }
} }
}
break;
case "bosesoundtouch.0.":
case "bosesoundtouch.1.":
case "bosesoundtouch.2.":
case "bosesoundtouch.3.":
case "bosesoundtouch.4.":
case "bosesoundtouch.5.":
case "bosesoundtouch.6.":
case "bosesoundtouch.7.":
case "bosesoundtouch.8.":
case "bosesoundtouch.9.": {
if (existsObject(id) == false) {
log('bosesoundtouch Alias ' + id + ' does not exist - will be created now', 'info');
try {
let dpPath: string = adapterPlayerInstance + 'keys';
await extendObjectAsync(id, {_id: id, type: 'channel', common: {role: 'media', name: 'media'}, native: {}});
await createAliasAsync(id + '.ACTUAL', dpPath + '.volume', true, <iobJS.StateCommon> {type: 'number', role: 'value.volume', name: 'ACTUAL'});
await createAliasAsync(id + '.VOLUME', dpPath + '.volume', true, <iobJS.StateCommon> {type: 'number', role: 'level.volume', name: 'VOLUME'});
dpPath = adapterPlayerInstance + 'nowPlaying';
await createAliasAsync(id + '.ALBUM', dpPath + '.album', true, <iobJS.StateCommon> {type: 'string', role: 'media.album', name: 'ALBUM'});
await createAliasAsync(id + '.ARTIST', dpPath + '.artist', true, <iobJS.StateCommon> {type: 'string', role: 'media.artist', name: 'ARTIST'});
await createAliasAsync(id + '.TITLE', dpPath + '.track', true, <iobJS.StateCommon> {type: 'string', role: 'media.title', name: 'TITLE'});
await createAliasAsync(id + '.DURATION', dpPath + '.total', true, <iobJS.StateCommon> {type: 'string', role: 'media.duration.text', name: 'DURATION'});
await createAliasAsync(id + '.ELAPSED', dpPath + '.time', true, <iobJS.StateCommon> {type: 'string', role: 'media.elapsed.text', name: 'ELAPSED'});
await createAliasAsync(id + '.REPEAT', dpPath + '.repeat', true, <iobJS.StateCommon> {type: 'boolean', role: 'media.mode.repeat', name: 'REPEAT'});
await createAliasAsync(id + '.SHUFFLE', dpPath + '.shuffle', true, <iobJS.StateCommon> {type: 'boolean', role: 'media.mode.shuffle', name: 'SHUFFLE'});
dpPath = adapterPlayerInstance + 'keys';
await createAliasAsync(id + '.STATE', dpPath + '.POWER', true, <iobJS.StateCommon> {type: 'boolean', role: 'media.state', name: 'STATE'});
await createAliasAsync(id + '.NEXT', dpPath + '.NEXT_TRACK', true, <iobJS.StateCommon> {type: 'boolean', role: 'button.next', name: 'NEXT'});
await createAliasAsync(id + '.PREV', dpPath + '.PREV_TRACK', true, <iobJS.StateCommon> {type: 'boolean', role: 'button.prev', name: 'PREV'});
await createAliasAsync(id + '.PLAY', dpPath + '.PLAY', true, <iobJS.StateCommon> {type: 'boolean', role: 'button.play', name: 'PLAY'});
await createAliasAsync(id + '.PAUSE', dpPath + '.PAUSE', true, <iobJS.StateCommon> {type: 'boolean', role: 'button.pause', name: 'PAUSE'});
await createAliasAsync(id + '.STOP', dpPath + '.STOP', true, <iobJS.StateCommon> {type: 'boolean', role: 'button.stop', name: 'STOP'});
} catch (err: any) {
log('error at function createAutoMediaAlias Adapter bosesoundtouch: ' + err.message, 'warn');
}
}
break;
}
default: {
log(`Dont find adapterPlayerInstance: ${adapterPlayerInstance}!`, 'warn')
}
} }
} }
} }
@@ -4868,7 +4974,7 @@ function GenerateMediaPage(page: PageMedia): Payload[] {
if (!page.items[0].adapterPlayerInstance!) throw new Error('page.items[0].adapterPlayerInstance is undefined!') if (!page.items[0].adapterPlayerInstance!) throw new Error('page.items[0].adapterPlayerInstance is undefined!')
let vInstance = page.items[0].adapterPlayerInstance!; let vInstance = page.items[0].adapterPlayerInstance!;
let v1Adapter = vInstance.split('.'); let v1Adapter = vInstance.split('.');
let v2Adapter = v1Adapter[0]; let v2Adapter:PlayerType = v1Adapter[0] as PlayerType;
// Some magic to change the ID of the alias, since speakers are not a property but separate objects // Some magic to change the ID of the alias, since speakers are not a property but separate objects
if(v2Adapter == 'squeezeboxrpc') { if(v2Adapter == 'squeezeboxrpc') {
@@ -4887,10 +4993,9 @@ function GenerateMediaPage(page: PageMedia): Payload[] {
} }
} }
if (page.items[0].autoCreateALias) {
let vMediaDevice = (page.items[0].mediaDevice != undefined) ? page.items[0].mediaDevice : ''; let vMediaDevice = (page.items[0].mediaDevice != undefined) ? page.items[0].mediaDevice : '';
if (!vMediaDevice) throw new Error(`Error in cardMedia! mediaDevice is empty! Page: ${JSON.stringify(page)}`);
createAutoMediaAlias(id, vMediaDevice, page.items[0].adapterPlayerInstance!); createAutoMediaAlias(id, vMediaDevice, page.items[0].adapterPlayerInstance!);
}
// Leave the display on if the alwaysOnDisplay parameter is specified (true) // Leave the display on if the alwaysOnDisplay parameter is specified (true)
if (page.type == 'cardMedia' && pageCounter == 0 && page.items[0].alwaysOnDisplay != undefined) { if (page.type == 'cardMedia' && pageCounter == 0 && page.items[0].alwaysOnDisplay != undefined) {
@@ -6253,14 +6358,20 @@ function HandleButtonEvent(words: any): void {
case 'hue': case 'hue':
toggleState(id + '.ON_ACTUAL'); toggleState(id + '.ON_ACTUAL');
case 'media': case 'media':
if (!activePage || activePage.type != 'cardMedia') {
if (activePage) throw new Error(`Found channel role media for card: ${activePage.type} not allowed`)
else throw new Error(`Something went wrong! Active Page is empty!`);
}
if (tempid[1] == undefined) { if (tempid[1] == undefined) {
if (Debug) log('Logo click', 'info'); if (Debug) log('Logo click', 'info');
GeneratePage(activePage!); GeneratePage(activePage!);
} else if (tempid[1] == 'repeat') { } else if (tempid[1] == 'repeat') {
let pageItemRepeat = findPageItem(id); let pageItemRepeat = findPageItem(id);
let adapterInstanceRepeat = pageItemRepeat.adapterPlayerInstance!; if (isPageMediaItem(pageItemRepeat)) {
let adapterInstanceRepeat = pageItemRepeat.adapterPlayerInstance;
let adapterRepeat = adapterInstanceRepeat.split('.'); let adapterRepeat = adapterInstanceRepeat.split('.');
let deviceAdapterRP = adapterRepeat[0]; const deviceAdapterRP: PlayerType = adapterRepeat[0] as PlayerType;
switch (deviceAdapterRP) { switch (deviceAdapterRP) {
case 'spotify-premium': case 'spotify-premium':
@@ -6294,8 +6405,8 @@ function HandleButtonEvent(words: any): void {
GeneratePage(activePage!); GeneratePage(activePage!);
break; break;
case 'volumio': case 'volumio':
let urlString: string = `${getState(adapterInstanceRepeat+'info.host').val}/api/commands/?cmd=repeat`; let urlString: string = `${getState(adapterInstanceRepeat + 'info.host').val}/api/commands/?cmd=repeat`;
axios.get(urlString, { headers: { 'User-Agent': 'ioBroker' } }) axios.get(urlString, {headers: {'User-Agent': 'ioBroker'}})
.then(async function (response) { .then(async function (response) {
if (response.status === 200) { if (response.status === 200) {
if (Debug) { if (Debug) {
@@ -6312,7 +6423,7 @@ function HandleButtonEvent(words: any): void {
break; break;
case 'squeezeboxrpc': case 'squeezeboxrpc':
try { try {
switch(getState(id + '.REPEAT').val) { switch (getState(id + '.REPEAT').val) {
case 0: case 0:
setIfExists(id + '.REPEAT', 1); setIfExists(id + '.REPEAT', 1);
GeneratePage(activePage!); GeneratePage(activePage!);
@@ -6334,6 +6445,7 @@ function HandleButtonEvent(words: any): void {
} }
} }
} }
}
break; break;
case 'up': case 'up':
setIfExists(id + '.OPEN', true); setIfExists(id + '.OPEN', true);
@@ -6478,6 +6590,7 @@ function HandleButtonEvent(words: any): void {
break; break;
case 'media-pause': case 'media-pause':
let pageItemTemp = findPageItem(id); let pageItemTemp = findPageItem(id);
if (isPageMediaItem(pageItemTemp)) {
let adaInstanceSplit = pageItemTemp.adapterPlayerInstance!.split('.'); let adaInstanceSplit = pageItemTemp.adapterPlayerInstance!.split('.');
if (adaInstanceSplit[0] == 'squeezeboxrpc') { if (adaInstanceSplit[0] == 'squeezeboxrpc') {
let adapterPlayerInstanceStateSeceltor: string = [pageItemTemp.adapterPlayerInstance, 'Players', pageItemTemp.mediaDevice, 'state'].join('.'); let adapterPlayerInstanceStateSeceltor: string = [pageItemTemp.adapterPlayerInstance, 'Players', pageItemTemp.mediaDevice, 'state'].join('.');
@@ -6499,30 +6612,33 @@ function HandleButtonEvent(words: any): void {
} }
} }
GeneratePage(activePage!); GeneratePage(activePage!);
}
break; break;
case 'media-next': case 'media-next':
setIfExists(id + '.NEXT', true); setIfExists(id + '.NEXT', true);
GeneratePage(activePage!); GeneratePage(activePage!);
break; break;
case 'media-shuffle': case 'media-shuffle':
if ((findPageItem(id).adapterPlayerInstance!).startsWith("volumio")) { const tempPage = findPageItem(id);
if (isPageMediaItem(tempPage)) {
if (tempPage.adapterPlayerInstance.startsWith("volumio")) {
findPageItem(id).playList = []; break; findPageItem(id).playList = []; break;
} //Volumio: empty playlist $uha-20230103 } //Volumio: empty playlist $uha-20230103
if ((findPageItem(id).adapterPlayerInstance!).startsWith("spotify")) { if ((tempPage.adapterPlayerInstance).startsWith("spotify")) {
if (getState(id + '.SHUFFLE').val == 'off') { if (getState(id + '.SHUFFLE').val == 'off') {
setIfExists(id + '.SHUFFLE', 'on'); setIfExists(id + '.SHUFFLE', 'on');
} else { } else {
setIfExists(id + '.SHUFFLE', 'off'); setIfExists(id + '.SHUFFLE', 'off');
} }
} }
if ((findPageItem(id).adapterPlayerInstance!).startsWith("alexa")) { if ((tempPage.adapterPlayerInstance).startsWith("alexa")) {
if (getState(id + '.SHUFFLE').val == false) { if (getState(id + '.SHUFFLE').val == false) {
setIfExists(id + '.SHUFFLE', true); setIfExists(id + '.SHUFFLE', true);
} else { } else {
setIfExists(id + '.SHUFFLE', false); setIfExists(id + '.SHUFFLE', false);
} }
} }
if ((findPageItem(id).adapterPlayerInstance!).startsWith("sonos")) { if ((tempPage.adapterPlayerInstance).startsWith("sonos")) {
if (getState(id + '.SHUFFLE').val == false) { if (getState(id + '.SHUFFLE').val == false) {
setIfExists(id + '.SHUFFLE', true); setIfExists(id + '.SHUFFLE', true);
} else { } else {
@@ -6530,6 +6646,7 @@ function HandleButtonEvent(words: any): void {
} }
} }
GeneratePage(activePage!); GeneratePage(activePage!);
}
break; break;
case 'volumeSlider': case 'volumeSlider':
pageCounter = -1; pageCounter = -1;
@@ -6544,9 +6661,10 @@ function HandleButtonEvent(words: any): void {
break; break;
case 'mode-speakerlist': case 'mode-speakerlist':
let pageItem = findPageItem(id); let pageItem = findPageItem(id);
if (isPageMediaItem(pageItem)) {
let adapterInstance = pageItem.adapterPlayerInstance!; let adapterInstance = pageItem.adapterPlayerInstance!;
let adapter = adapterInstance!.split('.'); let adapter = adapterInstance!.split('.');
let deviceAdapter = adapter[0]; const deviceAdapter: PlayerType = adapter[0] as PlayerType;
switch (deviceAdapter) { switch (deviceAdapter) {
case 'spotify-premium': case 'spotify-premium':
@@ -6569,11 +6687,15 @@ function HandleButtonEvent(words: any): void {
break; break;
case 'sonos': case 'sonos':
break; break;
case 'chromecast': /*case 'chromecast':
break; break;*/
case 'squeezeboxrpc': case 'squeezeboxrpc':
pageItem.mediaDevice = pageItem.speakerList![words[4]]; pageItem.mediaDevice = pageItem.speakerList![words[4]];
break; break;
case "volumio":
break;
case "bosesoundtouch":
break;
} }
pageCounter = 0; pageCounter = 0;
GeneratePage(activePage!); GeneratePage(activePage!);
@@ -6581,12 +6703,14 @@ function HandleButtonEvent(words: any): void {
pageCounter = 1; pageCounter = 1;
GeneratePage(activePage!); GeneratePage(activePage!);
}, 3000); }, 3000);
}
break; break;
case 'mode-playlist': case 'mode-playlist':
let pageItemPL = findPageItem(id); let pageItemPL = findPageItem(id);
if (!isPageMediaItem(pageItemPL)) break;
let adapterInstancePL = pageItemPL.adapterPlayerInstance!; let adapterInstancePL = pageItemPL.adapterPlayerInstance!;
let adapterPL = adapterInstancePL.split('.'); let adapterPL = adapterInstancePL.split('.');
let deviceAdapterPL = adapterPL[0]; const deviceAdapterPL: PlayerType = adapterPL[0] as PlayerType;
switch (deviceAdapterPL) { switch (deviceAdapterPL) {
case 'spotify-premium': case 'spotify-premium':
@@ -6629,6 +6753,10 @@ function HandleButtonEvent(words: any): void {
case 'squeezeboxrpc': case 'squeezeboxrpc':
setState([pageItemPL.adapterPlayerInstance, 'Players', pageItemPL.mediaDevice, 'cmdPlayFavorite'].join('.'), words[4]); setState([pageItemPL.adapterPlayerInstance, 'Players', pageItemPL.mediaDevice, 'cmdPlayFavorite'].join('.'), words[4]);
break; break;
case "bosesoundtouch":
break;
default:
log('Hello Mr. Developer u miss in mode-playlist something!', 'warn')
} }
pageCounter = 0; pageCounter = 0;
GeneratePage(activePage!); GeneratePage(activePage!);
@@ -6639,9 +6767,10 @@ function HandleButtonEvent(words: any): void {
break; break;
case 'mode-tracklist': case 'mode-tracklist':
let pageItemTL = findPageItem(id); let pageItemTL = findPageItem(id);
if (!isPageMediaItem(pageItemTL)) break;
let adapterInstanceTL = pageItemTL.adapterPlayerInstance!; let adapterInstanceTL = pageItemTL.adapterPlayerInstance!;
let adapterTL = adapterInstanceTL.split('.'); let adapterTL = adapterInstanceTL.split('.');
let deviceAdapterTL = adapterTL[0]; const deviceAdapterTL: PlayerType = adapterTL[0] as PlayerType;
switch (deviceAdapterTL) { switch (deviceAdapterTL) {
case 'spotify-premium': case 'spotify-premium':
@@ -6673,6 +6802,10 @@ function HandleButtonEvent(words: any): void {
//@ts-ignore Fehler kommt von findPageItem in vscode //@ts-ignore Fehler kommt von findPageItem in vscode
setState([pageItemPL.adapterPlayerInstance, 'Players', pageItemPL.mediaDevice, 'PlaylistCurrentIndex'].join('.'), words[4]); setState([pageItemPL.adapterPlayerInstance, 'Players', pageItemPL.mediaDevice, 'PlaylistCurrentIndex'].join('.'), words[4]);
break; break;
case "bosesoundtouch":
break;
default:
log('Hello Mr. Developer u miss in mode-tracklist something!', 'warn')
} }
pageCounter = 0; pageCounter = 0;
GeneratePage(activePage!); GeneratePage(activePage!);
@@ -6683,6 +6816,7 @@ function HandleButtonEvent(words: any): void {
break; break;
case 'mode-repeat': case 'mode-repeat':
let pageItemRP = findPageItem(id); let pageItemRP = findPageItem(id);
if (!isPageMediaItem(pageItemRP)) break;
let adapterInstanceRP = pageItemRP.adapterPlayerInstance!; let adapterInstanceRP = pageItemRP.adapterPlayerInstance!;
let adapterRP = adapterInstanceRP.split('.'); let adapterRP = adapterInstanceRP.split('.');
let deviceAdapterRP = adapterRP[0]; let deviceAdapterRP = adapterRP[0];
@@ -6712,6 +6846,7 @@ function HandleButtonEvent(words: any): void {
break; break;
case 'mode-seek': case 'mode-seek':
let pageItemSeek = findPageItem(id); let pageItemSeek = findPageItem(id);
if (!isPageMediaItem(pageItemSeek)) break;
let adapterInstanceSK = pageItemSeek.adapterPlayerInstance!; let adapterInstanceSK = pageItemSeek.adapterPlayerInstance!;
let adapterSK = adapterInstanceSK.split('.'); let adapterSK = adapterInstanceSK.split('.');
let deviceAdapterSK = adapterSK[0]; let deviceAdapterSK = adapterSK[0];
@@ -6732,6 +6867,7 @@ function HandleButtonEvent(words: any): void {
break; break;
case 'mode-crossfade': case 'mode-crossfade':
let pageItemCrossfade = findPageItem(id); let pageItemCrossfade = findPageItem(id);
if (!isPageMediaItem(pageItemCrossfade)) break;
let adapterInstanceCF = pageItemCrossfade.adapterPlayerInstance!; let adapterInstanceCF = pageItemCrossfade.adapterPlayerInstance!;
let adapterCF = adapterInstanceCF.split('.'); let adapterCF = adapterInstanceCF.split('.');
let deviceAdapterCF = adapterCF[0]; let deviceAdapterCF = adapterCF[0];
@@ -6756,6 +6892,7 @@ function HandleButtonEvent(words: any): void {
break; break;
case 'mode-favorites': case 'mode-favorites':
let pageItemFav = findPageItem(id); let pageItemFav = findPageItem(id);
if (!isPageMediaItem(pageItemFav)) break;
if (Debug) log(getState(pageItemFav.adapterPlayerInstance + 'root.' + pageItemFav.mediaDevice + '.favorites_set').val, 'info'); if (Debug) log(getState(pageItemFav.adapterPlayerInstance + 'root.' + pageItemFav.mediaDevice + '.favorites_set').val, 'info');
let favListArray = getState(pageItemFav.adapterPlayerInstance + 'root.' + pageItemFav.mediaDevice + '.favorites_list_array').val; let favListArray = getState(pageItemFav.adapterPlayerInstance + 'root.' + pageItemFav.mediaDevice + '.favorites_list_array').val;
setState(pageItemFav.adapterPlayerInstance + 'root.' + pageItemFav.mediaDevice + '.favorites_set', favListArray[words[4]]); setState(pageItemFav.adapterPlayerInstance + 'root.' + pageItemFav.mediaDevice + '.favorites_set', favListArray[words[4]]);
@@ -6771,7 +6908,8 @@ function HandleButtonEvent(words: any): void {
break; break;
case 'media-OnOff': case 'media-OnOff':
let pageItemTem = findPageItem(id); let pageItemTem = findPageItem(id);
let adaInstanceSpli = pageItemTem.adapterPlayerInstance!.split('.'); if (!isPageMediaItem(pageItemTem)) break;
let adaInstanceSpli = pageItemTem.adapterPlayerInstance.split('.');
if (adaInstanceSpli[0] == 'squeezeboxrpc') { if (adaInstanceSpli[0] == 'squeezeboxrpc') {
let adapterPlayerInstancePowerSelector: string = [pageItemTem.adapterPlayerInstance, 'Players', pageItemTem.mediaDevice, 'Power'].join('.'); let adapterPlayerInstancePowerSelector: string = [pageItemTem.adapterPlayerInstance, 'Players', pageItemTem.mediaDevice, 'Power'].join('.');
let stateVal = getState(adapterPlayerInstancePowerSelector).val; let stateVal = getState(adapterPlayerInstancePowerSelector).val;
@@ -7089,7 +7227,7 @@ function GetNavigationString(pageId: number): string {
return ''; return '';
} }
function GenerateDetailPage(type: string, optional: string | undefined, pageItem: PageItem, placeId: number | undefined): Payload[] { function GenerateDetailPage(type: string, optional: mediaOptional | undefined, pageItem: PageItem, placeId: number | undefined): Payload[] {
if (Debug) log('GenerateDetailPage Übergabe Type: ' + type + ' - optional: ' + optional + ' - pageItem.id: ' + pageItem.id, 'info'); if (Debug) log('GenerateDetailPage Übergabe Type: ' + type + ' - optional: ' + optional + ' - pageItem.id: ' + pageItem.id, 'info');
try { try {
let out_msgs: Array<Payload> = []; let out_msgs: Array<Payload> = [];
@@ -7106,7 +7244,9 @@ function GenerateDetailPage(type: string, optional: string | undefined, pageItem
let switchVal = '0'; let switchVal = '0';
let brightness = 0; let brightness = 0;
if (o.common.role == 'light' || o.common.role == 'socket') { switch (o.common.role) {
case 'light':
case 'socket': {
if (existsState(id + '.GET')) { if (existsState(id + '.GET')) {
val = getState(id + '.GET').val; val = getState(id + '.GET').val;
RegisterDetailEntityWatcher(id + '.GET', pageItem, type, placeId); RegisterDetailEntityWatcher(id + '.GET', pageItem, type, placeId);
@@ -7152,9 +7292,9 @@ function GenerateDetailPage(type: string, optional: string | undefined, pageItem
+ effect_supported + effect_supported
}); });
} }
break;
// Dimmer // Dimmer
if (o.common.role == 'dimmer') { case 'dimmer': {
if (existsState(id + '.ON_ACTUAL')) { if (existsState(id + '.ON_ACTUAL')) {
val = getState(id + '.ON_ACTUAL').val; val = getState(id + '.ON_ACTUAL').val;
RegisterDetailEntityWatcher(id + '.ON_ACTUAL', pageItem, type, placeId); RegisterDetailEntityWatcher(id + '.ON_ACTUAL', pageItem, type, placeId);
@@ -7209,9 +7349,9 @@ function GenerateDetailPage(type: string, optional: string | undefined, pageItem
+ effect_supported + effect_supported
}); });
} }
break;
// HUE-Licht // HUE-Licht
if (o.common.role == 'hue') { case 'hue': {
if (existsState(id + '.ON_ACTUAL')) { if (existsState(id + '.ON_ACTUAL')) {
val = getState(id + '.ON_ACTUAL').val; val = getState(id + '.ON_ACTUAL').val;
@@ -7281,9 +7421,9 @@ function GenerateDetailPage(type: string, optional: string | undefined, pageItem
+ effect_supported + effect_supported
}); });
} }
break;
// RGB-Licht // RGB-Licht
if (o.common.role == 'rgb') { case 'rgb': {
if (existsState(id + '.ON_ACTUAL')) { if (existsState(id + '.ON_ACTUAL')) {
val = getState(id + '.ON_ACTUAL').val; val = getState(id + '.ON_ACTUAL').val;
@@ -7352,9 +7492,9 @@ function GenerateDetailPage(type: string, optional: string | undefined, pageItem
+ effect_supported + effect_supported
}); });
} }
break;
// RGB-Licht-einzeln (HEX) // RGB-Licht-einzeln (HEX)
if (o.common.role == 'rgbSingle') { case 'rgbSingle': {
if (existsState(id + '.ON_ACTUAL')) { if (existsState(id + '.ON_ACTUAL')) {
val = getState(id + '.ON_ACTUAL').val; val = getState(id + '.ON_ACTUAL').val;
@@ -7428,9 +7568,9 @@ function GenerateDetailPage(type: string, optional: string | undefined, pageItem
+ effect_supported + effect_supported
}); });
} }
break;
// Farbtemperatur (CT) // Farbtemperatur (CT)
if (o.common.role == 'ct') { case 'ct': {
if (existsState(id + '.ON')) { if (existsState(id + '.ON')) {
val = getState(id + '.ON').val; val = getState(id + '.ON').val;
@@ -7492,6 +7632,8 @@ function GenerateDetailPage(type: string, optional: string | undefined, pageItem
+ effect_supported + effect_supported
}); });
} }
break;
}
} }
if (type == 'popupShutter') { if (type == 'popupShutter') {
@@ -7774,9 +7916,9 @@ function GenerateDetailPage(type: string, optional: string | undefined, pageItem
let actualState: any = ''; let actualState: any = '';
let optionalString: string = 'Kein Eintrag'; let optionalString: string = 'Kein Eintrag';
let mode: string = ''; let mode: string = '';
if (isPageMediaItem(pageItem)) {
let vTempAdapter = (pageItem.adapterPlayerInstance!).split('.'); const vTempAdapter = (pageItem.adapterPlayerInstance!).split('.');
let vAdapter = vTempAdapter[0]; const vAdapter: PlayerType = vTempAdapter[0] as PlayerType;
if (optional == 'seek') { if (optional == 'seek') {
let actualStateTemp: number = getState(pageItem.adapterPlayerInstance + 'root.' + pageItem.mediaDevice + '.seek').val; let actualStateTemp: number = getState(pageItem.adapterPlayerInstance + 'root.' + pageItem.mediaDevice + '.seek').val;
if (actualStateTemp >= 95) { if (actualStateTemp >= 95) {
@@ -7882,14 +8024,14 @@ function GenerateDetailPage(type: string, optional: string | undefined, pageItem
tempPlayList[i] = formatInSelText(pageItem.playList![i]); tempPlayList[i] = formatInSelText(pageItem.playList![i]);
} }
optionalString = pageItem.playList != undefined ? tempPlayList.join('?') : '' optionalString = pageItem.playList != undefined ? tempPlayList.join('?') : ''
} else if(vAdapter == 'squeezeboxrpc') { } else if (vAdapter == 'squeezeboxrpc') {
// Playlist browsing not supported by squeezeboxrpc adapter. But Favorites can be used // Playlist browsing not supported by squeezeboxrpc adapter. But Favorites can be used
actualState = ''; // Not supported by squeezeboxrpc adapter actualState = ''; // Not supported by squeezeboxrpc adapter
let tempPlayList: string[] = []; let tempPlayList: string[] = [];
let pathParts: Array<string> = pageItem.adapterPlayerInstance!.split('.'); let pathParts: Array<string> = pageItem.adapterPlayerInstance!.split('.');
for (let favorite_index=0; favorite_index < 45; favorite_index++) { for (let favorite_index = 0; favorite_index < 45; favorite_index++) {
let favorite_name_selector: string = [pathParts[0], pathParts[1], 'Favorites', favorite_index, 'Name'].join('.'); let favorite_name_selector: string = [pathParts[0], pathParts[1], 'Favorites', favorite_index, 'Name'].join('.');
if(!existsObject(favorite_name_selector)) { if (!existsObject(favorite_name_selector)) {
break; break;
} }
let favoritename: string = getState(favorite_name_selector).val; let favoritename: string = getState(favorite_name_selector).val;
@@ -7904,14 +8046,14 @@ function GenerateDetailPage(type: string, optional: string | undefined, pageItem
if (vAdapter == 'volumio') { if (vAdapter == 'volumio') {
actualState = getState(pageItem.id + '.TITLE').val; actualState = getState(pageItem.id + '.TITLE').val;
globalTracklist = pageItem.globalTracklist; globalTracklist = pageItem.globalTracklist;
}else if(vAdapter == 'squeezeboxrpc') { } else if (vAdapter == 'squeezeboxrpc') {
actualState = getState(pageItem.id + '.TITLE').val; actualState = getState(pageItem.id + '.TITLE').val;
}else if(vAdapter == 'sonos') { } else if (vAdapter == 'sonos') {
actualState = getState(pageItem.id + '.TITLE').val; actualState = getState(pageItem.id + '.TITLE').val;
} else { } else {
actualState = getState(pageItem.adapterPlayerInstance + 'player.trackName').val; actualState = getState(pageItem.adapterPlayerInstance + 'player.trackName').val;
} }
actualState = (actualState.replace('?','')).split(' -'); actualState = (actualState.replace('?', '')).split(' -');
actualState = actualState[0].split(" ("); actualState = actualState[0].split(" (");
actualState = formatInSelText(actualState[0]); actualState = formatInSelText(actualState[0]);
if (Debug) log(actualState, 'info'); if (Debug) log(actualState, 'info');
@@ -7919,7 +8061,7 @@ function GenerateDetailPage(type: string, optional: string | undefined, pageItem
//Limit 900 characters, then memory overflow --> Shorten as much as possible //Limit 900 characters, then memory overflow --> Shorten as much as possible
let temp_array: any[] = []; let temp_array: any[] = [];
//let trackArray = (function () { try {return JSON.parse(getState(pageItem.adapterPlayerInstance + 'player.playlist.trackListArray').val);} catch(e) {return {};}})(); //let trackArray = (function () { try {return JSON.parse(getState(pageItem.adapterPlayerInstance + 'player.playlist.trackListArray').val);} catch(e) {return {};}})();
for (let track_index=0; track_index < 45; track_index++) { for (let track_index = 0; track_index < 45; track_index++) {
let temp_cut_array = getAttr(globalTracklist, track_index + '.title'); let temp_cut_array = getAttr(globalTracklist, track_index + '.title');
/* Volumio: @local/NAS no title -> name */ /* Volumio: @local/NAS no title -> name */
if (temp_cut_array == undefined) { if (temp_cut_array == undefined) {
@@ -7927,13 +8069,13 @@ function GenerateDetailPage(type: string, optional: string | undefined, pageItem
} }
if (Debug) log('function GenerateDetailPage role:media tracklist -> ' + temp_cut_array, 'info'); if (Debug) log('function GenerateDetailPage role:media tracklist -> ' + temp_cut_array, 'info');
if (temp_cut_array != undefined) { if (temp_cut_array != undefined) {
temp_cut_array = (temp_cut_array.replace('?','')).split(' -'); temp_cut_array = (temp_cut_array.replace('?', '')).split(' -');
temp_cut_array = temp_cut_array[0].split(" ("); temp_cut_array = temp_cut_array[0].split(" (");
temp_cut_array = temp_cut_array[0]; temp_cut_array = temp_cut_array[0];
if (String(temp_cut_array[0]).length >= 22) { if (String(temp_cut_array[0]).length >= 22) {
temp_array[track_index] = temp_cut_array.substring(0,20) + '..'; temp_array[track_index] = temp_cut_array.substring(0, 20) + '..';
} else { } else {
temp_array[track_index] = temp_cut_array.substring(0,23); temp_array[track_index] = temp_cut_array.substring(0, 23);
} }
} }
else { else {
@@ -7947,13 +8089,13 @@ function GenerateDetailPage(type: string, optional: string | undefined, pageItem
optionalString = pageItem.playList != undefined ? tempTrackList.join('?') : '' optionalString = pageItem.playList != undefined ? tempTrackList.join('?') : ''
mode = 'tracklist'; mode = 'tracklist';
} else if (optional == 'equalizer') { } else if (optional == 'equalizer') {
if (pageItem.id == undefined) throw new Error ('Missing pageItem.id in equalizer!'); if (pageItem.id == undefined) throw new Error('Missing pageItem.id in equalizer!');
let lastIndex = (pageItem.id.split('.')).pop(); let lastIndex = (pageItem.id.split('.')).pop();
if (existsObject(NSPanel_Path + 'Media.Player.' + lastIndex + '.EQ.activeMode') == false || if (existsObject(NSPanel_Path + 'Media.Player.' + lastIndex + '.EQ.activeMode') == false ||
existsObject(NSPanel_Path + 'Media.Player.' + lastIndex + '.Speaker') == false) { existsObject(NSPanel_Path + 'Media.Player.' + lastIndex + '.Speaker') == false) {
createState(NSPanel_Path + 'Media.Player.' + lastIndex + '.EQ.activeMode', <iobJS.StateCommon>{ type: 'string' }); createState(NSPanel_Path + 'Media.Player.' + lastIndex + '.EQ.activeMode', <iobJS.StateCommon> {type: 'string'});
createState(NSPanel_Path + 'Media.Player.' + lastIndex + '.Speaker', <iobJS.StateCommon>{ type: 'string' }); createState(NSPanel_Path + 'Media.Player.' + lastIndex + '.Speaker', <iobJS.StateCommon> {type: 'string'});
} }
actualState = '' actualState = ''
@@ -7976,7 +8118,7 @@ function GenerateDetailPage(type: string, optional: string | undefined, pageItem
if (Debug) log(getState(pageItem.adapterPlayerInstance + 'root.' + pageItem.mediaDevice + '.favorites_set').val, 'info') if (Debug) log(getState(pageItem.adapterPlayerInstance + 'root.' + pageItem.mediaDevice + '.favorites_set').val, 'info')
actualState = formatInSelText(getState(pageItem.adapterPlayerInstance + 'root.' + pageItem.mediaDevice + '.favorites_set').val); actualState = formatInSelText(getState(pageItem.adapterPlayerInstance + 'root.' + pageItem.mediaDevice + '.favorites_set').val);
let tempFavList:string [] = []; let tempFavList: string[] = [];
let favList = getState(pageItem.adapterPlayerInstance + 'root.' + pageItem.mediaDevice + '.favorites_list_array').val; let favList = getState(pageItem.adapterPlayerInstance + 'root.' + pageItem.mediaDevice + '.favorites_list_array').val;
for (let i = 0; i < favList.length; i++) { for (let i = 0; i < favList.length; i++) {
tempFavList[i] = formatInSelText(favList[i]); tempFavList[i] = formatInSelText(favList[i]);
@@ -7996,6 +8138,7 @@ function GenerateDetailPage(type: string, optional: string | undefined, pageItem
+ optionalString + optionalString
}); });
GeneratePage(activePage!); GeneratePage(activePage!);
}
} else if (o.common.role == 'buttonSensor') { } else if (o.common.role == 'buttonSensor') {
let actualValue: string = ''; let actualValue: string = '';
@@ -9406,8 +9549,8 @@ type PageThermo = {
type PageMedia = { type PageMedia = {
type: 'cardMedia', type: 'cardMedia',
items: PageItem[], items: PageMediaItem[],
} & Omit<PageBaseType, 'useColor'> } & Omit<PageBaseType, 'useColor' | 'autoCreateAlias'>
type PageAlarm = { type PageAlarm = {
type: 'cardAlarm', type: 'cardAlarm',
@@ -9434,7 +9577,16 @@ type PageChart = {
items: PageItem[], items: PageItem[],
} & Omit<PageBaseType, 'useColor'> } & Omit<PageBaseType, 'useColor'>
type PageItem = { type PageItem = PageBaseItem | PageMediaItem
function isPageMediaItem(F: PageItem | PageMediaItem):F is PageMediaItem {
return (F as PageMediaItem).adapterPlayerInstance !== undefined
}
type PageMediaItem = {
adapterPlayerInstance: adapterPlayerInstanceType,
} & PageBaseItem
type PageBaseItem = {
id?: string | null, id?: string | null,
icon?: string, icon?: string,
icon2?: string, icon2?: string,
@@ -9462,7 +9614,7 @@ type PageItem = {
navigate?: boolean, navigate?: boolean,
colormode?: string, colormode?: string,
colorScale?: any, colorScale?: any,
adapterPlayerInstance?: string, //adapterPlayerInstance?: adapterPlayerInstanceType,
mediaDevice?: string, mediaDevice?: string,
targetPage?: string, targetPage?: string,
speakerList?: string[], speakerList?: string[],
@@ -9568,3 +9720,38 @@ type IconScaleElement = {
val_max:number, val_max:number,
val_best?: number val_best?: number
} }
/** we need this to have a nice order when using switch() */
type adapterPlayerInstanceType =
'alexa2.0.' | 'alexa2.1.'| 'alexa2.2.' | 'alexa2.3.' | 'alexa2.4.' | 'alexa2.5.' | 'alexa2.6.' | 'alexa2.7.' | 'alexa2.8.' | 'alexa2.9.'
| 'sonos.0.' | 'sonos.1.' | 'sonos.2.' | 'sonos.3.' | 'sonos.4.' | 'sonos.5.' | 'sonos.6.' | 'sonos.7.' | 'sonos.8.' | 'sonos.9.'
| 'spotify-premium.0.' | 'spotify-premium.1.' | 'spotify-premium.2.' | 'spotify-premium.3.' | 'spotify-premium.4.' | 'spotify-premium.5.' | 'spotify-premium.6.' | 'spotify-premium.7.' | 'spotify-premium.8.' | 'spotify-premium.9.'
| 'volumio.0.' | 'volumio.1.' | 'volumio.2.' | 'volumio.3.' |'volumio.4.' | 'volumio.5.' | 'volumio.6.' | 'volumio.7.' | 'volumio.8.' | 'volumio.9.'
| 'squeezeboxrpc.0.' | 'squeezeboxrpc.1.' | 'squeezeboxrpc.2.' | 'squeezeboxrpc.3.' | 'squeezeboxrpc.4.' | 'squeezeboxrpc.5.' | 'squeezeboxrpc.6.' | 'squeezeboxrpc.7.' | 'squeezeboxrpc.8.' | 'squeezeboxrpc.9.'
| 'bosesoundtouch.0.' | 'bosesoundtouch.1.' | 'bosesoundtouch.2.' | 'bosesoundtouch.3.' |'bosesoundtouch.4.' | 'bosesoundtouch.5.' | 'bosesoundtouch.6.' | 'bosesoundtouch.7.' | 'bosesoundtouch.8.' | 'bosesoundtouch.9.'
type PlayerType = 'alexa2' | 'sonos' | 'spotify-premium' | 'volumio' | 'squeezeboxrpc' | 'bosesoundtouch'
type notSortedPlayerType = `${PlayerType}.0.` | `${PlayerType}.1.` | `${PlayerType}.2.` | `${PlayerType}.3.` | `${PlayerType}.4.` | `${PlayerType}.5.` | `${PlayerType}.6.` | `${PlayerType}.7.` | `${PlayerType}.8.` | `${PlayerType}.9.`
/** check if adapterPlayerInstanceType has all Playertypes */
function checkSortedPlayerType(F: notSortedPlayerType) {
const test: adapterPlayerInstanceType = F;
}
type mediaOptional = 'seek' | 'crossfade' | 'speakerlist' | 'playlist' | 'tracklist' | 'equalizer' | 'repeat' | 'favorites'
function isMediaOptional(F: string | mediaOptional): F is mediaOptional {
switch(F as mediaOptional) {
case "seek":
case "crossfade":
case "speakerlist":
case "playlist":
case "tracklist":
case "equalizer":
case "repeat":
case "favorites":
return true;
default:
return false
}
}

28
ioBroker/tsconfig.json Normal file
View File

@@ -0,0 +1,28 @@
{
"compileOnSave": true,
"compilerOptions": {
"noEmit": true,
"allowJs": true,
"checkJs": true,
"module": "commonjs",
"moduleResolution": "node",
"esModuleInterop": true,
"resolveJsonModule": true,
"strict": true,
"noImplicitReturns": true,
"noImplicitAny": false,
"target": "ES2022",
"typeRoots": [
".iobroker/types",
"node_modules/@types"
]
},
"include": [
"**/*.js",
"**/*.ts",
"./.iobroker/types/javascript.d.ts"
],
"exclude": [
"node_modules/**"
]
}