2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.heos.internal.handler;
15 import static org.openhab.binding.heos.internal.HeosBindingConstants.CH_ID_QUEUE;
17 import java.io.IOException;
19 import org.eclipse.jdt.annotation.NonNullByDefault;
20 import org.eclipse.jdt.annotation.Nullable;
21 import org.openhab.binding.heos.internal.exception.HeosNotFoundException;
22 import org.openhab.binding.heos.internal.resources.Telnet.ReadException;
23 import org.openhab.core.thing.ChannelUID;
24 import org.openhab.core.thing.ThingUID;
25 import org.openhab.core.types.Command;
26 import org.openhab.core.types.RefreshType;
29 * The {@link HeosChannelHandlerFavorite} handles the playlist selection channel command
30 * from the implementing thing.
32 * @author Johannes Einig - Initial contribution
35 public class HeosChannelHandlerQueue extends BaseHeosChannelHandler {
36 private final HeosDynamicStateDescriptionProvider heosDynamicStateDescriptionProvider;
38 public HeosChannelHandlerQueue(HeosDynamicStateDescriptionProvider heosDynamicStateDescriptionProvider,
39 HeosBridgeHandler bridge) {
41 this.heosDynamicStateDescriptionProvider = heosDynamicStateDescriptionProvider;
45 public void handlePlayerCommand(Command command, String id, ThingUID uid) throws IOException, ReadException {
46 handleCommand(command, id, uid);
50 public void handleGroupCommand(Command command, @Nullable String id, ThingUID uid,
51 HeosGroupHandler heosGroupHandler) throws IOException, ReadException {
53 throw new HeosNotFoundException();
56 handleCommand(command, id, uid);
60 public void handleBridgeCommand(Command command, ThingUID uid) {
64 private void handleCommand(Command command, String id, ThingUID uid) throws IOException, ReadException {
65 ChannelUID channelUID = new ChannelUID(uid, CH_ID_QUEUE);
66 if (command instanceof RefreshType) {
67 heosDynamicStateDescriptionProvider.setQueue(channelUID, getApi().getQueue(id));
71 String idCommand = heosDynamicStateDescriptionProvider.getValueByLabel(channelUID, command.toString());
72 getApi().playMediaFromQueue(id, idCommand);