Skip to content

Commit 7879da3

Browse files
stefanroellinmarkus7017
authored andcommitted
[mpd]: Music Player Daemon initial contribution (openhab#7870)
Signed-off-by: Stefan Roellin <[email protected]>
1 parent d2a6d60 commit 7879da3

29 files changed

+2031
-0
lines changed

CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@
206206
/bundles/org.openhab.binding.sonyprojector/ @lolodomo
207207
/bundles/org.openhab.binding.spotify/ @Hilbrand
208208
/bundles/org.openhab.binding.squeezebox/ @digitaldan @mhilbush
209+
/bundles/org.openhab.binding.mpd/ @stefanroellin
209210
/bundles/org.openhab.binding.synopanalyzer/ @clinique
210211
/bundles/org.openhab.binding.systeminfo/ @svilenvul
211212
/bundles/org.openhab.binding.tado/ @dfrommi

bom/openhab-addons/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,6 +1019,11 @@
10191019
<artifactId>org.openhab.binding.modbus.sunspec</artifactId>
10201020
<version>${project.version}</version>
10211021
</dependency>
1022+
<dependency>
1023+
<groupId>org.openhab.addons.bundles</groupId>
1024+
<artifactId>org.openhab.binding.mpd</artifactId>
1025+
<version>${project.version}</version>
1026+
</dependency>
10221027
<dependency>
10231028
<groupId>org.openhab.addons.bundles</groupId>
10241029
<artifactId>org.openhab.binding.synopanalyzer</artifactId>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" output="target/classes" path="src/main/java">
4+
<attributes>
5+
<attribute name="optional" value="true"/>
6+
<attribute name="maven.pomderived" value="true"/>
7+
</attributes>
8+
</classpathentry>
9+
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
10+
<attributes>
11+
<attribute name="maven.pomderived" value="true"/>
12+
</attributes>
13+
</classpathentry>
14+
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
15+
<attributes>
16+
<attribute name="optional" value="true"/>
17+
<attribute name="maven.pomderived" value="true"/>
18+
<attribute name="test" value="true"/>
19+
</attributes>
20+
</classpathentry>
21+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
22+
<attributes>
23+
<attribute name="maven.pomderived" value="true"/>
24+
</attributes>
25+
</classpathentry>
26+
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
27+
<attributes>
28+
<attribute name="maven.pomderived" value="true"/>
29+
</attributes>
30+
</classpathentry>
31+
<classpathentry kind="output" path="target/classes"/>
32+
</classpath>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>org.openhab.binding.mpd</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
<buildCommand>
14+
<name>org.eclipse.m2e.core.maven2Builder</name>
15+
<arguments>
16+
</arguments>
17+
</buildCommand>
18+
</buildSpec>
19+
<natures>
20+
<nature>org.eclipse.jdt.core.javanature</nature>
21+
<nature>org.eclipse.m2e.core.maven2Nature</nature>
22+
</natures>
23+
</projectDescription>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
This content is produced and maintained by the openHAB project.
2+
3+
* Project home: https://www.openhab.org
4+
5+
== Declared Project Licenses
6+
7+
This program and the accompanying materials are made available under the terms
8+
of the Eclipse Public License 2.0 which is available at
9+
https://www.eclipse.org/legal/epl-2.0/.
10+
11+
== Source Code
12+
13+
https://github.com/openhab/openhab-addons
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# MPD Binding
2+
3+
[Music Player Daemon (MPD)](http://www.musicpd.org/) is a flexible, powerful, server-side application for playing music. Through plugins and libraries it can play a variety of sound files while being controlled by its network protocol.
4+
5+
With the openHAB MPD binding you can control Music Player Daemons.
6+
7+
8+
## Supported Things
9+
10+
This binding supports one ThingType: mpd
11+
12+
## Discovery
13+
14+
If zeroconf is enabled in the Music Player Daemon, it is discovered. Each Music Player daemon requires a unique zeroconf_name for correct discovery.
15+
16+
17+
## Thing Configuration
18+
19+
The ThingType mpd requires the following configuration parameters:
20+
21+
| Parameter Label | Parameter ID | Description | Required |
22+
|-----------------|--------------|--------------------------------------------------------------------------|----------|
23+
| IP Address | ipAddress | Host name or IP address of the Music Player Daemon | yes |
24+
| Port | port | Port number on which the Music Player Daemon is listening. Default: 6600 | yes |
25+
| Password | password | Password to access the Music Player Daemon | no |
26+
27+
28+
## Channels
29+
30+
The following channels are currently available:
31+
32+
| Channel Type ID | Item Type | Description |
33+
|-----------------|-----------|---------------------------|
34+
| control | Player | Start/Pause/Next/Previous |
35+
| volume | Dimmer | Volume in percent |
36+
| stop | Switch | Stop playback |
37+
| currentalbum | String | Current album |
38+
| currentartist | String | Current artist |
39+
| currentname | String | Current name |
40+
| currentsong | Number | Current song |
41+
| currentsongid | Number | Current song id |
42+
| currenttitle | String | Current title |
43+
| currenttrack | Number | Current track |
44+
45+
46+
## Full Example
47+
48+
#### Thing
49+
50+
```
51+
mpd:mpd:music [ ipAddress="192.168.1.2", port=6600 ]
52+
```
53+
54+
#### Items
55+
56+
```
57+
Switch morning_music "Morning music"
58+
59+
Player mpd_music_player "Player" { channel = "mpd:mpd:music:control" }
60+
Dimmer mpd_music_volume "Volume [%d %%]" { channel = "mpd:mpd:music:volume" }
61+
Switch mpd_music_stop "Stop" { channel = "mpd:mpd:music:stop" }
62+
String mpd_music_album "Album [%s]" { channel = "mpd:mpd:music:currentalbum" }
63+
String mpd_music_artist "Artist [%s]" { channel = "mpd:mpd:music:currentartist" }
64+
String mpd_music_name "Name [%s]" { channel = "mpd:mpd:music:currentname" }
65+
Number mpd_music_song "Song [%d]" { channel = "mpd:mpd:music:currentsong" }
66+
Number mpd_music_song_id "Song Id [%d]" { channel = "mpd:mpd:music:currentsongid" }
67+
String mpd_music_title "Title [%s]" { channel = "mpd:mpd:music:currenttitle" }
68+
Number mpd_music_track "Track [%d]" { channel = "mpd:mpd:music:currenttrack" }
69+
```
70+
71+
#### Sitemap
72+
73+
```
74+
Frame label="Music" {
75+
Default item=mpd_music_player
76+
Slider item=mpd_music_volume
77+
Switch item=mpd_music_stop
78+
Text item=mpd_music_album
79+
Text item=mpd_music_artist
80+
Text item=mpd_music_name
81+
Text item=mpd_music_song
82+
Text item=mpd_music_song_id
83+
Text item=mpd_music_title
84+
Text item=mpd_music_track
85+
}
86+
```
87+
88+
#### Rule
89+
90+
```
91+
rule "turn on morning music"
92+
when
93+
Item morning_music changed to ON
94+
then
95+
val actions = getActions("mpd","mpd:mpd:music")
96+
if(actions === null) {
97+
logWarn("myLog", "actions is null")
98+
return
99+
}
100+
101+
actions.sendCommand("clear")
102+
actions.sendCommand("load", "MorningMusic");
103+
actions.sendCommand("shuffle");
104+
actions.sendCommand("play");
105+
end
106+
```
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<parent>
8+
<groupId>org.openhab.addons.bundles</groupId>
9+
<artifactId>org.openhab.addons.reactor.bundles</artifactId>
10+
<version>2.5.8-SNAPSHOT</version>
11+
</parent>
12+
13+
<artifactId>org.openhab.binding.mpd</artifactId>
14+
15+
<name>openHAB Add-ons :: Bundles :: MPD Binding</name>
16+
17+
</project>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<features name="org.openhab.binding.mpd-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.4.0">
3+
<repository>mvn:org.openhab.core.features.karaf/org.openhab.core.features.karaf.openhab-core/${ohc.version}/xml/features</repository>
4+
5+
<feature name="openhab-binding-mpd" description="MPD Binding" version="${project.version}">
6+
<feature>openhab-runtime-base</feature>
7+
<bundle start-level="80">mvn:org.openhab.addons.bundles/org.openhab.binding.mpd/${project.version}</bundle>
8+
</feature>
9+
</features>
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/**
2+
* Copyright (c) 2010-2020 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.mpd.internal;
14+
15+
import org.eclipse.jdt.annotation.NonNullByDefault;
16+
import org.eclipse.smarthome.core.thing.ThingTypeUID;
17+
18+
/**
19+
* The {@link MPDBindingConstants} class defines common constants, which are
20+
* used across the whole binding.
21+
*
22+
* @author Stefan Röllin - Initial contribution
23+
*/
24+
@NonNullByDefault
25+
public class MPDBindingConstants {
26+
27+
private static final String BINDING_ID = "mpd";
28+
29+
// List of all Thing Type UIDs
30+
public static final ThingTypeUID THING_TYPE_MPD = new ThingTypeUID(BINDING_ID, "mpd");
31+
32+
// List of all Channel ids
33+
public static final String CHANNEL_CONTROL = "control";
34+
public static final String CHANNEL_CURRENT_ALBUM = "currentalbum";
35+
public static final String CHANNEL_CURRENT_ARTIST = "currentartist";
36+
public static final String CHANNEL_CURRENT_NAME = "currentname";
37+
public static final String CHANNEL_CURRENT_SONG = "currentsong";
38+
public static final String CHANNEL_CURRENT_SONG_ID = "currentsongid";
39+
public static final String CHANNEL_CURRENT_TITLE = "currenttitle";
40+
public static final String CHANNEL_CURRENT_TRACK = "currenttrack";
41+
public static final String CHANNEL_STOP = "stop";
42+
public static final String CHANNEL_VOLUME = "volume";
43+
44+
// Config Parameters
45+
public static final String PARAMETER_IPADDRESS = "ipAddress";
46+
public static final String PARAMETER_PORT = "port";
47+
public static final String UNIQUE_ID = "uniqueId";
48+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/**
2+
* Copyright (c) 2010-2020 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.mpd.internal;
14+
15+
import org.eclipse.jdt.annotation.NonNullByDefault;
16+
17+
/**
18+
* The {@link MPDConfiguration} class contains fields mapping thing configuration parameters.
19+
*
20+
* @author Stefan Röllin - Initial contribution
21+
*/
22+
@NonNullByDefault
23+
public class MPDConfiguration {
24+
25+
private String ipAddress = "";
26+
private Integer port = 0;
27+
private String password = "";
28+
29+
public String getIpAddress() {
30+
return ipAddress;
31+
}
32+
33+
public void setIpAddress(String ipAddress) {
34+
this.ipAddress = ipAddress;
35+
}
36+
37+
public Integer getPort() {
38+
return port;
39+
}
40+
41+
public void setPort(Integer port) {
42+
this.port = port;
43+
}
44+
45+
public String getPassword() {
46+
return password;
47+
}
48+
49+
public void setPassword(String password) {
50+
this.password = password;
51+
}
52+
}

0 commit comments

Comments
 (0)