Skip to content

Commit

Permalink
Merge pull request #6 from patrickse/0.0.11
Browse files Browse the repository at this point in the history
0.0.11
  • Loading branch information
patrickse authored Nov 13, 2018
2 parents 9b2ac4a + d3e7c67 commit dd5d668
Show file tree
Hide file tree
Showing 17 changed files with 269 additions and 125 deletions.
21 changes: 13 additions & 8 deletions .classpath
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src/main/java"/>
<classpathentry kind="lib" path="lib/socket.io-client-0.8.1.jar"/>
<classpathentry kind="lib" path="lib/engine.io-client-0.8.1.jar"/>
<classpathentry kind="lib" path="lib/json-20090211.jar"/>
<classpathentry kind="lib" path="lib/okhttp-3.4.1.jar"/>
<classpathentry kind="lib" path="lib/okhttp-ws-3.4.1.jar"/>
<classpathentry kind="lib" path="lib/okio-1.9.0.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry exported="true" kind="lib" path="lib/socket.io-client-0.8.1.jar"/>
<classpathentry exported="true" kind="lib" path="lib/engine.io-client-0.8.1.jar"/>
<classpathentry exported="true" kind="lib" path="lib/json-20090211.jar"/>
<classpathentry exported="true" kind="lib" path="lib/okhttp-3.4.1.jar"/>
<classpathentry exported="true" kind="lib" path="lib/okhttp-ws-3.4.1.jar"/>
<classpathentry exported="true" kind="lib" path="lib/okio-1.9.0.jar"/>
<classpathentry exported="true" kind="con" path="GROOVY_DSL_SUPPORT"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
target/
**/*.DS_Store
bin/
.idea/
*.iml
7 changes: 7 additions & 0 deletions .project
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,15 @@
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.groovy.core.groovyNature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
Expand Down
2 changes: 2 additions & 0 deletions .settings/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/org.eclipse.core.resources.prefs
/org.eclipse.m2e.core.prefs
1 change: 1 addition & 0 deletions .settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.8
33 changes: 33 additions & 0 deletions ESH-INF/thing/thing-types.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
<channel id="playRadioStream" typeId="playRadioStream"/>
<channel id="playPlaylist" typeId="playPlaylist"/>
<channel id="clearQueue" typeId="clearQueue"/>
<channel id="playURI" typeId="playURI"/>
<channel id="playFile" typeId="playFile"/>
<channel id="random" typeId="playRandom"/>
<channel id="repeat" typeId="playRepeat"/>
</channels>
Expand All @@ -29,6 +31,26 @@
<label>Hostname</label>
<description>The hostname of your volumio2 device</description>
</parameter>
<parameter name="port" type="integer" required="true">
<label>Port</label>
<description>The port of your volumio2 device (default is 3000)</description>
<default>3000</default>
</parameter>
<parameter name="protocol" type="text" required="true">
<label>Protocol</label>
<description>The protocol of your volumio2 device (default is http)</description>
<limitToOptions>true</limitToOptions>
<options>
<option value="http">http</option>
<option value="https">https</option>
</options>
</parameter>
<parameter name="timeout" type="integer" required="true">
<label>Timeout</label>
<description>Connection-Timeout in ms</description>
<default>5000</default>
<advanced>true</advanced>
</parameter>
</config-description>

</thing-type>
Expand Down Expand Up @@ -113,5 +135,16 @@
<description>Activate repeat mode</description>
</channel-type>

<channel-type id="playURI" advanced="true">
<item-type>String</item-type>
<label>Play URI</label>
<description>Play the stream at given uri</description>
</channel-type>

<channel-type id="playFile" advanced="true">
<item-type>String</item-type>
<label>Play file</label>
<description>Play a file, located on your Volumio2 device at the given absolute path, e.g. "mnt/INTERNAL/song.mp3"</description>
</channel-type>

</thing:thing-descriptions>
9 changes: 4 additions & 5 deletions META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ Bundle-ManifestVersion: 2
Bundle-Name: volumio2 Binding
Bundle-SymbolicName: org.openhab.binding.volumio2;singleton:=true
Bundle-Vendor: openHAB
Bundle-Version: 2.0.0.qualifier
Bundle-Version: 2.1.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ClassPath: .,lib/socket.io-client-0.8.1.jar,lib/engine.io-client-0.8.1.jar,lib/json-20090211.jar,lib/okhttp-3.4.1.jar,lib/okhttp-ws-3.4.1.jar,lib/okio-1.9.0.jar
Export-Package: org.openhab.binding.volumio2,
org.openhab.binding.volumio2.handler
Import-Package:
javax.jmdns,
org.apache.commons.io,
Expand All @@ -26,9 +28,6 @@ Import-Package:
org.eclipse.smarthome.io.transport.mdns.discovery,
org.openhab.binding.volumio2,
org.openhab.binding.volumio2.handler,
org.osgi.framework;version="1.8.0",
org.osgi.framework,
org.slf4j
Service-Component: OSGI-INF/*.xml
Export-Package: org.openhab.binding.volumio2,
org.openhab.binding.volumio2.handler
Bundle-ActivationPolicy: lazy
28 changes: 25 additions & 3 deletions about.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,30 @@
</head>
<body lang="EN-US">
<h2>About This Content</h2>
<h3>Third Party Content</h3>
<ul>
</ul>

<p>September 20th, 2015</p>
<h3>License</h3>

<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
indicated below, the Content is provided to you under the terms and conditions of the
Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>

<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
apply to your use of any object code in the Content. Check the Redistributor's license that was
provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
indicated below, the terms and conditions of the EPL still apply to any source code in the Content
and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>

<pre>
engine.io-client - MIT - Copyright (c) 2014 Automattic, Inc.
socket.io-client - MIT - Copyright (c) 2014 Automattic, Inc.
okio - Apache License Version 2.0, January 2004
okhttp - Apache License Version 2.0, January 2004
json-20090211.jar - The JSON License
</pre>

</body>
</html>
8 changes: 7 additions & 1 deletion build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,10 @@ bin.includes = META-INF/,\
.,\
OSGI-INF/,\
ESH-INF/,\
lib/
lib/engine.io-client-0.8.1.jar,\
lib/json-20090211.jar,\
lib/okhttp-3.4.1.jar,\
lib/okhttp-ws-3.4.1.jar,\
lib/okio-1.9.0.jar,\
lib/socket.io-client-0.8.1.jar,\
about.html
4 changes: 1 addition & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@
<parent>
<groupId>org.openhab</groupId>
<artifactId>pom-tycho</artifactId>
<version>2.1.0-SNAPSHOT</version>
<version>2.1.0</version>
<relativePath></relativePath>
</parent>


<groupId>org.openhab.binding</groupId>
<artifactId>org.openhab.binding.volumio2</artifactId>
<version>2.1.0-SNAPSHOT</version>

<name>volumio2 Binding</name>
<packaging>eclipse-plugin</packaging>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ public class Volumio2BindingConstants {
public final static String CHANNEL_CLEAR_QUEUE = "clearQueue";
public final static String CHANNEL_PLAY_RANDOM = "random";
public final static String CHANNEL_PLAY_REPEAT = "repeat";
public final static String CHANNEL_PLAY_URI = "playURI";
public final static String CHANNEL_PLAY_FILE = "playFile";

// Discovery Properties

Expand All @@ -45,4 +47,8 @@ public class Volumio2BindingConstants {
// Config

public final static String CONFIG_PROPERTY_HOSTNAME = "hostname";
public final static String CONFIG_PROPERTY_PORT = "port";
public final static String CONFIG_PROPERTY_PROTOCOL = "protocol";
public final static String CONFIG_PROPERTY_TIMEOUT = "timeout";

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import static org.openhab.binding.volumio2.Volumio2BindingConstants.*;

import java.math.BigDecimal;
import java.util.concurrent.TimeUnit;

import org.eclipse.smarthome.core.library.types.NextPreviousType;
Expand Down Expand Up @@ -50,8 +51,6 @@ public class Volumio2Handler extends BaseThingHandler {
private Volumio2Service volumio;
private Volumio2Data state = new Volumio2Data();

private String hostname;

public Volumio2Service getVolumio() {
return volumio;
}
Expand Down Expand Up @@ -105,6 +104,20 @@ public void handleCommand(ChannelUID channelUID, Command command) {
}
break;

case CHANNEL_PLAY_URI:
if (command instanceof StringType) {
final String uri = ((StringType) command).toFullString();
volumio.replacePlay(uri, "URI", Volumio2ServiceTypes.WEBRADIO);
}
break;

case CHANNEL_PLAY_FILE:
if (command instanceof StringType) {
final String uri = ((StringType) command).toFullString();
volumio.replacePlay(uri, "", Volumio2ServiceTypes.MPD);
}
break;

case CHANNEL_PLAY_PLAYLIST:
if (command instanceof StringType) {
final String playlistName = ((StringType) command).toFullString();
Expand Down Expand Up @@ -237,18 +250,26 @@ private void bindDefaultListener() {
@Override
public void initialize() {

hostname = (String) getThing().getConfiguration().get(CONFIG_PROPERTY_HOSTNAME);
String hostname = (String) getThing().getConfiguration().get(CONFIG_PROPERTY_HOSTNAME);
int port = ((BigDecimal) getThing().getConfiguration().get(CONFIG_PROPERTY_PORT)).intValueExact();
String protocol = (String) getThing().getConfiguration().get(CONFIG_PROPERTY_PROTOCOL);
int timeout = ((BigDecimal) getThing().getConfiguration().get(CONFIG_PROPERTY_TIMEOUT)).intValueExact();

if (hostname == null) {

updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
"Configuration incomplete, missing hostname");

} else if (protocol == null) {

updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
"Configuration incomplete, missing protocol");

} else {

log.debug("Trying to connect to Volumio2 on {}", hostname);
log.debug("Trying to connect to Volumio2 on {}://{}:{}", protocol, hostname, port);
try {
volumio = new Volumio2Service(hostname);
volumio = new Volumio2Service(protocol, hostname, port, timeout);

clearChannels();
bindDefaultListener();
Expand Down Expand Up @@ -285,6 +306,15 @@ public void run() {
}
}

public void playURI(StringType url) {
log.debug("Play uri sound: {}", url.toFullString());
this.volumio.playURI(url.toFullString());
}

public void playNotificationSoundURI(StringType url) {
log.debug("Play notification sound: {}", url.toFullString());
}

/** Listener **/

/**
Expand Down
Loading

0 comments on commit dd5d668

Please sign in to comment.