From 729a19a8da9c6100a7caa8a8670a989b0d2fa04c Mon Sep 17 00:00:00 2001 From: morph166955 <53797132+morph166955@users.noreply.github.com> Date: Tue, 17 Oct 2023 17:10:17 -0500 Subject: [PATCH] [roku] Add power, powerState, player, and activeAppName (#15542) * Adds power and powerState. Updates refresh to allow 1 second refresh. * Add activeAppName channel * Add Player channel for transport control Signed-off-by: Ben Rosenblum --- bundles/org.openhab.binding.roku/README.md | 26 ++++++-- .../roku/internal/RokuBindingConstants.java | 9 +++ .../roku/internal/handler/RokuHandler.java | 62 ++++++++++++++++++- .../main/resources/OH-INF/config/config.xml | 2 +- .../resources/OH-INF/i18n/roku.properties | 11 +++- .../src/main/resources/OH-INF/thing/roku.xml | 36 ++++++++++- .../main/resources/OH-INF/update/update.xml | 34 ++++++++++ 7 files changed, 170 insertions(+), 10 deletions(-) create mode 100644 bundles/org.openhab.binding.roku/src/main/resources/OH-INF/update/update.xml diff --git a/bundles/org.openhab.binding.roku/README.md b/bundles/org.openhab.binding.roku/README.md index d846a8738..fa3f78367 100644 --- a/bundles/org.openhab.binding.roku/README.md +++ b/bundles/org.openhab.binding.roku/README.md @@ -23,11 +23,11 @@ The binding has no configuration options, all configuration is done at Thing lev 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. | +| 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 is 10 seconds and minimum is 1 second. | ## Channels @@ -36,7 +36,9 @@ 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. | +| activeAppName | String | The name of the current app (ReadOnly). | | button | String | Sends a remote control command the Roku. See list of available commands below. | +| control | Player | Control Playback e.g. play/pause/next/previous | | 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. | @@ -47,6 +49,8 @@ The following channels are available: | programTitle | String | The name of the current TV program (ReadOnly). | | programDescription | String | The description of the current TV program (ReadOnly). | | programRating | String | The TV parental guideline rating of the current TV program (ReadOnly). | +| power | Switch | Controls the power for the TV. | +| powerState | String | The current power state for the TV. (ReadOnly - ie PowerOn, DisplayOff, Ready, etc.) | Some Notes: @@ -83,7 +87,7 @@ InputHDMI3 InputHDMI4 InputAV1 PowerOff -PowerOn +POWERON _(NOTE: POWERON needs to be completely capitalized due to a bug with older Roku devices)_ ## Full Example @@ -104,7 +108,9 @@ roku:roku_tv:mytv1 "My Roku TV" [ hostName="192.168.10.1", refresh=10 ] // Roku streaming media player items: String Player_ActiveApp "Current App: [%s]" { channel="roku:roku_player:myplayer1:activeApp" } +String Player_ActiveAppName "Current App Name: [%s]" { channel="roku:roku_player:myplayer1:activeAppName" } String Player_Button "Send Command to Roku" { channel="roku:roku_player:myplayer1:button" } +Player Player_Control "Control" { channel="roku:roku_player:myplayer1:control" } 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" } @@ -112,7 +118,9 @@ Number:Time Player_TimeTotal "Total Time: [%d %unit%]" { channel="roku:roku_ // Roku TV items: String Player_ActiveApp "Current App: [%s]" { channel="roku:roku_tv:mytv1:activeApp" } +String Player_ActiveAppName "Current App Name: [%s]" { channel="roku:roku_tv:mytv1:activeAppName" } String Player_Button "Send Command to Roku" { channel="roku:roku_tv:mytv1:button" } +Player Player_Control "Control" { channel="roku:roku_tv:mytv1:control" } String Player_PlayMode "Status: [%s]" { channel="roku:roku_tv:mytv1:playMode" } Number:Time Player_TimeElapsed "Elapsed Time: [%d %unit%]" { channel="roku:roku_tv:mytv1:timeElapsed" } Number:Time Player_TimeTotal "Total Time: [%d %unit%]" { channel="roku:roku_tv:mytv1:timeTotal" } @@ -123,6 +131,8 @@ String Player_ChannelName "Channel Name: [%s]" { channel="roku:rok String Player_ProgramTitle "Program Title: [%s]" { channel="roku:roku_tv:mytv1:programTitle" } String Player_ProgramDescription "Program Description: [%s]" { channel="roku:roku_tv:mytv1:programDescription" } String Player_ProgramRating "Program Rating: [%s]" { channel="roku:roku_tv:mytv1:programRating" } +Switch Player_Power "Power: [%s]" { channel="roku:roku_tv:mytv1:power" } +String Player_PowerState "Power State: [%s] { channel="roku:roku_tv:mytv1:powerState" } ``` @@ -132,7 +142,9 @@ String Player_ProgramRating "Program Rating: [%s]" { channel="roku:rok sitemap roku label="Roku" { Frame label="My Roku" { Selection item=Player_ActiveApp icon="screen" + Text item=Player_ActiveAppName Selection item=Player_Button icon="screen" + Default item=Player_Control Text item=Player_PlayMode Text item=Player_TimeElapsed icon="time" Text item=Player_TimeTotal icon="time" @@ -144,6 +156,8 @@ sitemap roku label="Roku" { Text item=Player_ProgramTitle Text item=Player_ProgramDescription Text item=Player_ProgramRating + Switch item=Player_Power + Text item=Player_PowerState } } ``` 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 index dd17c8928..344b7fd43 100644 --- 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 @@ -49,7 +49,9 @@ public class RokuBindingConstants { // List of all Channel id's public static final String ACTIVE_APP = "activeApp"; + public static final String ACTIVE_APPNAME = "activeAppName"; public static final String BUTTON = "button"; + public static final String CONTROL = "control"; public static final String PLAY_MODE = "playMode"; public static final String TIME_ELAPSED = "timeElapsed"; public static final String TIME_TOTAL = "timeTotal"; @@ -60,11 +62,14 @@ public class RokuBindingConstants { public static final String PROGRAM_TITLE = "programTitle"; public static final String PROGRAM_DESCRIPTION = "programDescription"; public static final String PROGRAM_RATING = "programRating"; + public static final String POWER = "power"; + public static final String POWER_STATE = "powerState"; // Units of measurement of the data delivered by the API public static final Unit