|
| 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 | +``` |
0 commit comments