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

[WIP][emby] Initial Contribution #7575

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
32 changes: 32 additions & 0 deletions bundles/org.openhab.binding.emby/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<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.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
23 changes: 23 additions & 0 deletions bundles/org.openhab.binding.emby/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.openhab.binding.emby</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>
13 changes: 13 additions & 0 deletions bundles/org.openhab.binding.emby/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
69 changes: 69 additions & 0 deletions bundles/org.openhab.binding.emby/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Emby Binding

The Emby Binding integrates EMBY support with openHAB, allowing both controlling the player as well as retrieving player status data like the currently played movie title.

This binding supports multiple clients connected to a EMBY Media Server. This binding allows simlar integration and control in the same manner as the Plex Binding. For example with this binding, it's possible to dim your lights when a video starts playing.

## Supported Things

_Please describe the different supported things / devices within this section._
_Which different types are supported, which models were tested etc.?_
_Note that it is planned to generate some part of this based on the XML files within ```ESH-INF/thing``` of your binding._
Comment on lines +9 to +11
Copy link
Member

Choose a reason for hiding this comment

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

Can you mention the Thing Type IDs?


## Discovery

The binding will autodiscover all clients which are conneted to your EMBY media server. These clients will be added to the inbox after the first time they come online and begin playing media. This however only works once a connection to an EMBY media server has been established by creating the bridge thing type for the EMBY media server.


## Thing Configuration

There are two types of things for this binding. The bridge type and the device. The bridge must be created before any device types will be generated.

The bridge should be configured as follows:

| Parameter | Description |
|---------|----------------------------------------------------------|
| API Key | This is the API key generated from EMBY used for Authorization. (Generated from your emby server at Dashboard -> Expert -> Advanced -> Security) |
| Web Socket Buffer Size | Here you can define a custom size for the websocket buffer size. Default is 100000. Increasing this can descrease server timeouts in certain cases |
Copy link
Member

Choose a reason for hiding this comment

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

When do the user need to change this? Under which circumstances are the timeouts too high?

| ipAddress | This is the ip address of the EMBY Server. |
| Port | This is the port of the EMBY server. |
| Refresh Parameter | This is the refresh interval in milliseconds that will be sent to the websocket. |

## Channels

An emby device that is automatically discovered will come with several preconfigured channels:

| Channel Type | Item Type | Config Parameters | Description |
|--------------|----------------------|----------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Control | Player | None | This channel will indicate the playing status of the device. It can also be used to send play/pause commands |
| Stop | Switch | None | This channel will indicate whether there is media currently playing on the device. When media is playing the channel will indicate ON. Sending a command of OFF to the channel will send a command to stop any currently playing media. |
| Title | String | None | Will show the title of the currently playing song |
| Mute | Switch | None | Indicates whether the device is muted. Sending a command of ON will send a mute command to the currently playing media. |
| ShowTitle | String | None | Will show the title of the currently playing movie or TV show. |
| Image URL | String | Image Max Height
Image Max Width
Image Type
Percent Played | This will produce a URL to the currently playing media. More information about the config parameters can be found at https://github.com/MediaBrowser/Emby/wiki/Images. |
Comment on lines +43 to +46
Copy link
Member

Choose a reason for hiding this comment

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

Multiline rows are not supported, at least by the Github markdown renderer. Can you mention the exact names of the config parameters?

| Current Time | Number:Time | None | The current play time of the playing media. |
| Duration | Number:Time | None | The length of time left in the current playing media item. |
| Media Type | String | None | Description |
| Send Play | String | None | Description |
Comment on lines +49 to +50
Copy link
Member

Choose a reason for hiding this comment

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

This is WIP?



## Full Example

*.things
*.items
String EMBYWMCPosterImage_URL "URL: [%s]" (EMBY) {channel="emby:device:416bcb51:d96138c30b0b404cba7513ae09db7966:imageurl"}
String EMBYWMCTVStatus "Status [%s]" <video> (EMBY)
Switch EMBYWMC_HTPC_Stop (EMBY,EMBY_HTPC_Stop){channel="emby:device:416bcb51:d96138c30b0b404cba7513ae09db7966:stop"}
String EMBYWMCItemPlayed "[%s]" (EMBY) {channel="emby:device:416bcb51:d96138c30b0b404cba7513ae09db7966:showtitle" }
Switch EMBYWMC_IsMute (EMBY, EMBY_IsMute){channel="emby:device:416bcb51:d96138c30b0b404cba7513ae09db7966:mute"}
Player EMBYWMC_Player (EMBY) {channel="emby:device:416bcb51:d96138c30b0b404cba7513ae09db7966:control"}

*.sitemap
Image item=EMBYWMCPosterImage_URL label=""




16 changes: 16 additions & 0 deletions bundles/org.openhab.binding.emby/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?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/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>2.5.5-SNAPSHOT</version>
</parent>

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

<name>openHAB Add-ons :: Bundles :: Emby Binding</name>

