-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[emby] Initial contribution #13340
Closed
Closed
[emby] Initial contribution #13340
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
87efc89
initial commit after setup of dev envirmonent and binding shell
volfan6415 c539d5b
initial commit after adding binding shell to dev environment
volfan6415 bf0cc9a
ported over original code from 3.0 verision of binding
volfan6415 6f90f7d
inital working binding for openhab 3.0
volfan6415 302dac0
add change to emby handler to reestablish connection on socket close
volfan6415 ddd99ef
changes to cleanup code in prep. for pull request
volfan6415 b1db922
changes/updates to logging levels
volfan6415 43f79a2
updates to logging levels
volfan6415 c882b87
mvn spotless changes
volfan6415 a0e8bf4
change binding to use shared websocket client
volfan6415 b1a1ecb
changes to pom.xml to apply formatting
volfan6415 a46bfc5
Formatting updates
volfan6415 46dc760
updates to logging
volfan6415 30aa049
fixed mvn issues
volfan6415 9cf681c
corrections to header text
volfan6415 06d6d09
fix code style errors
volfan6415 5a86e2d
updates to fix binding re-establishing connection on connection close
volfan6415 3b6e7e3
updates to fix configuration checking on EmbyBridgeConfiguration
volfan6415 8d9bf7b
changes to make the binding more stable on websocket close
volfan6415 894ba04
changes to make the binding more stable on websocket close
volfan6415 2cd71a1
cleanup of comments
volfan6415 23397a4
Merge branch 'main' into embydev
volfan6415 4425603
Update bundles/org.openhab.binding.emby/pom.xml
volfan6415 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# Emby Binding | ||
|
||
The Emby Binding integrates EMBY, a personal media server https://emby.media/, 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._ | ||
|
||
## 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 | | ||
| 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. | | ||
| 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 | | ||
|
||
|
||
## 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="" | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?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.emby</artifactId> | ||
|
||
<name>openHAB Add-ons :: Bundles :: emby Binding</name> | ||
|
||
</project> |
9 changes: 9 additions & 0 deletions
9
bundles/org.openhab.binding.emby/src/main/feature/feature.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
79 changes: 79 additions & 0 deletions
79
...ab.binding.emby/src/main/java/org/openhab/binding/emby/internal/EmbyBindingConstants.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/** | ||
* Copyright (c) 2010-2022 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.openhab.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 = "bufferSize"; | ||
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"; | ||
public static final String DISCOVERY_ENABLE = "discovery"; | ||
// 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"; | ||
} |
39 changes: 39 additions & 0 deletions
39
...binding.emby/src/main/java/org/openhab/binding/emby/internal/EmbyBridgeConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** | ||
* Copyright (c) 2010-2022 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.openhab.core.config.core.Configuration; | ||
|
||
/** | ||
* The {@link EmbyBridgeConfiguration} class contains fields mapping thing configuration parameters. | ||
* | ||
* @param api - This is the API key generated from EMBY used for Authorization. | ||
* @param buffersize - Here you can define a custom size for the websocket buffer size. Default is 10,0000 | ||
* @param ipAddress - This is the ip address of the EMBY Server. | ||
* @param port - This is the port of the EMBY server. | ||
* @param refreshInterval - This is the refresh interval in milliseconds that will be sent to the websocket. Default is | ||
* 10,000 | ||
* @param discovery - If set to false the controller will not add new things from devices to the inbox. | ||
* @author Zachary Christiansen - Initial contribution | ||
*/ | ||
@NonNullByDefault | ||
public class EmbyBridgeConfiguration extends Configuration { | ||
|
||
public String api = ""; | ||
public int bufferSize; | ||
public String ipAddress = ""; | ||
public int port; | ||
public int refreshInterval; | ||
public boolean discovery; | ||
} |
33 changes: 33 additions & 0 deletions
33
...nhab.binding.emby/src/main/java/org/openhab/binding/emby/internal/EmbyBridgeListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/** | ||
* Copyright (c) 2010-2022 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); | ||
} |
35 changes: 35 additions & 0 deletions
35
...binding.emby/src/main/java/org/openhab/binding/emby/internal/EmbyDeviceConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** | ||
* Copyright (c) 2010-2022 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 = false; | ||
imageImageType = null; | ||
} | ||
} |
68 changes: 68 additions & 0 deletions
68
...enhab.binding.emby/src/main/java/org/openhab/binding/emby/internal/EmbyEventListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/** | ||
* Copyright (c) 2010-2022 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 EmbyEventListener extends EventListener { | ||
public enum EmbyState { | ||
PLAY, | ||
PAUSE, | ||
END, | ||
STOP, | ||
REWIND, | ||
FASTFORWARD | ||
} | ||
|
||
public enum EmbyPlaylistState { | ||
ADD, | ||
ADDED, | ||
INSERT, | ||
REMOVE, | ||
REMOVED, | ||
CLEAR | ||
} | ||
|
||
void updateConnectionState(boolean connected); | ||
|
||
void updateScreenSaverState(boolean screenSaveActive); | ||
|
||
void updatePlayerState(EmbyState state); | ||
|
||
void updateMuted(boolean muted); | ||
|
||
void updateTitle(String title); | ||
|
||
void updateShowTitle(String title); | ||
|
||
void updateMediaType(String mediaType); | ||
|
||
void updateCurrentTime(long currentTime); | ||
|
||
void updateDuration(long duration); | ||
|
||
void updatePrimaryImageURL(String imageURL); | ||
|
||
public void handleEvent(EmbyPlayStateModel playstate, String hostname, int embyport); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.