Skip to content
  • Home
  • Recent
  • Tags
  • 0 Unread 0
  • Categories
  • Unreplied
  • Popular
  • GitHub
  • Docu
  • Hilfe
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
ioBroker Logo

Community Forum

donate donate
  1. ioBroker Community Home
  2. Deutsch
  3. Hardware
  4. SONOFF NSPanel mit Lovelace UI (TypeScript Version)

NEWS

  • Neuer ioBroker-Blog online: Monatsrückblick März/April 2026
    BluefoxB
    Bluefox
    8
    1
    522

  • Verwendung von KI bitte immer deutlich kennzeichnen
    HomoranH
    Homoran
    10
    1
    426

  • Monatsrückblick Januar/Februar 2026 ist online!
    BluefoxB
    Bluefox
    18
    1
    994

SONOFF NSPanel mit Lovelace UI (TypeScript Version)

Scheduled Pinned Locked Moved Hardware
lovelace uinspanelsonoff
8.1k Posts 280 Posters 7.4m Views 261 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • SmartStuffCoyoteS SmartStuffCoyote

    @ticaki siehe oben, das hab ich noch gefunden und nachgetragen. Das ".SqueezePlay." im Datenpunkt-Pfad ist falsch. Das existiert schlicht nicht.

    Hab aber immer noch mein "undefined". heul

    author = lmstracklist[currentIndex].Artist + '|' + lmstracklist[currentIndex].Album;
    if (author == undefined || author == "undefined") {
          author = getState(id + '.ARTIST').val;
    }
    

    Das kann aber auch nicht klappen, author wird ja zugewiesen und kann nnicht undefined sein.

                          author = lmstracklist[currentIndex].Artist;
                            if (author == undefined || author == "undefined") {
                                author = getState(id + '.ARTIST').val;
                            } 
                            author = author + '|' + lmstracklist[currentIndex].Album;
    

    klappt bei mir.

    T Do not disturb
    T Do not disturb
    ticaki
    wrote on last edited by ticaki
    #8101

    @SmartStuffCoyote

    Das hier ist trotzdem nötig - da darf kein undefined auf length geprüft werden...

    if (name.length == 0) -> if (typeof name !== 'string' || name.length == 0)

    wobei das ist kürzer (aber auch unsicherer)
    if ((name ?? '').length == 0)

    Weather-Warnings Espresense NSPanel-Lovelace-ui Tagesschau

    Spenden

    1 Reply Last reply
    0
    • ArmilarA Armilar

      @SmartStuffCoyote

      Wenn es jetzt funktioniert, dann bitte mal hier die komplette GenerateMediaPage reinwerfen. Dann kann ich mir das zusammensuchen sparen.

      SmartStuffCoyoteS Online
      SmartStuffCoyoteS Online
      SmartStuffCoyote
      wrote on last edited by SmartStuffCoyote
      #8102

      @Armilar Hier, inklusive des Fix von @ticaki

      function GenerateMediaPage (page: NSPanel.PageMedia): NSPanel.Payload[] {
          try {
              unsubscribeMediaSubscriptions();
      
              if (!page.items[0].id) throw new Error('Missing page id for cardMedia!');
      
              let id = page.items[0].id;
              let tid = 0;
              let out_msgs: NSPanel.Payload[] = [];
      
              if (!page.items[0].adapterPlayerInstance!) throw new Error('page.items[0].adapterPlayerInstance is undefined!');
              let vInstance = page.items[0].adapterPlayerInstance!;
              let v1Adapter = vInstance.split('.');
              let v2Adapter: NSPanel.PlayerType = v1Adapter[0] as NSPanel.PlayerType;
      
              let vMediaDevice = page.items[0].mediaDevice != undefined ? page.items[0].mediaDevice : '';
      
              if (isPlayerWithMediaDevice(v2Adapter)) {
                  if (!vMediaDevice) throw new Error(`Error in cardMedia! mediaDevice is empty! Page: ${JSON.stringify(page)}`);
              }
              createAutoMediaAlias(id, vMediaDevice, page.items[0].adapterPlayerInstance!);
      
              // Leave the display on if the alwaysOnDisplay parameter is specified (true)
              if (page.type == 'cardMedia' && pageCounter == 0 && page.items[0].alwaysOnDisplay != undefined) {
                  out_msgs.push({payload: 'pageType~cardMedia'});
                  if (page.items[0].alwaysOnDisplay != undefined) {
                      if (page.items[0].alwaysOnDisplay) {
                          pageCounter = 1;
                          if (alwaysOn == false) {
                              alwaysOn = true;
                              SendToPanel({payload: 'timeout~0'});
                              subscribeMediaSubscriptions(page.items[0].id);
                              if (v2Adapter == 'sonos') {
                                  subscribeMediaSubscriptionsSonosAdd(page.items[0].id);
                              } else if (v2Adapter == 'spotify-premium') {
                                  setState(vInstance + 'getDevices', true);
                                  setState(vInstance + 'getPlaybackInfo', true);
                                  setState(vInstance + 'getPlaylists', true);
                              }
                          }
                      }
                  }
              } else if (page.type == 'cardMedia' && pageCounter == 1) {
                  alwaysOn = true;
                  subscribeMediaSubscriptions(page.items[0].id);
                  if (v2Adapter == 'sonos') {
                      subscribeMediaSubscriptionsSonosAdd(page.items[0].id);
                  }
              } else if (page.type == 'cardMedia' && pageCounter == -1) {
                  //Do Nothing
              } else {
                  out_msgs.push({payload: 'pageType~cardMedia'});
              }
      
              if (existsObject(id)) {
      
                  let name = "";
                  if (page.items[0].showOnlyPlayerHeadline && page.items[0].showOnlyPlayerHeadline != undefined) {
                      //name = getState(page.items[0].adapterPlayerInstance + "Players.SqueezePlay.Playername").val;
                      name = getState(page.items[0].adapterPlayerInstance + "Players." + page.items[0].mediaDevice + ".Playername").val;
                      //name = page.heading;
                  } else {
                      name = getState(id + '.ALBUM').val;
                      console.log("##### else name");
                  }
                  let title = getState(id + '.TITLE').val;
                  if (title && title.indexOf('~') !== -1) {
                      title = title.split('~')[0].trim();
                  }
      
                  if (title.length > 24) {
                      title = title.slice(0, 24) + '...';
                  }
                  if (existsObject(id + '.DURATION') && existsObject(id + '.ELAPSED')) {
                      if (v2Adapter == 'alexa2') {
                          if (Debug) log(getState(id + '.DURATION').val, 'info');
                          let Seconds = parseInt(getState(id + '.DURATION').val) % 60 < 10 ? '0' : '';
                          let Duration = Math.floor(getState(id + '.DURATION').val / 60) + ':' + Seconds + (getState(id + '.DURATION').val % 60);
                          let vElapsed = getState(id + '.ELAPSED').val;
      
                          if (vElapsed.length == 5) {
                              if (parseInt(vElapsed.slice(0, 2)) < 9) {
                                  vElapsed = vElapsed.slice(1);
                              }
                          }
                          if (vElapsed == 0) {
                              vElapsed = '0:00';
                          }
                          let vDuration = Duration;
                          if (vDuration.length == 5) {
                              if (parseInt(vDuration.slice(0, 2)) < 9) {
                                  vDuration = vDuration.slice(1);
                              }
                          }
                          if (vDuration != '0:00') {
                              title = title + ' (' + vElapsed + '|' + vDuration + ')';
                          } else {
                              title = title + ' (' + vElapsed + ')';
                          }
                          if (title == ' (0:00)') {
                              title = '';
                          }
                      } else if (v2Adapter == 'sonos' && getState(page.items[0].adapterPlayerInstance + 'root.' + page.items[0].mediaDevice + '.current_type').val == 0) {
                          let vElapsed = getState(id + '.ELAPSED').val;
                          if (vElapsed.length == 5) {
                              if (parseInt(vElapsed.slice(0, 2)) < 9) {
                                  vElapsed = vElapsed.slice(1);
                              }
                          } else if (vElapsed.length == 8) {
                              vElapsed = vElapsed.slice(4);
                          }
                          let vDuration = getState(id + '.DURATION').val;
                          if (vDuration.length == 5) {
                              if (parseInt(vDuration.slice(0, 2)) < 9) {
                                  vDuration = vDuration.slice(1);
                              }
                          } else if (vDuration.length == 8) {
                              vDuration = vDuration.slice(4);
                          }
                          title = title + ' (' + vElapsed + '|' + vDuration + ')';
                      } else if (v2Adapter == 'bosesoundtouch') {
                          if (Debug) log(getState(id + '.ELAPSED').val, 'info');
                          let elapsedSeconds = parseInt(getState(id + '.ELAPSED').val) % 60 < 10 ? '0' : '';
                          let vElapsed = Math.floor(getState(id + '.ELAPSED').val / 60) + ':' + elapsedSeconds + (getState(id + '.ELAPSED').val % 60);
                          if (Debug) log(getState(id + '.DURATION').val, 'info');
                          let durationSeconds = parseInt(getState(id + '.DURATION').val) % 60 < 10 ? '0' : '';
                          let vDuration = Math.floor(getState(id + '.DURATION').val / 60) + ':' + durationSeconds + (getState(id + '.DURATION').val % 60);
                          title = title + ' (' + vElapsed + '|' + vDuration + ')';
                      } else if (v2Adapter == 'mpd') {
                          let vElapsed: string = getState(id + '.ELAPSED').val;
                          let vDuration: string = getState(id + '.DURATION').val;
                          title = title + ' (' + vElapsed + '|' + vDuration + ')';
                          if (getState(id + '.STATE').val === 'stop') {
                              title = '(00:00|00:00)';
                          }
                      }
                  }
      
                  let author = getState(id + '.ARTIST').val;
      
                  if (v2Adapter == 'squeezeboxrpc' && author.length > 0) {
                      if (existsObject([page.items[0].adapterPlayerInstance, 'Players.', page.items[0].mediaDevice, '.Playlist'].join(''))) {
                          if (existsObject([page.items[0].adapterPlayerInstance, 'Players.', page.items[0].mediaDevice, '.Playlist'].join(''))) {
                              let lmstracklist = JSON.parse(getState([page.items[0].adapterPlayerInstance, 'Players.', page.items[0].mediaDevice, '.Playlist'].join('')).val);
                              let currentIndex: number = parseInt(getState([page.items[0].adapterPlayerInstance, 'Players.', page.items[0].mediaDevice, '.PlaylistCurrentIndex'].join('')).val);
                              
                              author = lmstracklist[currentIndex].Artist;
                              if (author == undefined || author == "undefined") {
                                  author = getState(id + '.ARTIST').val;
                              } 
                              author = author + '|' + lmstracklist[currentIndex].Album;
                              if (author.length > 37) {
                                  author = author.slice(0, 37) + '...';
                              }
                              let elapsedTime: number = parseInt(getState([page.items[0].adapterPlayerInstance, 'Players.', page.items[0].mediaDevice, '.Time'].join('')).val);
                              let elapsedSeconds = elapsedTime % 60 < 10 ? '0' : '';
                              let vElapsed = Math.floor(elapsedTime / 60) + ':' + elapsedSeconds + (elapsedTime % 60);
      
                              let durationSeconds = parseInt(lmstracklist[currentIndex].Duration) % 60 < 10 ? '0' : '';
                              let vDuration = Math.floor(parseInt(lmstracklist[currentIndex].Duration) / 60) + ':' + durationSeconds + (parseInt(lmstracklist[currentIndex].Duration) % 60);
                              title = lmstracklist[currentIndex].title;
                              if (title.length > 25) {
                                  title = title.slice(0, 25) + '...';
                              }
                              title = title + ' (' + vElapsed + '|' + vDuration + ')';
                          }
                      }
                  }
      
                  // Settings >>Aktualisierungsintervall für Statusinformationen<< = 1 !
                  // If the refresh time is set to 1 second in the spotify-premium.X instance,
                  // the elapsed refresh bug '00:00' is not visible
                  if (v2Adapter == 'spotify-premium') {
                      let vElapsed: string = getState(id + '.ELAPSED').val;
                      if (vElapsed.substring(0, 1) == '0') {
                          vElapsed = vElapsed.slice(1);
                      }
                      let vDuration: string = getState(id + '.DURATION').val;
                      if (vDuration.substring(0, 1) == '0') {
                          vDuration = vDuration.slice(1);
                      }
                      title = title + ' (' + vElapsed + '|' + vDuration + ')';
                      if (title == ' (0:00|0:00)') {
                          title = '';
                      }
                  }
      
                  let shuffle = getState(id + '.SHUFFLE').val;
      
                  //New Adapter/Player
                  let media_icon = Icons.GetIcon('playlist-music');
      
                  //Spotify-Premium
                  if (v2Adapter == 'spotify-premium') {
                      media_icon = Icons.GetIcon('spotify');
                      if (page.items[0].playerMediaIcon !== undefined) {
                          if (page.items[0].playerMediaIcon == 'logo-spotify') {
                              media_icon = page.items[0].playerMediaIcon;
                          } else {
                              media_icon = Icons.GetIcon(page.items[0].playerMediaIcon);
                          }
                      }
                      name = getState(id + '.CONTEXT_DESCRIPTION').val;
                      let nameLength = name.length;
                      if (name.substring(0, 17) == 'Playlist: This Is') {
                          name = name.slice(18, 34) + '...';
                      } else if (name.substring(0, 9) == 'Playlist:') {
                          name = name.slice(10, 26) + '...';
                      } else if (name.substring(0, 6) == 'Album:') {
                          name = name.slice(7, 23) + '...';
                      } else if (name.substring(0, 6) == 'Track:') {
                          name = name.slice(7, 23) + '...';
                      } else if (name.substring(0, 7) == 'Artist:') {
                          name = name.slice(8, 24) + '...';
                      }
                      if (nameLength == 0) {
                          name = 'Spotify-Premium';
                      }
                      author = getState(id + '.ARTIST').val + ' | ' + getState(id + '.ALBUM').val;
                      if (author.length > 37) {
                          author = author.slice(0, 37) + '...';
                      }
                      if (getState(id + '.ARTIST').val.length == 0) {
                          author = findLocale('media', 'no_music_to_control');
                      }
                  }
      
                  //Sonos
                  if (v2Adapter == 'sonos') {
                      media_icon = Icons.GetIcon('alpha-s-circle');
                      if (page.items[0].playerMediaIcon !== undefined) {
                          if (page.items[0].playerMediaIcon == 'logo-sonos') {
                              media_icon = page.items[0].playerMediaIcon;
                          } else {
                              media_icon = Icons.GetIcon(page.items[0].playerMediaIcon);
                          }
                      }
                      name = getState(id + '.CONTEXT_DESCRIPTION').val;
                      let nameLenght = name.length;
                      if (nameLenght == 0) {
                          name = page.heading;
                      } else if (nameLenght > 16) {
                          name = name.slice(0, 16) + '...';
                      }
                      if (getState(id + '.ALBUM').val.length > 0) {
                          author = getState(id + '.ARTIST').val + ' | ' + getState(id + '.ALBUM').val;
                          if (author.length > 37) {
                              author = author.slice(0, 37) + '...';
                          }
                      } else {
                          author = getState(id + '.ARTIST').val;
                      }
                      if (getState(id + '.ARTIST').val.length == 0) {
                          author = findLocale('media', 'no_music_to_control');
                      }
                  }
      
                  //Bose Soundtouch
                  if (v2Adapter == 'bosesoundtouch') {
                      media_icon = Icons.GetIcon('alpha-b-circle');
                      if (page.items[0].playerMediaIcon !== undefined) {
                          if (page.items[0].playerMediaIcon == 'logo-bose') {
                              media_icon = page.items[0].playerMediaIcon;
                          } else {
                              media_icon = Icons.GetIcon(page.items[0].playerMediaIcon);
                          }
                      }
                      name = page.heading;
      
                      if (getState(id + '.ALBUM').val.length > 0) {
                          author = getState(id + '.ARTIST').val + ' | ' + getState(id + '.ALBUM').val;
                          if (author.length > 37) {
                              author = author.slice(0, 37) + '...';
                          }
                      } else {
                          author = getState(id + '.ARTIST').val;
                      }
                      if (getState(id + '.ARTIST').val.length == 0) {
                          author = findLocale('media', 'no_music_to_control');
                      }
                  }
      
                  //Logitech Squeezebox RPC
                  if (v2Adapter == 'squeezeboxrpc') {
                      media_icon = Icons.GetIcon('dlna');
                      if (page.items[0].playerMediaIcon !== undefined) {
                          if (page.items[0].playerMediaIcon == 'logo-dnla') {
                              media_icon = page.items[0].playerMediaIcon;
                          } else {
                              media_icon = Icons.GetIcon(page.items[0].playerMediaIcon);
                          }
                      }
                      if (name.length == 0) {
                          name = page.heading;
                      } else if (name.length > 16) {
                          name = name.slice(0, 16) + '...';
                      }
                  }
      
                  //Alexa2
                  if (v2Adapter == 'alexa2') {
                      media_icon = Icons.GetIcon('alpha-a-circle');
                      if (page.items[0].playerMediaIcon !== undefined) {
                          if (page.items[0].playerMediaIcon == 'logo-alexa') {
                              media_icon = page.items[0].playerMediaIcon;
                          } else {
                              media_icon = Icons.GetIcon(page.items[0].playerMediaIcon);
                          }
                      }
                      name = getState(id + '.ALBUM').val;
                      let nameLength = name.length;
                      if (name.substring(0, 9) == 'Playlist:') {
                          name = name.slice(10, 26) + '...';
                      } else if (name.substring(0, 6) == 'Album:') {
                          name = name.slice(7, 23) + '...';
                      } else if (name.substring(0, 6) == 'Track') {
                          name = 'Alexa Player';
                      }
                      if (nameLength == 0) {
                          name = 'Alexa Player';
                      } else {
                          name = name.slice(0, 16) + '...';
                      }
                      author = getState(id + '.ARTIST').val + ' | ' + getState(id + '.ALBUM').val;
                      if (author.length > 30) {
                          author = getState(id + '.ARTIST').val;
                      }
                      if (getState(id + '.ARTIST').val.length == 0) {
                          author = findLocale('media', 'no_music_to_control');
                      }
                  }
      
                  //Volumio
                  if (v2Adapter == 'volumio') {
                      media_icon = Icons.GetIcon('clock-time-twelve-outline');
                      if (page.items[0].playerMediaIcon !== undefined) {
                          if (page.items[0].playerMediaIcon == 'logo-volumio') {
                              media_icon = page.items[0].playerMediaIcon;
                          } else {
                              media_icon = Icons.GetIcon(page.items[0].playerMediaIcon);
                          }
                      }
                      if (name != undefined) {
                          author = author + ' | ' + name;
                      }
                      name = page.heading;
                  }
      
                  //MPD
                  if (v2Adapter == 'mpd') {
                      media_icon = Icons.GetIcon('alpha-m-circle');
                      if (page.items[0].playerMediaIcon !== undefined) {
                          if (page.items[0].playerMediaIcon == 'logo-mpd') {
                              media_icon = page.items[0].playerMediaIcon;
                          } else {
                              media_icon = Icons.GetIcon(page.items[0].playerMediaIcon);
                          }
                      }
                      if (getState(id + '.ALBUM').val.length > 0) {
                          author = getState(id + '.ARTIST').val + ' | ' + getState(id + '.ALBUM').val;
                          if (author.length > 37) {
                              author = author.slice(0, 37) + '...';
                          }
                      } else {
                          author = getState(id + '.ARTIST').val;
                      }
                      if (getState(id + '.ARTIST').val.length == 0) {
                          author = findLocale('media', 'no_music_to_control');
                      }
                      name = page.heading;
                  }
      
                  let volume = scale(getState(id + '.VOLUME').val, activePage!.items[0]!.minValue ?? 0, activePage!.items[0]!.maxValue ?? 100, 100, 0);
                  let iconplaypause = Icons.GetIcon('pause'); //pause
                  let shuffle_icon = Icons.GetIcon('shuffle-variant'); //shuffle
                  let onoffbutton = 1374;
      
                  if (shuffle == 'off' || shuffle == false || shuffle == 0 || shuffle == 'false') {
                      shuffle_icon = Icons.GetIcon('shuffle-disabled'); //shuffle
                  }
      
                  // Todo: Refresh automatisieren und dafür wieder Shuffle nutzen
                  //if (v2Adapter == 'volumio') { shuffle_icon = Icons.GetIcon('shuffle-disabled'); } //Volumio: refresh playlist
      
                  //For all players
                  if (getState(id + '.STATE').val) {
                      onoffbutton = 65535;
                      iconplaypause = Icons.GetIcon('pause'); //pause
                  } else {
                      iconplaypause = Icons.GetIcon('play'); //play
                  }
      
                  //Ausnahme für squeezebox, da State = Power
                  if (v2Adapter == 'squeezeboxrpc') {
                      if (getState(id + '.PAUSE').val === false) {
                          onoffbutton = 65535;
                          iconplaypause = Icons.GetIcon('pause'); //pause
                      } else {
                          iconplaypause = Icons.GetIcon('play'); //play
                      }
                  }
      
                  //Ausnahme für mpd, da State = play, pause,....
                  if (v2Adapter == 'mpd') {
                      if (getState(id + '.STATE').val === 'play') {
                          onoffbutton = 65535;
                          iconplaypause = Icons.GetIcon('pause'); //pause
                      } else if (getState(id + '.STATE').val === 'pause') {
                          iconplaypause = Icons.GetIcon('play'); //play
                      } else if (getState(id + '.STATE').val === 'stop') {
                          onoffbutton = 1374;
                          iconplaypause = Icons.GetIcon('play'); //play
                      }
      
                  }
      
                  //Ausnahme Volumio: status = string: play, pause, stop usw.
                  if (v2Adapter == 'volumio') {
                      if (getState(id + '.status').val == 'play') {
                          onoffbutton = 65535;
                          iconplaypause = Icons.GetIcon('pause'); //pause
                      } else {
                          iconplaypause = Icons.GetIcon('play'); //play
                      }
                  }
      
                  let currentSpeaker: string = findLocale('media', 'no_speaker_found');
      
                  if (v2Adapter == 'alexa2') {
                      currentSpeaker = getState([page.items[0].adapterPlayerInstance, 'Echo-Devices.', page.items[0].mediaDevice, '.Info.name'].join('')).val;
                  } else if (v2Adapter == 'spotify-premium') {
                      currentSpeaker = getState([page.items[0].adapterPlayerInstance, 'player.device.name'].join('')).val;
                  } else if (v2Adapter == 'sonos') {
                      currentSpeaker = getState([page.items[0].adapterPlayerInstance, 'root.', page.items[0].mediaDevice, '.members'].join('')).val;
                  } else if (v2Adapter == 'squeezeboxrpc') {
                      currentSpeaker = getState([page.items[0].adapterPlayerInstance, 'Players.', page.items[0].mediaDevice, '.Playername'].join('')).val;
                  } else if (v2Adapter == 'bosesoundtouch') {
                      currentSpeaker = getState([page.items[0].adapterPlayerInstance, 'deviceInfo.name'].join('')).val;
                  } else if (v2Adapter == 'volumio') {
                      currentSpeaker = getState([page.items[0].adapterPlayerInstance, 'info.name'].join('')).val;
                  } else if (v2Adapter == 'mpd') {
                      currentSpeaker = v1Adapter[0] + '.' + v1Adapter[1];
                  }
                  //-------------------------------------------------------------------------------------------------------------
                  // All Alexa devices (the online / player and commands directory is available) are listed and linked below
                  // If the constant alexaSpeakerList contains at least one entry, the constant is used - otherwise all devices from the Alexa adapter
                  let speakerListArray: string[] = [];
                  if (page.items[0].speakerList && page.items[0].speakerList.length > 0) {
                      for (let i_index in page.items[0].speakerList) {
                          speakerListArray.push(page.items[0].speakerList[i_index]);
                      }
                  } else if (v2Adapter == 'squeezeboxrpc') {
                      // Beim Squeezeboxrpc ist jeder Player ein eigener Knoten im Objektbaum. Somit werden einzelne Aliase benötigt.
                      const squeezeboxPlayerQuery: iobJS.QueryResult = $('channel[state.id=' + page.items[0].adapterPlayerInstance + '.Players.*.Playername]');
                      squeezeboxPlayerQuery.each((playerId: string, playerIndex: number) => {
                          speakerListArray.push(getState(playerId).val);
                          page.items[0].speakerList = speakerListArray;
                      });
                  } else if (v2Adapter == 'spotify-premium') {
                      // All possible Devices if page.items[0].speakerList empty
                      if (Debug) log(getState(page.items[0].adapterPlayerInstance + 'devices.availableDeviceListString').val);
                      speakerListArray = getState(page.items[0].adapterPlayerInstance + 'devices.availableDeviceListString').val.split(';');
                      page.items[0].speakerList = speakerListArray;
                  } else if (v2Adapter == 'mpd') {
                      // All possible Devices if page.items[0].speakerList empty
                      page.items[0].speakerList[0] = v1Adapter[0] + '.' + v1Adapter[1];
                  } else {
                      let i_list = Array.prototype.slice.apply($('[state.id="' + page.items[0].adapterPlayerInstance + 'Echo-Devices.*.Info.name"]'));
                      for (let i_index in i_list) {
                          let i = i_list[i_index];
                          let deviceId = i;
                          deviceId = deviceId.split('.');
                          if (
                              getState([page.items[0].adapterPlayerInstance, 'Echo-Devices.', deviceId[3], '.online'].join('')).val &&
                              existsObject([page.items[0].adapterPlayerInstance, 'Echo-Devices.', deviceId[3], '.Player'].join('')) &&
                              existsObject([page.items[0].adapterPlayerInstance, 'Echo-Devices.', deviceId[3], '.Commands'].join(''))
                          ) {
                              speakerListArray.push(getState(i).val);
                          }
                      }
                  }
                  //--------------------------------------------------------------------------------------------------------------
      
                  let colMediaIcon = page.items[0].colorMediaIcon != undefined ? page.items[0].colorMediaIcon : White;
                  let colMediaTitle = page.items[0].colorMediaTitle != undefined ? page.items[0].colorMediaTitle : White;
                  let colMediaArtist = page.items[0].colorMediaArtist != undefined ? page.items[0].colorMediaArtist : White;
      
                  //InSel Speaker
                  let speakerListString: string = '~~~~~~';
                  let speakerListIconCol = rgb_dec565(HMIOff);
                  if (speakerListArray.length > 0) {
                      speakerListIconCol = rgb_dec565(HMIOn);
                      speakerListString = 'input_sel' + '~' + tid + '?speakerlist' + '~' + Icons.GetIcon('speaker') + '~' + speakerListIconCol + '~' + findLocale('media', 'speaker') + '~' + 'media0~';
                  }
      
                  //InSel Playlist
                  let playListString: string = '~~~~~~';
                  let playListIconCol = rgb_dec565(HMIOff);
                  if (page.items[0].playList != undefined) {
                      /* Volumio: get actual playlist if empty */
                      if (v2Adapter == 'volumio') {
                          if (page.items[0].playList.length == 0) {
                              let urlString: string = `${getState(vInstance + 'info.host').val}/api/listplaylists`;
      
                              axios
                                  .get(urlString, {headers: {'User-Agent': 'ioBroker'}})
                                  .then(async function (response) {
                                      if (response.status === 200) {
                                          if (Debug) {
                                              log(JSON.stringify(response.data), 'info');
                                          }
                                          page.items[0].playList = JSON.parse(JSON.stringify(response.data));
                                          if (Debug) log('volumio-playlist: ' + page.items[0].playList, 'info');
                                      } else {
                                          log('Axios Status - get_volumio-playlist: ' + response.state, 'warn');
                                      }
                                  })
                                  .catch(function (error) {
                                      log(error, 'warn');
                                  });
                          }
                          /* Spotify: get all playlists if empty */
                      } else if (v2Adapter == 'spotify-premium') {
                          page.items[0].playList = getState(page.items[0].adapterPlayerInstance + 'playlists.playlistListString').val.split(';');
                      } else if (v2Adapter == 'mpd') {
                          let tempPL = getState(page.items[0].adapterPlayerInstance + 'listplaylists').val;
                          tempPL = tempPL.replace('[', '');
                          tempPL = tempPL.replace(']', '');
                          tempPL = tempPL.replaceAll('"', '');
                          page.items[0].playList = tempPL.split(',');
                      }
                      playListIconCol = rgb_dec565(HMIOn);
                      playListString =
                          'input_sel' +
                          '~' +
                          tid +
                          '?playlist' +
                          '~' +
                          Icons.GetIcon('playlist-play') +
                          '~' +
                          playListIconCol +
                          '~' +
                          //'PlayL ' + page.heading + '~' +
                          findLocale('media', 'playlist') +
                          '~' +
                          'media1~';
                  }
      
                  //InSel Tracklist
                  globalTracklist = '';
      
                  let trackListString: string = '~~~~~~';
                  let trackListIconCol = rgb_dec565(HMIOff);
                  if (v2Adapter == 'volumio') {
                      /* Volumio: get queue */
                      setTimeout(async function () {
                          let urlString: string = `${getState(vInstance + 'info.host').val}/api/getQueue`;
      
                          axios
                              .get(urlString, {headers: {'User-Agent': 'ioBroker'}})
                              .then(async function (response) {
                                  if (response.status === 200) {
                                      if (Debug) {
                                          log(JSON.stringify(response.data), 'info');
                                      }
                                      const QUEUELIST = JSON.parse(JSON.stringify(response.data));
                                      page.items[0].globalTracklist = QUEUELIST.queue;
                                      if (Debug) {
                                          for (let i_index in QUEUELIST.queue) {
                                              log('volumio-queue: ' + QUEUELIST.queue[i_index], 'info');
                                          }
                                      }
                                  } else {
                                      log('Axios Status - get_volumio-queue: ' + response.state, 'warn');
                                  }
                              })
                              .catch(function (error) {
                                  log(error, 'warn');
                              });
                      }, 2000);
                      globalTracklist = page.items[0].globalTracklist;
                  } else if (v2Adapter == 'squeezeboxrpc' && existsObject([page.items[0].adapterPlayerInstance, 'Players.', page.items[0].mediaDevice, '.Playlist'].join(''))) {
                      let lmstracklist = JSON.parse(getState([page.items[0].adapterPlayerInstance, 'Players.', page.items[0].mediaDevice, '.Playlist'].join('')).val);
                      globalTracklist = lmstracklist;
                  } else if (v2Adapter == 'sonos' && existsObject([page.items[0].adapterPlayerInstance, 'root.', page.items[0].mediaDevice, '.playlist_set'].join(''))) {
                      let lmstracklist = getState([page.items[0].adapterPlayerInstance, 'root.', page.items[0].mediaDevice, '.queue'].join('')).val;
                      lmstracklist = lmstracklist.replace(/\s*[\[{(].*?[)}\]]\s*/g, '');
                      let lmstracklistTemp = lmstracklist.split(', ');
                      let trackList: string = '[';
                      if (getState(page.items[0].adapterPlayerInstance + 'root.' + page.items[0].mediaDevice + '.current_type').val == 0) {
                          for (let i = 0; i < lmstracklistTemp.length; i++) {
                              let trackTemp = lmstracklistTemp[i].split(' - ');
                              trackList = trackList + '{"id":"' + i + '","name":"' + trackTemp[0] + '","title":"' + trackTemp[1] + '"}';
                              if (i < lmstracklistTemp.length - 1) {
                                  trackList = trackList + ',';
                              }
                          }
                      }
                      trackList = trackList + ']';
                      if (Debug) log(trackList, 'info');
                      globalTracklist = trackList;
                  } else if (v2Adapter == 'spotify-premium') {
                      try {
                          let tempTrackList = JSON.parse(getState(page.items[0].adapterPlayerInstance + 'player.playlist.trackListArray').val);
                          globalTracklist = tempTrackList;
                      } catch {
                          log('Hello Mr. Developer something went wrong in tracklist!', 'debug');
                      }
                  } else if (v2Adapter == 'mpd') {
                      try {
                          let tempTrackList = JSON.parse(getState(page.items[0].adapterPlayerInstance + 'playlist_list').val);
                          globalTracklist = tempTrackList;
                      } catch {
                          log('Hello Mr. Developer something went wrong in tracklist!', 'debug');
                      }
                  }
      
                  if (globalTracklist != null && globalTracklist.length != 0) {
                      trackListIconCol = rgb_dec565(HMIOn);
                      trackListString =
                          'input_sel' + '~' + tid + '?tracklist' + '~' + Icons.GetIcon('animation-play-outline') + '~' + trackListIconCol + '~' + findLocale('media', 'tracklist') + '~' + 'media2~';
                  }
      
                  // InSel/Slider EQ
                  let equalizerListString: string = '~~~~~~';
                  let equalizerListIconCol = rgb_dec565(HMIOff);
      
                  if (page.items[0].equalizerList != undefined) {
                      equalizerListIconCol = rgb_dec565(HMIOn);
                      equalizerListString =
                          'input_sel' + '~' + tid + '?equalizer' + '~' + Icons.GetIcon('equalizer-outline') + '~' + equalizerListIconCol + '~' + findLocale('media', 'equalizer') + '~' + 'media3~';
                  } else if (page.items[0].equalizerSlider != undefined && v2Adapter == 'alexa2') {
                      equalizerListIconCol = rgb_dec565(HMIOn);
                      equalizerListString =
                          'slider' + '~' + tid + '~' + Icons.GetIcon('equalizer-outline') + '~' + equalizerListIconCol + '~' + findLocale('media', 'equalizer') + '~' + 'media3~';
                  } else if (page.items[0].equalizerList == undefined && v2Adapter == 'sonos') {
                      let equalizerListIconCol = rgb_dec565(HMIOn);
                      //equalizerListString is used for favariteList
                      equalizerListString =
                          'input_sel' + '~' + tid + '?favorites' + '~' + Icons.GetIcon('playlist-star') + '~' + equalizerListIconCol + '~' + findLocale('media', 'favorites') + '~' + 'media3~';
                  }
      
                  //Repeat Control Button
                  let repeatIcon = Icons.GetIcon('repeat-variant');
                  let repeatIconCol = rgb_dec565(HMIOff);
                  let repeatButtonString: string = '~~~~~~';
      
                  if (v2Adapter == 'spotify-premium') {
                      if (getState(id + '.REPEAT').val == 'context') {
                          repeatIcon = Icons.GetIcon('repeat-variant');
                          repeatIconCol = rgb_dec565(HMIOn);
                      } else if (getState(id + '.REPEAT').val == 'track') {
                          repeatIcon = Icons.GetIcon('repeat-once');
                          repeatIconCol = rgb_dec565(HMIOn);
                      }
                  } else if (v2Adapter == 'alexa2') {
                      if (getState(id + '.REPEAT').val == true) {
                          repeatIcon = Icons.GetIcon('repeat-variant');
                          repeatIconCol = rgb_dec565(HMIOn);
                      }
                  } else if (v2Adapter == 'sonos') {
                      if (getState(id + '.REPEAT').val == 1) {
                          repeatIcon = Icons.GetIcon('repeat-variant');
                          repeatIconCol = rgb_dec565(HMIOn);
                      } else if (getState(id + '.REPEAT').val == 2) {
                          repeatIcon = Icons.GetIcon('repeat-once');
                          repeatIconCol = rgb_dec565(HMIOn);
                      }
                  } else if (v2Adapter == 'bosesoundtouch') {
                      if (getState(id + '.REPEAT').val == 'REPEAT_ALL') {
                          repeatIcon = Icons.GetIcon('repeat-variant');
                          repeatIconCol = rgb_dec565(HMIOn);
                      } else if (getState(id + '.REPEAT').val == 'REPEAT_ONE') {
                          repeatIcon = Icons.GetIcon('repeat-once');
                          repeatIconCol = rgb_dec565(HMIOn);
                      }
                  } else if (v2Adapter == 'squeezeboxrpc') {
                      if (getState(id + '.REPEAT').val == 1) {
                          repeatIcon = Icons.GetIcon('repeat-once');
                          repeatIconCol = rgb_dec565(HMIOn);
                      } else if (getState(id + '.REPEAT').val == 2) {
                          repeatIcon = Icons.GetIcon('repeat');
                          repeatIconCol = rgb_dec565(HMIOn);
                      }
                  } else if (v2Adapter == 'volumio') {
                      /* Volumio: only Repeat true/false with API */
                      if (getState(id + '.REPEAT').val == true) {
                          repeatIcon = Icons.GetIcon('repeat-variant');
                          repeatIconCol = rgb_dec565(HMIOn);
                      }
                  } else if (v2Adapter == 'mpd') {
                      if (getState(id + '.REPEAT').val == true && getState(id + '.SINGLE').val == 0) {
                          repeatIcon = Icons.GetIcon('repeat');
                          repeatIconCol = rgb_dec565(HMIOn);
                      } else if (getState(id + '.REPEAT').val == true && getState(id + '.SINGLE').val == 1) {
                          repeatIcon = Icons.GetIcon('repeat-once');
                          repeatIconCol = rgb_dec565(HMIOn);
                      }
                  }
      
                  if (v2Adapter == 'spotify-premium' || v2Adapter == 'alexa2' || v2Adapter == 'sonos' || v2Adapter == 'bosesoundtouch' || v2Adapter == 'volumio' || v2Adapter == 'squeezeboxrpc' || v2Adapter == 'mpd') {
                      repeatButtonString = 'button' + '~' + tid + '?repeat' + '~' + repeatIcon + '~' + repeatIconCol + '~' + 'Repeat' + '~' + 'media4';
                  }
      
                  //popUp Tools
                  let toolsString: string = '~~~~~~';
                  let toolsIconCol = rgb_dec565(colMediaIcon);
                  if (v2Adapter == 'sonos' || v2Adapter == 'mpd') {
                      if (page.items[0].crossfade == undefined || page.items[0].crossfade == false) {
                          toolsString = 'input_sel' + '~' + tid + '?seek' + '~' + media_icon + '~' + toolsIconCol + '~' + findLocale('media', 'seek') + '~' + 'media5~';
                      } else {
                          toolsString = 'input_sel' + '~' + tid + '?crossfade' + '~' + media_icon + '~' + toolsIconCol + '~' + findLocale('media', 'crossfade') + '~' + 'media5~';
                      }
                  } else if (v2Adapter == 'squeezeboxrpc') {
                      if (page.items[0].crossfade == undefined || page.items[0].crossfade == false) {
                          toolsString = 'input_sel' + '~' + tid + '?seek' + '~' + media_icon + '~' + toolsIconCol + '~' + findLocale('media', 'seek') + '~' + 'media5~';
                      }
                  } else if (v2Adapter == 'spotify-premium') {
                      if (page.items[0].crossfade == undefined || page.items[0].crossfade == false) {
                          toolsString = 'input_sel' + '~' + tid + '?seek' + '~' + media_icon + '~' + toolsIconCol + '~' + findLocale('media', 'seek') + '~' + 'media5~';
                      }
                  } else {
                      toolsString = 'button' + '~' + tid + '' + '~' + media_icon + '~' + toolsIconCol + '~' + findLocale('media', 'tools') + '~' + 'media5~';
                  }
      
                  out_msgs.push({
                      payload:
                          'entityUpd~' + //entityUpd
                          name +
                          '~' + //heading
                          getNavigationString(pageId) +
                          '~' + //navigation
                          tid +
                          '~' + //internalNameEntiy
                          title +
                          '~' + //title
                          rgb_dec565(colMediaTitle) +
                          '~' + //titleColor
                          author +
                          '~' + //author
                          rgb_dec565(colMediaArtist) +
                          '~' + //authorColor
                          volume +
                          '~' + //volume
                          iconplaypause +
                          '~' + //playpauseicon
                          onoffbutton +
                          '~' + //On/Off Button Color
                          shuffle_icon +
                          '~' + //iconShuffle                     --> Code
                          toolsString +
                          speakerListString +
                          playListString +
                          trackListString +
                          equalizerListString +
                          repeatButtonString,
                  });
              }
              if (Debug) {
                  log('GenerateMediaPage payload: ' + JSON.stringify(out_msgs), 'info');
              }
              return out_msgs;
          } catch (err: any) {
              log('error at function GenerateMediaPage: ' + err.message, 'warn');
              return [];
          }
      }
      

      Danke euch!

      1 Reply Last reply
      1

      Hello! It looks like you're interested in this conversation, but you don't have an account yet.

      Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

      With your input, this post could be even better 💗

      Register Login
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      Support us

      ioBroker
      Community Adapters
      Donate

      517

      Online

      32.8k

      Users

      82.9k

      Topics

      1.3m

      Posts
      Community
      Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen | Einwilligungseinstellungen
      ioBroker Community 2014-2025
      logo
      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Home
      • Recent
      • Tags
      • Unread 0
      • Categories
      • Unreplied
      • Popular
      • GitHub
      • Docu
      • Hilfe