Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial commit of the kodi binding #1262

Merged
merged 25 commits into from
Dec 27, 2016
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
b46ec8c
Initial commit of the kodi binding
pail23 Sep 26, 2016
bc68921
Initial commit of the kodi binding
pail23 Sep 26, 2016
b995fbf
first version of AudioSink
pail23 Oct 12, 2016
fdc200d
fixes
pail23 Oct 13, 2016
72cb474
fixes
pail23 Oct 29, 2016
83ad75e
audio sink fixes
pail23 Oct 29, 2016
ef5bbd0
Merge branch 'master' of https://github.com/openhab/openhab2-addons i…
pail23 Nov 21, 2016
7fa15f0
- Migrated to jetty websocket
pail23 Nov 23, 2016
68eacc1
Merge branch 'master' of https://github.com/openhab/openhab2-addons i…
pail23 Nov 23, 2016
91fc7f7
merge upstream
pail23 Nov 23, 2016
ecb651a
Merge branch 'master' of https://github.com/openhab/openhab2-addons i…
pail23 Nov 25, 2016
59f1640
Fixed review comments
pail23 Nov 28, 2016
a8dfa6f
Merge branch 'master' of https://github.com/openhab/openhab2-addons i…
pail23 Dec 4, 2016
1ada508
- Adapted according review comments from Kai
pail23 Dec 6, 2016
7fed57e
Removed a comment according a review finding
pail23 Dec 6, 2016
f6aa55c
update ohdr version to 1.0.8
pail23 Dec 8, 2016
37154e1
Changed encoding of the kode_de.properties file to UTF8
pail23 Dec 10, 2016
530e742
reverted change to UTF8
pail23 Dec 11, 2016
a6f3e1b
Small typo fix
pail23 Dec 11, 2016
ef14153
- fixed Umlaut
pail23 Dec 14, 2016
1824c28
improved documentation
pail23 Dec 14, 2016
7cb54c0
- updated documentation based on the proposal from @ThomDietrich
pail23 Dec 21, 2016
14cebf0
merge upstream
pail23 Dec 23, 2016
bbecdab
Read show title from kodi and add it to the title channel if available
pail23 Dec 23, 2016
49ba238
- Added ShowTitle as a seperate channel
pail23 Dec 27, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions addons/binding/org.openhab.binding.kodi/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src/main/java"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
33 changes: 33 additions & 0 deletions addons/binding/org.openhab.binding.kodi/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.openhab.binding.kodi</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ds.core.builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<binding:binding id="kodi"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:binding="http://eclipse.org/smarthome/schemas/binding/v1.0.0"
xsi:schemaLocation="http://eclipse.org/smarthome/schemas/binding/v1.0.0 http://eclipse.org/smarthome/schemas/binding-1.0.0.xsd">

<name>Kodi Binding</name>
<description>This is the binding for Kodi.</description>
<author>Paul Frank</author>

<config-description>
<parameter name="callbackUrl" type="text">
<label>Callback URL</label>
<description>url to use for playing notification sounds, e.g. http://192.168.0.2:8080</description>
<required>false</required>
</parameter>
</config-description>
</binding:binding>
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# binding
binding.kodi.name = Kodi Binding
binding.kodi.description = Das Kodi Binding erlaubt das Kodi Media Center zu steuern

# thing types
thing-type.kodi.kodi.label = Kodi Media Center
thing-type.kodi.kodi.description = Kodi Media Center Binding
thing-type.config.kodi.kodi.ipAddress.label = Netzwerkaddresse
thing-type.config.kodi.kodi.ipAddress.description = IP Addresse oder Host Name des Kodi Media Centers
thing-type.config.kodi.kodi.port.label = Port
thing-type.config.kodi.kodi.port.description = Port des Web Socket Services des Kodi Media Centers