</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.emby-${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-emby" description="Emby Binding" version="${project.version}">
<feature>openhab-runtime-base</feature>
<bundle start-level="80">mvn:org.openhab.addons.bundles/org.openhab.binding.emby/${project.version}</bundle>
</feature>
</features>
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/**
* Copyright (c) 2010-2020 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.emby.internal;

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

/**
* The {@link EmbyBindingConstants} class defines common constants, which are
* used across the whole binding.
*
* @author Zachary Christiansen - Initial contribution
*/
@NonNullByDefault
public class EmbyBindingConstants {

private static final String BINDING_ID = "emby";

// List of all Thing Type UIDs
public static final ThingTypeUID THING_TYPE_EMBY_CONTROLLER = new ThingTypeUID(BINDING_ID, "controller");
public static final ThingTypeUID THING_TYPE_EMBY_DEVICE = new ThingTypeUID(BINDING_ID, "device");

// List of all Channel ids
public static final String CHANNEL_MUTE = "mute";
public static final String CHANNEL_VOLUME = "volume";
public static final String CHANNEL_STOP = "stop";
public static final String CHANNEL_CONTROL = "control";
public static final String CHANNEL_SENDPLAYCOMMAND = "sendplay";
public static final String CHANNEL_GENERALCOMMAND = "generalCommand";
public static final String CHANNEL_GENERALCOMMANDWITHARGS = "generalCommand_withArguments";

public static final String CHANNEL_GENERALCOMMAND_NAME = "generalCommand_CommandName";

public static final String CHANNEL_TITLE = "title";
public static final String CHANNEL_SHOWTITLE = "showtitle";

public static final String CHANNEL_MEDIATYPE = "mediatype";

public static final String CHANNEL_CURRENTTIME = "currenttime";

public static final String CHANNEL_DURATION = "duration";
public static final String CHANNEL_IMAGEURL = "imageurl";
public static final String CHANNEL_IMAGEURL_TYPE = "imageurl_type";
public static final String CHANNEL_IMAGEURL_MAXWIDTH = "imageurl_maxWidth";
public static final String CHANNEL_IMAGEURL_MAXHEIGHT = "imageurl_maxHeight";
public static final String CHANNEL_IMAGEURL_PERCENTPLAYED = "imageurl_PercentPlayed";

// Module Properties

public static final String HOST_PARAMETER = "ipAddress";
public static final String WS_PORT_PARAMETER = "port";
public static final String WS_BUFFER_SIZE = "buffer_size";
public static final String HTTP_PORT_PARAMETER = "httpPort";
public static final String HTTP_USER_PARAMETER = "httpUser";
public static final String HTTP_PASSWORD_PARAMETER = "httpPassword";
public static final String REFRESH_PARAMETER = "refreshInterval";
public static final String API_KEY = "api";
public static final String DEVICE_ID = "deviceID";

// control constant commands
public static final String CONTROL_SESSION = "/Sessions/";
public static final String CONTROL_GENERALCOMMAND = "/Command/";
public static final String CONTROL_SENDPLAY = "/Playing";
public static final String CONTROL_PLAY = "/Playing/Unpause";
public static final String CONTROL_PAUSE = "/Playing/Pause";
public static final String CONTROL_MUTE = "/Command/Mute";
public static final String CONTROL_UNMUTE = "/Command/Unmute";
public static final String CONTROL_STOP = "/Playing/Stop";

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/**
* Copyright (c) 2010-2020 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.emby.internal;

/**
* The {@link EmbyBridgeConfiguration} class contains fields mapping thing configuration parameters.
*
* @author Zachary Christiansen - Initial contribution
*/

public class EmbyBridgeConfiguration {

public String api;
private String ipAddress;
private Integer port;
private Integer httpPort;
private Integer refreshInterval;
private Integer notificationTimeout;
private Integer notificationVolume;

public String getIpAddress() {
return ipAddress;
}

public void setIpAddress(String ipAddress) {
this.ipAddress = ipAddress;
}

public Integer getPort() {
return port;
}

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

public Integer getHttpPort() {
return httpPort;
}

public void setHttpPort(Integer httpPort) {
this.httpPort = httpPort;
}

public Integer getRefreshInterval() {
return refreshInterval;
}

public void setRefreshInterval(Integer refreshInterval) {
this.refreshInterval = refreshInterval;
}

public Integer getNotificationTimeout() {
return notificationTimeout;
}

public void setNotificationTimeout(Integer notificationTimeout) {
this.notificationTimeout = notificationTimeout;
}

public Integer getNotificationVolume() {
return notificationVolume;
}

public void setNotificationVolume(Integer notificationVolume) {
this.notificationVolume = notificationVolume;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* Copyright (c) 2010-2020 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.emby.internal;

import java.util.EventListener;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.binding.emby.internal.model.EmbyPlayStateModel;
import org.openhab.binding.emby.internal.protocol.EmbyConnection;

/**
* Interface which has to be implemented by a class in order to get status
* updates from a {@link EmbyConnection}
*
* @author Zachary Christiansen - Initial Contribution
*/
@NonNullByDefault
public interface EmbyBridgeListener extends EventListener {

void updateConnectionState(boolean connected);

void handleEvent(EmbyPlayStateModel playstate, String hostname, int embyport);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* Copyright (c) 2010-2020 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.emby.internal;

/**
* The {@link EmbyDeviceConfiguration} class contains fields mapping thing configuration parameters.
*
* @author Zachary Christiansen - Initial contribution
*/
public class EmbyDeviceConfiguration {

public String deviceID;
public String imageMaxWidth;
public String imageMaxHeight;
public Boolean imagePercentPlayed;
public String imageImageType;

public EmbyDeviceConfiguration(String setDeviceID) {
deviceID = setDeviceID;
imageMaxWidth = null;
imageMaxHeight = null;
imagePercentPlayed = null;
imageImageType = null;
}

}
Loading