From 0602acd4bb858770aff72059ebf88c8ac12c71e2 Mon Sep 17 00:00:00 2001 From: andan67 Date: Sun, 6 Nov 2022 20:37:39 +0100 Subject: [PATCH] Initial 3.4.0 skyq binding --- bundles/org.openhab.binding.skyq/README.md | 119 ++++++++++-------- .../binding/skyq/internal/SkyQHandler.java | 19 +-- 2 files changed, 75 insertions(+), 63 deletions(-) diff --git a/bundles/org.openhab.binding.skyq/README.md b/bundles/org.openhab.binding.skyq/README.md index 5c6cdabc2b28e..f4c63f5404d61 100644 --- a/bundles/org.openhab.binding.skyq/README.md +++ b/bundles/org.openhab.binding.skyq/README.md @@ -25,63 +25,82 @@ Use the UI to add the receiver as a thing and provide the following configuratio ## Channels -| Channel | Type | Description | -|----------|--------|----------------------------| -| control#controlCommand | String | Sends a remote control command to the device (see below) | -| control#channelPreset | String | Holds list of all channels from receiver and allows switch to a selected channel. The list and order of the channels can be configured through a file (see below). -| control#channelFavorites | String | Holds list of favorite channels from receiver and allows switch to a selected channel. -| control#power | Switch | Switches the receiver ON or OFF. Your receiver has in network standby for this to work. | -| statusChannels#currentChannelTitle | String | Shows current live TV channel title if available | -| statusChannels#powerStatus | String | Shows power state ON, OFF, or STANDBY | -| statusChannels#currentTransportState | String | State of current transport stream (PLAYING etc) | +| Channel | Type | Description | +|----------|--------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| control#controlCommand | String | Sends remote control commands to the device (see below) | +| control#channelPreset | String | Holds list of all channels from receiver and allows switch to a selected channel. The list and order of the channels can be configured through a file (see below). +| control#channelFavorites | String | Holds list of favorite channels from receiver and allows switch to a selected channel. +| control#power | Switch | Switches the receiver ON or OFF. Your receiver has in network standby for this to work. | +| statusChannels#currentChannelTitle | String | Shows current live TV channel title if available | +| statusChannels#powerStatus | String | Shows power state ON, OFF, or STANDBY | +| statusChannels#currentTransportState | String | State of current transport stream (PLAYING etc) | ## Control commands The `control#controlCommand` channel supports the following commands that are defined as state options: -| Value | Label | Description | -|----------|--------|------------------------------| -| power | Power || -| select | Select || -| backup | Back/Up || -| dismiss | Dismiss || -| channelup | Channel up || +| Value | Label | Description | +|-------------|--------|------------------------------| +| power | Power || +| select | Select || +| backup | Back/Up || +| dismiss | Dismiss || +| channelup | Channel up || | channeldown |Channel down || | interactive | Interactive || -| sidebar | Sidebar || -| help | Help || -| services | Services || -| search | Search || -| tvguide | TV guide || -| home | Home || -| i | i || -| text |Text || -| up | Up || -| down | Down || -| left | Left || -| right | Right || -| red | Red || -| green | Green || -| yellow | Yellow || -| blue | Blue || -| 0 | 0 || -| 1 | 1 || -| 2 | 2 || -| 3 | 3 || -| 4 | 4 || -| 5 | 5 || -| 6 | 6 || -| 7 | 7 || -| 8 | 8 || -| 9 | 9 || -| play | Play || -| pause | Pause || -| stop | Stop || -| record | Record || +| sidebar | Sidebar || +| help | Help || +| services | Services || +| search | Search || +| tvguide | TV guide || +| home | Home || +| i | i || +| text |Text || +| up | Up || +| down | Down || +| left | Left || +| right | Right || +| red | Red || +| green | Green || +| yellow | Yellow || +| blue | Blue || +| 0 | 0 || +| 1 | 1 || +| 2 | 2 || +| 3 | 3 || +| 4 | 4 || +| 5 | 5 || +| 6 | 6 || +| 7 | 7 || +| 8 | 8 || +| 9 | 9 || +| play | Play || +| pause | Pause || +| stop | Stop || +| record | Record || | fastforward | Fast forward || -| rewind | Rewind || -| boxoffice | Box office || -| sky | Sky || +| rewind | Rewind || +| boxoffice | Box office || +| sky | Sky || + +### Defining macros +The `controlCommand` channel supports sending multiple commands to the device. This allows the definition of macros by the following procedure: + +1. Define a `String` typed item linked to the `controlCommand` channel +2. Add `State Description` metadata to the item +3. A macro is defined by each option (line) within the `Options` section. The option value represents the +semicolon separated sequence of commands of the macro, and the label the macro name +4. A special command `sleep` is used to delay the sending of the commands by a fixed but short period. This might be required for certain sequences of commands +because sometime some commands are swallowed by the box. + +#### Example + +State options that define macros for opening the prime video app of for showing the top series page +``` +interactive;down;down;down;select=prime video +home;sleep;down;down;down;sleep;right;right=Top Series +``` +Note the `sleep` command here which is required to get reproducable results. ## Configurable channel presets @@ -110,7 +129,7 @@ pseudo channel to the list. skyq.things: ``` -Thing skyq:skyqreceiver:skyq1 [ hostname="192.168.178.2", configurablePresets=true, retryInterval=60, checkStatusInterval=60, refreshInterval=30 ] +Thing skyq:skyqreceiver:skyq1 [ hostname="192.168.178.2", configurrblePresets=true, retryInterval=60, checkStatusInterval=60, refreshInterval=30 ] ``` skyq.items: diff --git a/bundles/org.openhab.binding.skyq/src/main/java/org/openhab/binding/skyq/internal/SkyQHandler.java b/bundles/org.openhab.binding.skyq/src/main/java/org/openhab/binding/skyq/internal/SkyQHandler.java index e63ac2a8592e8..cf6ca6953f0c8 100644 --- a/bundles/org.openhab.binding.skyq/src/main/java/org/openhab/binding/skyq/internal/SkyQHandler.java +++ b/bundles/org.openhab.binding.skyq/src/main/java/org/openhab/binding/skyq/internal/SkyQHandler.java @@ -165,7 +165,7 @@ public void handleCommand(ChannelUID channelUID, Command command) { break; } // refresh states from handling event for channel id - refreshState(id); + // refreshState(id); } @Override @@ -474,9 +474,7 @@ private void refreshState(String handledChannel) { private void refreshState(boolean initial, String handledChannel) { // get current system information if (restProtocol != null) { - if (handledChannel.isEmpty()) { - refreshPowerStatus(true); - } + refreshPowerStatus(true); if (initial || sidToSkyChannelMap.isEmpty()) { refreshSkyChannels(); } @@ -493,15 +491,10 @@ private void refreshState(boolean initial, String handledChannel) { SkyChannel skyChannel = sidToSkyChannelMap.get(currentSid); updateState(new ChannelUID(thing.getUID(), CHANNEL_GROUP_STATUS, CHANNEL_CURRENT_CHANNEL_TITLE), new StringType(skyChannel != null ? skyChannel.title : "UNDEF")); - if (handledChannel.equals(CHANNEL_FAVORITES)) { - updateState(new ChannelUID(thing.getUID(), CHANNEL_GROUP_CONTROL, CHANNEL_PRESET), - new StringType(skyChannel != null ? skyChannel.dispNum : "UNDEF")); - } - if (handledChannel.equals(CHANNEL_PRESET)) { - updateState(new ChannelUID(thing.getUID(), CHANNEL_GROUP_CONTROL, CHANNEL_FAVORITES), - new StringType(skyChannel != null ? skyChannel.dispNum : "UNDEF")); - } - + updateState(new ChannelUID(thing.getUID(), CHANNEL_GROUP_CONTROL, CHANNEL_PRESET), + new StringType(skyChannel != null ? skyChannel.dispNum : "UNDEF")); + updateState(new ChannelUID(thing.getUID(), CHANNEL_GROUP_CONTROL, CHANNEL_FAVORITES), + new StringType(skyChannel != null ? skyChannel.dispNum : "UNDEF")); } } @Nullable