Skip to content

Commit

Permalink
[volumio] Initial contribution (openhab#14525)
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Loercher <[email protected]>
  • Loading branch information
miloit authored and markus7017 committed Jul 8, 2023
1 parent 302f227 commit d26aeee
Show file tree
Hide file tree
Showing 20 changed files with 1,849 additions and 0 deletions.
1 change: 1 addition & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,7 @@
/bundles/org.openhab.binding.yamahareceiver/ @davidgraeff @zarusz
/bundles/org.openhab.binding.yeelight/ @claell
/bundles/org.openhab.binding.yioremote/ @miloit
/bundles/org.openhab.binding.volumio/ @miloit
/bundles/org.openhab.binding.zoneminder/ @mhilbush
/bundles/org.openhab.binding.zway/ @pathec
/bundles/org.openhab.io.homekit/ @andylintner @ccutrer @yfre
Expand Down
5 changes: 5 additions & 0 deletions bom/openhab-addons/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1841,6 +1841,11 @@
<artifactId>org.openhab.binding.volvooncall</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.binding.volumio</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.binding.warmup</artifactId>
Expand Down
13 changes: 13 additions & 0 deletions bundles/org.openhab.binding.volumio/NOTICE
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
This content is produced and maintained by the openHAB project.

* Project home: https://www.openhab.org

== Declared Project Licenses

This program and the accompanying materials are made available under the terms
of the Eclipse Public License 2.0 which is available at
https://www.eclipse.org/legal/epl-2.0/.

== Source Code

https://github.com/openhab/openhab-addons
101 changes: 101 additions & 0 deletions bundles/org.openhab.binding.volumio/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# Volumio Binding

This binding integrates the open-source Music Player [Volumio](https://www.volumio.com).

## Supported Things


All available Volumio (playback) modes are supported by this binding.

## Discovery

The Volumio devices are discovered through mDNS in the local network and all devices are put in the Inbox.


## Binding Configuration

The binding has the following configuration options, which can be set:

| Parameter | Name | Description | Required |
| ----------- | ---------------- | -------------------------------------------------------------------------- | -------- |
| hostname | Hostname | The hostname of the Volumio player. | yes |
| port | Port | The port of your volumio2 device (default is 3000) | yes |
| protocol | Protocol | The protocol of your volumio2 device (default is http) | yes |
| timeout | Timeout | Connection-Timeout in ms | no |


## Thing Configuration

The Volumio Thing requires the hostname, port and protocol as a configuration value in order for the binding to know how to access it.
Additionally, a connection timeout (in ms) can be configured.
In the thing file, this looks e.g. like

```java
Thing volumio:player:VolumioLivingRoom "Volumio" @ "Living Room" [hostname="volumio.local", protocol="http"]
```

### `sample` Thing Configuration

| Name | Type | Description | Default | Required | Advanced |
|-----------------|---------|---------------------------------------|---------|----------|----------|
| hostname | text | The hostname of the Volumio player. | N/A | yes | no |
| port | text | The port of your Volumio device. | 3000 | yes | no |
| protocol | text | The protocol of your Volumio device. | http | yes | no |
| timeout | integer | Connection-Timeout in ms. | 5000 | no | yes |

## Channels

The devices support the following channels:


| Channel | Type | Read/Write | Description |
|-------------------|--------|------------|----------------------------------------------------------------------------------------------------------------------|
| title | String | R | Title of the song currently playing. |
| artist | String | R | Name of the artist currently playing. |
| album | String | R | Name of the album currently playing. |
| volume | Dimmer | RW | Set or get the master volume. |
| player | Player | RW | The State channel contains state of the Volumio Player. |
| albumArt | Image | R | Cover Art for the currently played track. |
| track-type | String | R | Tracktype of the currently played track. |
| play-radiostream | String | RW | Play the given radio stream. |
| play-playlist | String | RW | Playback a playlist identified by its name. |
| clear-queue | Switch | RW | Clear the current queue. |
| play-uri | Switch | RW | Play the stream at given uri. |
| play-file | Switch | RW | Play a file, located on your Volumio device at the given absolute path, e.g."mnt/INTERNAL/song.mp3" |
| random | Switch | RW | Activate random mode. |
| repeat | Switch | RW | Activate repeat mode. |
| system-command | Switch | RW | Sends a system command to Volumio. This allows to shutdown/reboot Volumio. Use "Shutdown"/"Reboot" as String command.|
| stop-command | Switch | RW | Sends a Stop Command to Volumio. This allows to stop the player. Use "stop" as string command. |


## Full Example

demo.things:

```java
Thing volumio:player:VolumioLivingRoom "Volumio" @ "Living Room" [hostname="volumio.local", protocol="http"]
```

demo.items:

```java
String Volumio_CurrentTitle "Current Title [%s]" <musicnote> {channel="volumio:player:VolumioLivingRoom:title"}
String Volumio_CurrentArtist "Current Artist [%s]" {channel="volumio:player:VolumioLivingRoom:artist"}
String Volumio_CurrentAlbum "Current Album [%s]" {channel="volumio:player:VolumioLivingRoom:album"}
Dimmer Volumio_CurrentVolume "Current Volume [%.1f %%]" <soundvolume> {channel="volumio:player:VolumioLivingRoom:volume"}
Player Volumio "Current Status [%s]" <volumiologo> {channel="volumio:player:VolumioLivingRoom:player"}
String Volumio_CurrentTrackType "Current Track Type [%s]" <musicnote> {channel="volumio:player:VolumioLivingRoom:track-type"}
```

demo.sitemap:

```perl
sitemap demo label="Main Menu"
{
Frame label="Volumio" {
Slider item=Volumio_CurrentVolume
Text item=Volumio
Text item=Volumio_CurrentTitle
}
}
```
51 changes: 51 additions & 0 deletions bundles/org.openhab.binding.volumio/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.addons.reactor.bundles</artifactId>
<version>4.0.0-SNAPSHOT</version>
</parent>

<artifactId>org.openhab.binding.volumio</artifactId>

<name>openHAB Add-ons :: Bundles :: Volumio Binding</name>
<properties>
<bnd.importpackage>org.apache.http.*;io.socket.thread;io.socket.engineio.client;io.socket.emitter;android.*;resolution:=optional,com.android.org.*;resolution:=optional,dalvik.*;resolution:=optional,javax.annotation.meta.*;resolution:=optional,org.apache.harmony.*;resolution:=optional,org.conscrypt.*;resolution:=optional,sun.security.*;resolution:=optional</bnd.importpackage>
</properties>
<dependencies>
<dependency>
<groupId>org.openhab.osgiify</groupId>
<artifactId>io.socket.socket.io-client</artifactId>
<version>1.0.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.openhab.osgiify</groupId>
<artifactId>io.socket.engine.io-client</artifactId>
<version>1.0.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.servicemix.bundles</groupId>
<artifactId>org.apache.servicemix.bundles.okhttp</artifactId>
<version>3.8.1_1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.servicemix.bundles</groupId>
<artifactId>org.apache.servicemix.bundles.okio</artifactId>
<version>1.13.0_1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20230227</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<features name="org.openhab.binding.volumio-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.4.0">
<repository>mvn:org.openhab.core.features.karaf/org.openhab.core.features.karaf.openhab-core/${ohc.version}/xml/features</repository>

<feature name="openhab-binding-volumio" description="Volumio Binding" version="${project.version}">
<feature>openhab-runtime-base</feature>
<bundle start-level="80">mvn:org.openhab.addons.bundles/org.openhab.binding.volumio/${project.version}</bundle>
</feature>
</features>
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/**
* Copyright (c) 2010-2023 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.volumio.internal;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.core.thing.ThingTypeUID;

/**
* The {@link VolumioBindingConstants} class defines common constants, which are
* used across the whole binding.
*
* @author Patrick Sernetz - Initial Contribution
* @author Chris Wohlbrecht - Adaption for openHAB 3
* @author Michael Loercher - Adaption for openHAB 3
*/
@NonNullByDefault
public class VolumioBindingConstants {

private static final String BINDING_ID = "volumio";

// List of all Thing Type UIDs
public static final ThingTypeUID THING_TYPE_VOLUMIO = new ThingTypeUID(BINDING_ID, "player");

// List of all Channel ids
public static final String CHANNEL_TITLE = "title";
public static final String CHANNEL_ARTIST = "artist";
public static final String CHANNEL_ALBUM = "album";
public static final String CHANNEL_VOLUME = "volume";
public static final String CHANNEL_PLAYER = "player";
public static final String CHANNEL_COVER_ART = "album-art";
public static final String CHANNEL_TRACK_TYPE = "track-type";
public static final String CHANNEL_PLAY_RADIO_STREAM = "play-radiostream";
public static final String CHANNEL_PLAY_PLAYLIST = "play-playlist";
public static final String CHANNEL_CLEAR_QUEUE = "clear-queue";
public static final String CHANNEL_PLAY_RANDOM = "random";
public static final String CHANNEL_PLAY_REPEAT = "repeat";
public static final String CHANNEL_PLAY_URI = "play-uri";
public static final String CHANNEL_PLAY_FILE = "play-file";
public static final String CHANNEL_SYSTEM_COMMAND = "system-command";
public static final String CHANNEL_STOP = "stop-command";

// discovery properties
public static final String DISCOVERY_SERVICE_TYPE = "_Volumio._tcp.local.";
public static final String DISCOVERY_NAME_PROPERTY = "volumioName";
public static final String DISCOVERY_UUID_PROPERTY = "UUID";

// config
public static final String CONFIG_PROPERTY_HOSTNAME = "hostname";
public static final String CONFIG_PROPERTY_PORT = "port";
public static final String CONFIG_PROPERTY_PROTOCOL = "protocol";
public static final String CONFIG_PROPERTY_TIMEOUT = "timeout";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/**
* Copyright (c) 2010-2023 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.volumio.internal;

import org.eclipse.jdt.annotation.NonNullByDefault;

/**
* The {@link VolumioConfiguration} class contains fields mapping thing configuration parameters.
*
* @author Patrick Sernetz - Initial contribution
* @author Chris Wohlbrecht - Adapt for openHAB 3
* @author Michael Loercher - Adaption for openHAB 3
*/
@NonNullByDefault
public class VolumioConfiguration {

private String hostName = "";

private int port;

private String protocol = "";

private int timeout;

public String getHost() {
return hostName;
}

public void setHost(String host) {
this.hostName = host;
}

public int getPort() {
return port;
}

public void setPort(int port) {
this.port = port;
}

public String getProtocol() {
return protocol;
}

public void setProtocol(String protocol) {
this.protocol = protocol;
}

public int getTimeout() {
return timeout;
}

public void setTimeout(int timeout) {
this.timeout = timeout;
}
}
Loading

0 comments on commit d26aeee

Please sign in to comment.