diff --git a/CODEOWNERS b/CODEOWNERS index e877a114f9f09..409e1927fcbc8 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -218,6 +218,7 @@ /bundles/org.openhab.binding.rfxcom/ @martinvw @paulianttila /bundles/org.openhab.binding.rme/ @kgoderis /bundles/org.openhab.binding.robonect/ @reyem +/bundles/org.openhab.binding.roku/ @mlobstein /bundles/org.openhab.binding.rotel/ @lolodomo /bundles/org.openhab.binding.russound/ @tmrobert8 /bundles/org.openhab.binding.sagercaster/ @clinique diff --git a/bom/openhab-addons/pom.xml b/bom/openhab-addons/pom.xml index 63d59e0574639..a9c38a1e54caf 100644 --- a/bom/openhab-addons/pom.xml +++ b/bom/openhab-addons/pom.xml @@ -1076,6 +1076,11 @@ org.openhab.binding.robonect ${project.version} + + org.openhab.addons.bundles + org.openhab.binding.roku + ${project.version} + org.openhab.addons.bundles org.openhab.binding.rotel diff --git a/bundles/org.openhab.binding.roku/NOTICE b/bundles/org.openhab.binding.roku/NOTICE new file mode 100644 index 0000000000000..38d625e349232 --- /dev/null +++ b/bundles/org.openhab.binding.roku/NOTICE @@ -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 diff --git a/bundles/org.openhab.binding.roku/README.md b/bundles/org.openhab.binding.roku/README.md new file mode 100644 index 0000000000000..b3d92ccff2e5f --- /dev/null +++ b/bundles/org.openhab.binding.roku/README.md @@ -0,0 +1,111 @@ +# Roku Binding + +This binding connects Roku streaming media players and Roku TVs to openHAB. +The Roku device must support the Roku ECP protocol REST API. + +## Supported Things + +There are two supported thing types, which represent either a standalone Roku device or a Roku TV. +A supported Roku streaming media player or streaming stick uses the `roku_player` id and a supported Roku TV uses the `roku_tv` id. +The binding functionality is the same for both types, but the Roku TV type adds additional button commands to the button channel dropdown. +Multiple Things can be added if more than one Roku is to be controlled. + +## Discovery + +Auto-discovery is supported if the Roku can be located on the local network using SSDP. +Otherwise the thing must be manually added. + +## Binding Configuration + +The binding has no configuration options, all configuration is done at Thing level. + +## Thing Configuration + +The thing has a few configuration parameters: + +| Parameter | Description | +|-----------|------------------------------------------------------------------------------------------------------------| +| hostName | The host name or IP address of the Roku device. Mandatory. | +| port | The port on the Roku that listens for http connections. Default 8060 | +| refresh | Overrides the refresh interval for player status updates. Optional, the default and minimum is 10 seconds. | + +## Channels + +The following channels are available: + +| Channel ID | Item Type | Description | +|-----------------|-------------|---------------------------------------------------------------------------------------------------------------------------------------------------------| +| activeApp | String | A dropdown containing a list of all apps installed on the Roku. The app currently running is automatically selected. The list updates every 10 minutes. | +| button | String | Sends a remote control command the Roku. See list of available commands below. | +| playMode | String | The current playback mode ie: stop, play, pause (ReadOnly). | +| timeElapsed | Number:Time | The total number of seconds of playback time elapsed for the current playing title (ReadOnly). | +| timeTotal | Number:Time | The total length of the current playing title in seconds (ReadOnly). This data is not provided by all streaming apps. | + +Some Notes: + +* The values for `activeApp`, `playMode`, `timeElapsed` & `timeTotal` refresh automatically per the configured `refresh` interval (10 seconds minimum). + +**List of available button commands for Roku streaming devices:** +Home +Rev +Fwd +Play +Select +Left +Right +Up +Down +Back +InstantReplay +Info +Backspace +Search +Enter +FindRemote + +**List of additional button commands for Roku TVs:** +ChannelUp +ChannelDown +VolumeUp +VolumeDown +VolumeMute +InputTuner +InputHDMI1 +InputHDMI2 +InputHDMI3 +InputHDMI4 +InputAV1 +PowerOff + +## Full Example + +roku.things: + +```java +roku:roku_player:myplayer1 "My Roku" [ hostName="192.168.10.1", refresh=10 ] +roku:roku_tv:myplayer1 "My Roku TV" [ hostName="192.168.10.1", refresh=10 ] +``` + +roku.items: + +```java +String Player_ActiveApp "Current App: [%s]" { channel="roku:roku_player:myplayer1:activeApp" } +String Player_Button "Send Command to Roku" { channel="roku:roku_player:myplayer1:button" } +String Player_PlayMode "Status: [%s]" { channel="roku:roku_player:myplayer1:playMode" } +Number:Time Player_TimeElapsed "Elapsed Time: [%d %unit%]" { channel="roku:roku_player:myplayer1:timeElapsed" } +Number:Time Player_TimeTotal "Total Time: [%d %unit%]" { channel="roku:roku_player:myplayer1:timeTotal" } +``` + +roku.sitemap: + +```perl +sitemap roku label="Roku" { + Frame label="My Roku" { + Selection item=Player_ActiveApp icon="screen" + Selection item=Player_Button icon="screen" + Text item=Player_PlayMode + Text item=Player_TimeElapsed icon="time" + Text item=Player_TimeTotal icon="time" + } +} +``` diff --git a/bundles/org.openhab.binding.roku/pom.xml b/bundles/org.openhab.binding.roku/pom.xml new file mode 100644 index 0000000000000..f1b29687ae5dd --- /dev/null +++ b/bundles/org.openhab.binding.roku/pom.xml @@ -0,0 +1,17 @@ + + + + 4.0.0 + + + org.openhab.addons.bundles + org.openhab.addons.reactor.bundles + 3.1.0-SNAPSHOT + + + org.openhab.binding.roku + + openHAB Add-ons :: Bundles :: Roku Binding + + diff --git a/bundles/org.openhab.binding.roku/src/main/feature/feature.xml b/bundles/org.openhab.binding.roku/src/main/feature/feature.xml new file mode 100644 index 0000000000000..7d12deccc1bc4 --- /dev/null +++ b/bundles/org.openhab.binding.roku/src/main/feature/feature.xml @@ -0,0 +1,9 @@ + + + mvn:org.openhab.core.features.karaf/org.openhab.core.features.karaf.openhab-core/${ohc.version}/xml/features + + + openhab-runtime-base + mvn:org.openhab.addons.bundles/org.openhab.binding.roku/${project.version} + + diff --git a/bundles/org.openhab.binding.roku/src/main/java/org/openhab/binding/roku/internal/RokuBindingConstants.java b/bundles/org.openhab.binding.roku/src/main/java/org/openhab/binding/roku/internal/RokuBindingConstants.java new file mode 100644 index 0000000000000..76401a776f61e --- /dev/null +++ b/bundles/org.openhab.binding.roku/src/main/java/org/openhab/binding/roku/internal/RokuBindingConstants.java @@ -0,0 +1,66 @@ +/** + * Copyright (c) 2010-2021 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.roku.internal; + +import java.util.Set; + +import javax.measure.Unit; +import javax.measure.quantity.Time; + +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.openhab.core.library.unit.Units; +import org.openhab.core.thing.ThingTypeUID; + +/** + * The {@link RokuBindingConstants} class defines common constants, which are + * used across the whole binding. + * + * @author Michael Lobstein - Initial contribution + */ +@NonNullByDefault +public class RokuBindingConstants { + public static final String BINDING_ID = "roku"; + public static final String PROPERTY_UUID = "uuid"; + public static final String PROPERTY_HOST_NAME = "hostName"; + public static final String PROPERTY_PORT = "port"; + public static final String PROPERTY_MODEL_NAME = "Model Name"; + public static final String PROPERTY_MODEL_NUMBER = "Model Number"; + public static final String PROPERTY_DEVICE_LOCAITON = "Device Location"; + public static final String PROPERTY_SERIAL_NUMBER = "Serial Number"; + public static final String PROPERTY_DEVICE_ID = "Device Id"; + public static final String PROPERTY_SOFTWARE_VERSION = "Software Version"; + + // List of all Thing Type UIDs + public static final ThingTypeUID THING_TYPE_ROKU_PLAYER = new ThingTypeUID(BINDING_ID, "roku_player"); + public static final ThingTypeUID THING_TYPE_ROKU_TV = new ThingTypeUID(BINDING_ID, "roku_tv"); + public static final Set SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_ROKU_PLAYER, + THING_TYPE_ROKU_TV); + + // List of all Channel id's + public static final String ACTIVE_APP = "activeApp"; + public static final String BUTTON = "button"; + public static final String PLAY_MODE = "playMode"; + public static final String TIME_ELAPSED = "timeElapsed"; + public static final String TIME_TOTAL = "timeTotal"; + + // Units of measurement of the data delivered by the API + public static final Unit