# channel types
channel-type.kodi.volume.label = Lautst�rke
channel-type.kodi.volume.description = Lautst�rke des Kodi Media Centers
channel-type.kodi.mute.label = Stumm schalten
channel-type.kodi.mute.description = Das Kodi Media Centers stumm schalten
channel-type.kodi.control.label = Kontrolle
channel-type.kodi.control.description = Steuert das Kodi Media Center (z.B. Play, Pause, Stop)
channel-type.kodi.playuri.label = URI abspielen
channel-type.kodi.playuri.description = Spielt einen URI ab
channel-type.kodi.shownotification.label = Nachricht anzeigen
channel-type.kodi.shownotification.description = Zeigt eine Nachricht auf dem Bildschirm an
channel-type.kodi.input.label = Tastendruck
channel-type.kodi.input.description = Schickt einen Tastendruck an das Kodi Media Center um auf dem Bildschirm zu navigieren
channel-type.kodi.inputtext.label = Texteingabe
channel-type.kodi.inputtext.description = Schickt eine Zeichenkette als Eingabe an das Kodi Media Center
channel-type.kodi.title.label = Titel
channel-type.kodi.title.description = Titel des aktuellen St�cks oder Films
channel-type.kodi.title.label = Titel
channel-type.kodi.title.description = Titel des aktuellen St�cks oder Films
channel-type.kodi.album.label = Album
channel-type.kodi.album.description = Album des aktuellen St�cks
channel-type.kodi.artist.label = K�nstler
Copy link
Contributor

