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.mpd.internal.protocol;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.slf4j.Logger;
19 import org.slf4j.LoggerFactory;
22 * Class for representing the status of a Music Player Daemon.
24 * @author Stefan Röllin - Initial contribution
27 public class MPDStatus {
35 private final Logger logger = LoggerFactory.getLogger(MPDStatus.class);
37 private final State state;
38 private final int volume;
40 public MPDStatus(MPDResponse response) {
41 Map<String, String> values = MPDResponseParser.responseToMap(response);
42 state = parseState(values.getOrDefault("state", ""));
43 volume = parseVolume(values.getOrDefault("volume", "0"));
46 public State getState() {
50 public int getVolume() {
54 private State parseState(String value) {
67 private int parseVolume(String value) {
69 return Integer.parseInt(value);
70 } catch (NumberFormatException e) {
71 logger.debug("parseVolume of {} failed", value);