]> git.basschouten.com Git - openhab-addons.git/blob
703e6283ce5f9cccb9d34bf19ca2ad994969c617
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
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
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.heos.internal.json.dto;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
17 import org.slf4j.Logger;
18 import org.slf4j.LoggerFactory;
19
20 /**
21  * Enum to reference the different HEOS events
22  *
23  * @author Martin van Wingerden - Initial contribution
24  */
25 @NonNullByDefault
26 public enum HeosEvent {
27     SOURCES_CHANGED,
28     PLAYERS_CHANGED,
29     GROUPS_CHANGED,
30     PLAYER_STATE_CHANGED,
31     PLAYER_NOW_PLAYING_CHANGED,
32     PLAYER_NOW_PLAYING_PROGRESS,
33     PLAYER_PLAYBACK_ERROR,
34     PLAYER_QUEUE_CHANGED,
35     PLAYER_VOLUME_CHANGED,
36     REPEAT_MODE_CHANGED,
37     SHUFFLE_MODE_CHANGED,
38     GROUP_VOLUME_CHANGED,
39     USER_CHANGED;
40
41     private static final Logger LOGGER = LoggerFactory.getLogger(HeosEvent.class);
42
43     @Nullable
44     public static HeosEvent valueOfString(@Nullable String eventCommand) {
45         if (eventCommand == null) {
46             return null;
47         }
48         try {
49             String command = eventCommand.substring(6);
50             return HeosEvent.valueOf(command.toUpperCase());
51         } catch (IllegalArgumentException e) {
52             LOGGER.debug("Unsupported event {}", eventCommand);
53             return null;
54         }
55     }
56 }