@MHerbst MHerbst Dec 10, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have stored the file with text encoding ISO 8859-1. As a result the german "umlauts" do not appear correctly (in Chrome on Windows) neither in Paper UI nor in Basic UI. I have changed the encoding to UTF-8 and corrected the "umlauts". Then everything looked fine.
@kaikreuzer I have tried to find a hint on the correct encoding in the developer documentation for Smarthome and openHAB but without success . Java sources and XML files are all using UTF-8 but all properties files in the openHAB repository that I have checked were using encoding ISO 8859-1.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the meantime I have created an issue in the Smarthome repository (eclipse-archived/smarthome#2639) because other bindings have the same problem.

channel-type.kodi.artist.description = K�nstler des aktuellen St�cks oder Films
channel-type.kodi.mediatype.label = Medientyp
channel-type.kodi.mediatype.description = Medientyp des aktuellen St�cks oder Films (z. B. movie, song)

124 changes: 124 additions & 0 deletions addons/binding/org.openhab.binding.kodi/ESH-INF/thing/thing-types.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="kodi" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:thing="http://eclipse.org/smarthome/schemas/thing-description/v1.0.0"
xsi:schemaLocation="http://eclipse.org/smarthome/schemas/thing-description/v1.0.0 http://eclipse.org/smarthome/schemas/thing-description-1.0.0.xsd">

<!-- Kodi Thing Type -->
<thing-type id="kodi">
<label>Kodi Mediacenter</label>
<description>Kodi Mediacenter Binding</description>

<channels>
<channel id="volume" typeId="volume" />
<channel id="mute" typeId="mute" />
<channel id="control" typeId="control" />
<channel id="playuri" typeId="playuri" />
<channel id="shownotification" typeId="shownotification" />
<channel id="input" typeId="input" />
<channel id="inputtext" typeId="inputtext" />
<channel id="title" typeId="title" />
<channel id="album" typeId="album" />
<channel id="artist" typeId="artist" />
<channel id="mediatype" typeId="mediatype" />
</channels>

<properties>
<property name="version">unknown</property>
</properties>

<config-description>
<parameter name="ipAddress" type="text" required="true">
<label>Network Address</label>
<description>The IP or host name of the kodi</description>
<context>network-address</context>
</parameter>
<parameter name="port" type="integer" required="true" min="1" max="65335">
<label>Web socket service port</label>
<description>Port for the web socket service</description>
<default>9090</default>
</parameter>
</config-description>
</thing-type>

<!-- Kodi Commands -->
<channel-type id="mute">
<item-type>Switch</item-type>
<label>Mute</label>
<description>Mute/unmute your device</description>
</channel-type>
<channel-type id="volume">
<item-type>Dimmer</item-type>
<label>Volume</label>
<description>Volume of your device</description>
<state min="0" max="100" step="1" pattern="%d %%">
</state>
</channel-type>
<channel-type id="control">
<item-type>Player</item-type>
<label>Control</label>
<description>Control the Kodi Player, e.g. start/stop/next/previous/ffward/rewind</description>
<category>Player</category>
</channel-type>
<channel-type id="playuri" advanced="true">
<item-type>String</item-type>
<label>Play URI</label>
<description>Play the given URI</description>
</channel-type>
<channel-type id="shownotification" advanced="true">
<item-type>String</item-type>
<label>Show Notification</label>
<description>Shows a notification on the UI</description>
</channel-type>
<channel-type id="input" advanced="true">
<item-type>String</item-type>
<label>Send a key</label>
<description>Sends a key stroke to the Kodi Player to navigate in the UI</description>
<state>
<options>
<option value="Left">Left</option>
<option value="Right">Right</option>
<option value="Up">Up</option>
<option value="Down">Down</option>
<option value="Select">Select</option>
<option value="Back">Back</option>
<option value="Home">Home</option>
<option value="ContextMenu">Context Menu</option>
<option value="Info">Info</option>
<option value="ShowCodec">Show Codec</option>
<option value="ShowOSD">Show OSD</option>
</options>
</state>
</channel-type>
<channel-type id="inputtext" advanced="true">
<item-type>String</item-type>
<label>Sends text as input</label>
<description>Sends a text to the Kodi Player to simulate keyboard text entry</description>
</channel-type>


<!-- Kodi variables -->
<channel-type id="title">
<item-type>String</item-type>
<label>Title</label>
<description>Title of the current song</description>
<state readOnly="true" pattern="%s"></state>
</channel-type>
<channel-type id="album">
<item-type>String</item-type>
<label>Album</label>
<description>Album name of the current song</description>
<state readOnly="true" pattern="%s"></state>
</channel-type>
<channel-type id="artist">
<item-type>String</item-type>
<label>Artist</label>
<description>Artist name of the current song</description>
<state readOnly="true" pattern="%s"></state>
</channel-type>
<channel-type id="mediatype">
<item-type>String</item-type>
<label>Media Type</label>
<description>Media type of the current file</description>
<state readOnly="true" pattern="%s"></state>
</channel-type>
</thing:thing-descriptions>
38 changes: 38 additions & 0 deletions addons/binding/org.openhab.binding.kodi/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Kodi Binding
Bundle-SymbolicName: org.openhab.binding.kodi;singleton:=true
Bundle-Vendor: openHAB
Bundle-Version: 2.0.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Bundle-ClassPath: .
Import-Package:
com.google.common.base,
com.google.common.collect,
com.google.gson,
org.apache.commons.lang,
org.eclipse.jetty.util.component,
org.eclipse.jetty.websocket.api,
org.eclipse.jetty.websocket.api.annotations,
org.eclipse.jetty.websocket.client,
org.eclipse.jetty.websocket.common,
org.eclipse.smarthome.config.core,
org.eclipse.smarthome.config.discovery,
org.eclipse.smarthome.core.audio,
org.eclipse.smarthome.core.library.types,
org.eclipse.smarthome.core.thing,
org.eclipse.smarthome.core.thing.binding,
org.eclipse.smarthome.core.thing.binding.builder,
org.eclipse.smarthome.core.thing.type,
org.eclipse.smarthome.core.types,
org.jupnp.model.meta,
org.jupnp.model.types,
org.openhab.binding.kodi,
org.openhab.binding.kodi.handler,
org.osgi.framework,
org.osgi.service.component,
org.slf4j
Service-Component: OSGI-INF/*.xml
Export-Package: org.openhab.binding.kodi,
org.openhab.binding.kodi.handler

17 changes: 17 additions & 0 deletions addons/binding/org.openhab.binding.kodi/OSGI-INF/KodiDiscovery.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

Copyright (c) 2014-2015 openHAB UG (haftungsbeschraenkt) and others.

All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License v1.0
which accompanies this distribution, and is available at
http://www.eclipse.org/legal/epl-v10.html

-->
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" immediate="true" name="org.openhab.onkyo" activate="activate">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

org.openhab.onkyo -> org.openhab.kodi

<implementation class="org.openhab.binding.kodi.internal.discovery.KodiDiscoveryParticipant"/>
<service>
<provide interface="org.eclipse.smarthome.config.discovery.UpnpDiscoveryParticipant"/>
</service>
</scr:component>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2014-2016 by the respective copyright holders.
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License v1.0
which accompanies this distribution, and is available at
http://www.eclipse.org/legal/epl-v10.html
-->
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" configuration-policy="optional" immediate="true" name="binding.kodi">

<implementation class="org.openhab.binding.kodi.internal.KodiHandlerFactory"/>

<service>
<provide interface="org.eclipse.smarthome.core.thing.binding.ThingHandlerFactory"/>
</service>
<reference bind="setAudioHTTPServer" cardinality="1..1" interface="org.eclipse.smarthome.core.audio.AudioHTTPServer" name="AudioHTTPServer" policy="static" unbind="unsetAudioHTTPServer"/>
</scr:component>
64 changes: 64 additions & 0 deletions addons/binding/org.openhab.binding.kodi/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Kodi Binding

This binding integrates the Kodi players (which used to be XBMC).

## Introduction


## Supported Things

This binding supports only one thing: The Kodi player. All kodi devices are registered as an audio sink in the framework.


## Discovery

This binding can discover the Kodi players.

## Binding Configuration

The binding can auto-discover the Kodi players present on your local network. The auto-discovery is enabled by default. To disable it, you can create a file in the services directory called Kodi.cfg with the following content:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line should actually be in the "Discovery" section. And no need to create a Kodi.cfg file; instead, the line should be added to conf/services/runtime.cfg.


```
org.openhab.Kodi:enableAutoDiscovery=false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

org.openhab.Kodi -> org.openhab.kodi

```

This configuration parameter only controls the Kodi player auto-discovery process, not the openHAB auto-discovery. Moreover, if the openHAB auto-discovery is disabled, the Kodi player auto-discovery is disabled too.

The binding has the following configuration option, which can be set for "binding:kodi":

| Parameter | Name | Description | Required |
|-----------------|------------------------|--------------|------------ |
| callbackUrl | Callback URL | URL to use for playing notification sounds, e.g. http://192.168.0.2:8080 | no |


## Thing Configuration

The Kodi player thing requires the ip address and the port to access it on.
In the thing file, this looks e.g. like
```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add an empty line above code sections as otherwise Jekyll breaks the layout.

Kodi:Kodi:myKodi [ipAddress="192.168.1.100", port="9090"]

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are missing the closing ``` here.


##Channels
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

## Channels


The Kodi thing supports the following channels:

| Channel Type ID | Item Type | Description |
|-------------------------|--------------|--------------|
| mute | Switch | Mute/unmute your device |
| volume | Dimmer | Volume of your device |
| control | Player | Control the Kodi player, e.g. play/pause/next/previous/ffward/rewind |
| title | String | Title of the current song|
| album | String | Album name of the current song|
| artist | String | Artist name of the current song|
| playuri | String | Plays the file with the provided URI|
| shownotification | String | Shows the provided notification message on the screen|
| input | String | Allows to navigate on the screen. Valid values are: Up, Down, Left, Right, Select, Back, Home, ContextMenu, Info, ShowCodec, ShowOSD|
| inputtext | String | This channel emulates the keyboard entry|
| mediatype | String | The media type of the current file. e.g. song, movie|


## Audio Support

All supported kodi devices are registered as an audio sink in the framework.
Audio streams are sent to the `playuri` channel.
8 changes: 8 additions & 0 deletions addons/binding/org.openhab.binding.kodi/build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
source.. = src/main/java/
output.. = target/classes
bin.includes = META-INF/,\
.,\
OSGI-INF/,\
ESH-INF/


21 changes: 21 additions & 0 deletions addons/binding/org.openhab.binding.kodi/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?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 http://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>


<parent>
<groupId>org.openhab.binding</groupId>
<artifactId>pom</artifactId>
<version>2.0.0-SNAPSHOT</version>
</parent>


<groupId>org.openhab.binding</groupId>
<artifactId>org.openhab.binding.kodi</artifactId>
<version>2.0.0-SNAPSHOT</version>

<name>Kodi Binding</name>
<packaging>eclipse-plugin</packaging>
</project>
Loading