From 8acbac9a9850defaad694c2a13dacc46bef68f66 Mon Sep 17 00:00:00 2001 From: Plebs Date: Mon, 5 Sep 2016 14:41:19 +0200 Subject: [PATCH 1/4] Update openhab_default.cfg Committing change for xbmc binding --- .../openhabhome/configurations/openhab_default.cfg | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/distribution/openhabhome/configurations/openhab_default.cfg b/distribution/openhabhome/configurations/openhab_default.cfg index 6f230f26352..d7da4a6109e 100644 --- a/distribution/openhabhome/configurations/openhab_default.cfg +++ b/distribution/openhabhome/configurations/openhab_default.cfg @@ -2482,11 +2482,14 @@ tcp:refreshinterval=250 # Port number for the web socket service (optional, defaults to 9090). Example: #xbmc:livingRoom.wsPort=9090 -# Username to connect to XBMC. (optional, defaults to none). Example: +# Username to connect to XBMC. (optional, defaults to xbmc). Example: #xbmc:livingRoom.username=xbmc -# Password to connect to XBMC. (optional, defaults to none). Example: +# Password to connect to XBMC. (optional, defaults to xbmc). Example: #xbmc:livingRoom.password=xbmc + +#Refresh interval in ms (optional, defaults to 60000ms [1 minute]) +#xbmc:refreshInterval= ################################ Garadget Binding ################################### # From 80052fcac5328ee57de2136a17803506032e3a02 Mon Sep 17 00:00:00 2001 From: giig1967g Date: Mon, 5 Sep 2016 17:13:51 +0200 Subject: [PATCH 2/4] Hi, sending my changes to XBMC binding. Added following commands: - Player.GETINFO - Player.GETPROPERTIES - XBMC.GetINFOLABEL Added configurable refresh interval --- .../binding/xbmc/internal/XbmcActivator.java | 2 +- .../xbmc/internal/XbmcActiveBinding.java | 42 +++- .../org/openhab/binding/xbmc/rpc/RpcCall.java | 3 + .../binding/xbmc/rpc/XbmcConnector.java | 181 +++++++++++++++--- .../binding/xbmc/rpc/calls/InputBack.java | 43 +++++ .../xbmc/rpc/calls/InputContextMenu.java | 43 +++++ .../binding/xbmc/rpc/calls/InputDown.java | 43 +++++ .../binding/xbmc/rpc/calls/InputHome.java | 43 +++++ .../binding/xbmc/rpc/calls/InputInfo.java | 43 +++++ .../binding/xbmc/rpc/calls/InputLeft.java | 43 +++++ .../binding/xbmc/rpc/calls/InputRight.java | 43 +++++ .../binding/xbmc/rpc/calls/InputSelect.java | 43 +++++ .../xbmc/rpc/calls/InputShowCodec.java | 43 +++++ .../binding/xbmc/rpc/calls/InputShowOSD.java | 43 +++++ .../binding/xbmc/rpc/calls/InputUp.java | 43 +++++ .../binding/xbmc/rpc/calls/PlayerGetItem.java | 7 +- .../xbmc/rpc/calls/PlayerGetLabels.java | 129 +++++++++++++ .../xbmc/rpc/calls/PlayerGetProperties.java | 79 +++++++- .../src/main/resources/conf/xbmc.cfg | 7 +- 19 files changed, 883 insertions(+), 40 deletions(-) create mode 100644 bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputBack.java create mode 100644 bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputContextMenu.java create mode 100644 bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputDown.java create mode 100644 bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputHome.java create mode 100644 bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputInfo.java create mode 100644 bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputLeft.java create mode 100644 bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputRight.java create mode 100644 bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputSelect.java create mode 100644 bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputShowCodec.java create mode 100644 bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputShowOSD.java create mode 100644 bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputUp.java create mode 100644 bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/PlayerGetLabels.java diff --git a/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/internal/XbmcActivator.java b/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/internal/XbmcActivator.java index 8057233d5bf..6cc7de84479 100644 --- a/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/internal/XbmcActivator.java +++ b/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/internal/XbmcActivator.java @@ -16,7 +16,7 @@ /** * Extension of the default OSGi bundle activator * - * @author tlan, Ben Jones + * @author tlan, Ben Jones,plebs * @since 1.5.0 */ public final class XbmcActivator implements BundleActivator { diff --git a/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/internal/XbmcActiveBinding.java b/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/internal/XbmcActiveBinding.java index a66328a0911..6cd3241f3bb 100644 --- a/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/internal/XbmcActiveBinding.java +++ b/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/internal/XbmcActiveBinding.java @@ -13,6 +13,7 @@ import java.util.HashMap; import java.util.Map; +import org.apache.commons.lang.StringUtils; import org.openhab.binding.xbmc.XbmcBindingProvider; import org.openhab.binding.xbmc.rpc.XbmcConnector; import org.openhab.core.binding.AbstractActiveBinding; @@ -32,10 +33,10 @@ * All item updates are received asynchronously via the web socket All item * commands are sent via the web socket * - * @author tlan, Ben Jones + * @author tlan, Ben Jones, Plebs * @since 1.5.0 */ -public class XbmcActiveBinding extends AbstractActiveBindingimplements ManagedService { +public class XbmcActiveBinding extends AbstractActiveBinding implements ManagedService { private static final Logger logger = LoggerFactory.getLogger(XbmcActiveBinding.class); @@ -46,12 +47,12 @@ public class XbmcActiveBinding extends AbstractActiveBinding config) throws ConfigurationException Map hosts = new HashMap(); if (config != null) { + + String refreshIntervalString = (String) config.get("refreshInterval"); + if (StringUtils.isNotBlank(refreshIntervalString)) { + refreshInterval = Long.parseLong(refreshIntervalString); + } + Enumeration keys = config.keys(); while (keys.hasMoreElements()) { + // Ignore "refreshInterval" key String key = keys.nextElement(); + if ("refreshInterval".equals(key)) { + continue; + } if ("service.pid".equals(key)) { continue; @@ -426,6 +459,7 @@ public void updated(Dictionary config) throws ConfigurationException hosts.put(hostname, host); } + setProperlyConfigured(true); nameHostMapper = hosts; registerAllWatches(); } diff --git a/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/RpcCall.java b/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/RpcCall.java index 45aed70aee7..abdaf0adafd 100644 --- a/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/RpcCall.java +++ b/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/RpcCall.java @@ -131,11 +131,14 @@ private void postRequest(Map request, Runnable completeHandler) try { // we fire this request off asynchronously and let the completeHandler // process any response as necessary (can be null) + logger.debug("Write JSON: " + writeJson(request)); // Stefano: logging the JSON request ListenableFuture future = client.preparePost(uri).setBody(writeJson(request)) .setHeader("content-type", "application/json").setHeader("accept", "application/json") .execute(new AsyncCompletionHandler() { @Override public Response onCompleted(Response response) throws Exception { + logger.debug("Read JSON: " + response.getResponseBody()); // Stefano: logging the JSON + // response Map json = readJson(response.getResponseBody()); // if we get an error then throw an exception to stop the diff --git a/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/XbmcConnector.java b/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/XbmcConnector.java index 5c75ee3370c..5c9a486b5f3 100644 --- a/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/XbmcConnector.java +++ b/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/XbmcConnector.java @@ -28,11 +28,24 @@ import org.openhab.binding.xbmc.rpc.calls.ApplicationSetVolume; import org.openhab.binding.xbmc.rpc.calls.FilesPrepareDownload; import org.openhab.binding.xbmc.rpc.calls.GUIShowNotification; +import org.openhab.binding.xbmc.rpc.calls.InputBack; +import org.openhab.binding.xbmc.rpc.calls.InputContextMenu; +import org.openhab.binding.xbmc.rpc.calls.InputDown; import org.openhab.binding.xbmc.rpc.calls.InputExecuteAction; +import org.openhab.binding.xbmc.rpc.calls.InputHome; +import org.openhab.binding.xbmc.rpc.calls.InputInfo; +import org.openhab.binding.xbmc.rpc.calls.InputLeft; +import org.openhab.binding.xbmc.rpc.calls.InputRight; +import org.openhab.binding.xbmc.rpc.calls.InputSelect; +import org.openhab.binding.xbmc.rpc.calls.InputShowCodec; +import org.openhab.binding.xbmc.rpc.calls.InputShowOSD; +import org.openhab.binding.xbmc.rpc.calls.InputUp; import org.openhab.binding.xbmc.rpc.calls.JSONRPCPing; import org.openhab.binding.xbmc.rpc.calls.PVRGetChannels; import org.openhab.binding.xbmc.rpc.calls.PlayerGetActivePlayers; import org.openhab.binding.xbmc.rpc.calls.PlayerGetItem; +import org.openhab.binding.xbmc.rpc.calls.PlayerGetLabels; +import org.openhab.binding.xbmc.rpc.calls.PlayerGetProperties; import org.openhab.binding.xbmc.rpc.calls.PlayerOpen; import org.openhab.binding.xbmc.rpc.calls.PlayerPlayPause; import org.openhab.binding.xbmc.rpc.calls.PlayerStop; @@ -400,6 +413,61 @@ public void playerOpen(String file) { playeropen.execute(); } + public void inputBack() { + final InputBack inputback = new InputBack(client, httpUri); + inputback.execute(); + } + + public void inputContextMenu() { + final InputContextMenu inputcontextmenu = new InputContextMenu(client, httpUri); + inputcontextmenu.execute(); + } + + public void inputDown() { + final InputDown inputdown = new InputDown(client, httpUri); + inputdown.execute(); + } + + public void inputHome() { + final InputHome inputhome = new InputHome(client, httpUri); + inputhome.execute(); + } + + public void inputInfo() { + final InputInfo inputinfo = new InputInfo(client, httpUri); + inputinfo.execute(); + } + + public void inputLeft() { + final InputLeft inputleft = new InputLeft(client, httpUri); + inputleft.execute(); + } + + public void inputRight() { + final InputRight inputright = new InputRight(client, httpUri); + inputright.execute(); + } + + public void inputSelect() { + final InputSelect inputselect = new InputSelect(client, httpUri); + inputselect.execute(); + } + + public void inputShowCodec() { + final InputShowCodec inputshowcodec = new InputShowCodec(client, httpUri); + inputshowcodec.execute(); + } + + public void inputShowOSD() { + final InputShowOSD inputshowosd = new InputShowOSD(client, httpUri); + inputshowosd.execute(); + } + + public void inputUp() { + final InputUp inputup = new InputUp(client, httpUri); + inputup.execute(); + } + public void inputExecuteAction(String action) { final InputExecuteAction executeAction = new InputExecuteAction(client, httpUri); executeAction.setAction(action); @@ -581,25 +649,82 @@ private void requestPlayerUpdate(int playerId, boolean updatePolledPropertiesOnl if (!properties.isEmpty()) { logger.debug("[{}]: Retrieving properties ({}) for playerId {}", xbmc.getHostname(), properties.size(), playerId); + final List propertiesInfo = new ArrayList(); + final List propertiesProperties = new ArrayList(); + final List propertiesLabels = new ArrayList(); + + for (String property : properties) { + if (property.startsWith("Player.")) { + propertiesInfo.add(property); + } + if (property.startsWith("Property.")) { + propertiesProperties.add(property); + } + if (property.startsWith("Label.")) { + propertiesLabels.add(property); + } + } + // make the request for the player item details - final PlayerGetItem item = new PlayerGetItem(client, httpUri); - item.setPlayerId(playerId); - item.setProperties(properties); - - item.execute(new Runnable() { - @Override - public void run() { - // now update each of the openHAB items for each property - for (String property : properties) { - String value = item.getPropertyValue(property); - if (property.equals("Player.Fanart")) { - updateFanartUrl(property, value); - } else { + if (!propertiesInfo.isEmpty()) { + final PlayerGetItem item = new PlayerGetItem(client, httpUri); + item.setPlayerId(playerId); + item.setProperties(propertiesInfo); + + item.execute(new Runnable() { + @Override + public void run() { + // now update each of the openHAB items for each property + for (String property : propertiesInfo) { + String value = item.getPropertyValue(property); + // logger.debug("UPDATEfromGETINFO: property=" + property + " & value=" + value); + if (property.equals("Player.Fanart")) { + updateFanartUrl(property, value); + } else { + updateProperty(property, value); + } + } + } + }); + } + + // make the request for the player item2 details using GETPROPERTIES + if (!propertiesProperties.isEmpty()) { + final PlayerGetProperties item2 = new PlayerGetProperties(client, httpUri); + item2.setPlayerId(playerId); + item2.setProperties(propertiesProperties); + + item2.execute(new Runnable() { + @Override + public void run() { + // now update each of the openHAB items for each property + for (String property : propertiesProperties) { + String value = item2.getPropertyValue(property); + // logger.debug("UPDATEfromGETPROPERTIES: property=" + property + " & value=" + value); updateProperty(property, value); } } - } - }); + }); + } + + // make the request for the player item3 details using GETLABELS + if (!propertiesLabels.isEmpty()) { + final PlayerGetLabels item3 = new PlayerGetLabels(client, httpUri); + // item3.setPlayerId(playerId); + item3.setProperties(propertiesLabels); + + item3.execute(new Runnable() { + @Override + public void run() { + // now update each of the openHAB items for each property + for (String property : propertiesLabels) { + String value = item3.getPropertyValue(property); + // logger.debug("UPDATEfromGETLABELS: property=" + property + " & value=" + value); + updateProperty(property, value); + } + } + }); + } } } @@ -676,25 +801,37 @@ private List getPlayerProperties(boolean updatePolledPropertiesOnly) { for (String property : watches.values()) { if (properties.contains(property)) { continue; - } else if (property.equals("Player.Label")) { + } + if (property.equals("Player.State")) { + continue; + } + if (property.startsWith("Player.")) { + properties.add(property); + } + if (property.startsWith("Property.")) { properties.add(property); - } else if (property.equals("Player.Title")) { + } + if (property.startsWith("Label.")) { properties.add(property); } } } else { for (String property : watches.values()) { - if (!property.startsWith("Player.")) { + if (properties.contains(property)) { continue; } if (property.equals("Player.State")) { continue; } - if (properties.contains(property)) { - continue; + if (property.startsWith("Player.")) { + properties.add(property); + } + if (property.startsWith("Property.")) { + properties.add(property); + } + if (property.startsWith("Label.")) { + properties.add(property); } - - properties.add(property); } } return properties; diff --git a/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputBack.java b/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputBack.java new file mode 100644 index 00000000000..b602a5dc289 --- /dev/null +++ b/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputBack.java @@ -0,0 +1,43 @@ +/** + * Copyright (c) 2010-2016 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.xbmc.rpc.calls; + +import java.util.Collections; +import java.util.Map; + +import org.openhab.binding.xbmc.rpc.RpcCall; + +import com.ning.http.client.AsyncHttpClient; + +/** + * Input.Back RPC + * + * @author Il Plebs + * @since 1.5.0 + */ +public class InputBack extends RpcCall { + + public InputBack(AsyncHttpClient client, String uri) { + super(client, uri); + } + + @Override + protected String getName() { + return "Input.Back"; + } + + @Override + protected Map getParams() { + return Collections.emptyMap(); + } + + @Override + protected void processResponse(Map response) { + } +} diff --git a/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputContextMenu.java b/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputContextMenu.java new file mode 100644 index 00000000000..2175387cbed --- /dev/null +++ b/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputContextMenu.java @@ -0,0 +1,43 @@ +/** + * Copyright (c) 2010-2016 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.xbmc.rpc.calls; + +import java.util.Collections; +import java.util.Map; + +import org.openhab.binding.xbmc.rpc.RpcCall; + +import com.ning.http.client.AsyncHttpClient; + +/** + * Input.ContextMenu RPC + * + * @author Il Plebs + * @since 1.5.0 + */ +public class InputContextMenu extends RpcCall { + + public InputContextMenu(AsyncHttpClient client, String uri) { + super(client, uri); + } + + @Override + protected String getName() { + return "Input.ContextMenu"; + } + + @Override + protected Map getParams() { + return Collections.emptyMap(); + } + + @Override + protected void processResponse(Map response) { + } +} diff --git a/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputDown.java b/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputDown.java new file mode 100644 index 00000000000..5f11d453f57 --- /dev/null +++ b/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputDown.java @@ -0,0 +1,43 @@ +/** + * Copyright (c) 2010-2016 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.xbmc.rpc.calls; + +import java.util.Collections; +import java.util.Map; + +import org.openhab.binding.xbmc.rpc.RpcCall; + +import com.ning.http.client.AsyncHttpClient; + +/** + * Input.Down RPC + * + * @author Il Plebs + * @since 1.5.0 + */ +public class InputDown extends RpcCall { + + public InputDown(AsyncHttpClient client, String uri) { + super(client, uri); + } + + @Override + protected String getName() { + return "Input.Down"; + } + + @Override + protected Map getParams() { + return Collections.emptyMap(); + } + + @Override + protected void processResponse(Map response) { + } +} diff --git a/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputHome.java b/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputHome.java new file mode 100644 index 00000000000..58f63bc320a --- /dev/null +++ b/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputHome.java @@ -0,0 +1,43 @@ +/** + * Copyright (c) 2010-2016 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.xbmc.rpc.calls; + +import java.util.Collections; +import java.util.Map; + +import org.openhab.binding.xbmc.rpc.RpcCall; + +import com.ning.http.client.AsyncHttpClient; + +/** + * Input.Home RPC + * + * @author Il Plebs + * @since 1.5.0 + */ +public class InputHome extends RpcCall { + + public InputHome(AsyncHttpClient client, String uri) { + super(client, uri); + } + + @Override + protected String getName() { + return "Input.Home"; + } + + @Override + protected Map getParams() { + return Collections.emptyMap(); + } + + @Override + protected void processResponse(Map response) { + } +} diff --git a/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputInfo.java b/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputInfo.java new file mode 100644 index 00000000000..3fc9b0313f6 --- /dev/null +++ b/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputInfo.java @@ -0,0 +1,43 @@ +/** + * Copyright (c) 2010-2016 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.xbmc.rpc.calls; + +import java.util.Collections; +import java.util.Map; + +import org.openhab.binding.xbmc.rpc.RpcCall; + +import com.ning.http.client.AsyncHttpClient; + +/** + * Input.Info RPC + * + * @author Il Plebs + * @since 1.5.0 + */ +public class InputInfo extends RpcCall { + + public InputInfo(AsyncHttpClient client, String uri) { + super(client, uri); + } + + @Override + protected String getName() { + return "Input.Info"; + } + + @Override + protected Map getParams() { + return Collections.emptyMap(); + } + + @Override + protected void processResponse(Map response) { + } +} diff --git a/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputLeft.java b/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputLeft.java new file mode 100644 index 00000000000..6c603eeaacd --- /dev/null +++ b/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputLeft.java @@ -0,0 +1,43 @@ +/** + * Copyright (c) 2010-2016 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.xbmc.rpc.calls; + +import java.util.Collections; +import java.util.Map; + +import org.openhab.binding.xbmc.rpc.RpcCall; + +import com.ning.http.client.AsyncHttpClient; + +/** + * Input.Left RPC + * + * @author Il Plebs + * @since 1.5.0 + */ +public class InputLeft extends RpcCall { + + public InputLeft(AsyncHttpClient client, String uri) { + super(client, uri); + } + + @Override + protected String getName() { + return "Input.Left"; + } + + @Override + protected Map getParams() { + return Collections.emptyMap(); + } + + @Override + protected void processResponse(Map response) { + } +} diff --git a/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputRight.java b/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputRight.java new file mode 100644 index 00000000000..971d0d237a3 --- /dev/null +++ b/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputRight.java @@ -0,0 +1,43 @@ +/** + * Copyright (c) 2010-2016 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.xbmc.rpc.calls; + +import java.util.Collections; +import java.util.Map; + +import org.openhab.binding.xbmc.rpc.RpcCall; + +import com.ning.http.client.AsyncHttpClient; + +/** + * Input.Right RPC + * + * @author Il Plebs + * @since 1.5.0 + */ +public class InputRight extends RpcCall { + + public InputRight(AsyncHttpClient client, String uri) { + super(client, uri); + } + + @Override + protected String getName() { + return "Input.Right"; + } + + @Override + protected Map getParams() { + return Collections.emptyMap(); + } + + @Override + protected void processResponse(Map response) { + } +} diff --git a/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputSelect.java b/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputSelect.java new file mode 100644 index 00000000000..95215ec1254 --- /dev/null +++ b/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputSelect.java @@ -0,0 +1,43 @@ +/** + * Copyright (c) 2010-2016 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.xbmc.rpc.calls; + +import java.util.Collections; +import java.util.Map; + +import org.openhab.binding.xbmc.rpc.RpcCall; + +import com.ning.http.client.AsyncHttpClient; + +/** + * Input.Select RPC + * + * @author Il Plebs + * @since 1.5.0 + */ +public class InputSelect extends RpcCall { + + public InputSelect(AsyncHttpClient client, String uri) { + super(client, uri); + } + + @Override + protected String getName() { + return "Input.Select"; + } + + @Override + protected Map getParams() { + return Collections.emptyMap(); + } + + @Override + protected void processResponse(Map response) { + } +} diff --git a/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputShowCodec.java b/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputShowCodec.java new file mode 100644 index 00000000000..3ae5e2e60b2 --- /dev/null +++ b/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputShowCodec.java @@ -0,0 +1,43 @@ +/** + * Copyright (c) 2010-2016 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.xbmc.rpc.calls; + +import java.util.Collections; +import java.util.Map; + +import org.openhab.binding.xbmc.rpc.RpcCall; + +import com.ning.http.client.AsyncHttpClient; + +/** + * Input.ShowCodec RPC + * + * @author Il Plebs + * @since 1.5.0 + */ +public class InputShowCodec extends RpcCall { + + public InputShowCodec(AsyncHttpClient client, String uri) { + super(client, uri); + } + + @Override + protected String getName() { + return "Input.ShowCodec"; + } + + @Override + protected Map getParams() { + return Collections.emptyMap(); + } + + @Override + protected void processResponse(Map response) { + } +} diff --git a/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputShowOSD.java b/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputShowOSD.java new file mode 100644 index 00000000000..465fae10df6 --- /dev/null +++ b/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputShowOSD.java @@ -0,0 +1,43 @@ +/** + * Copyright (c) 2010-2016 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.xbmc.rpc.calls; + +import java.util.Collections; +import java.util.Map; + +import org.openhab.binding.xbmc.rpc.RpcCall; + +import com.ning.http.client.AsyncHttpClient; + +/** + * Input.ShowOSD RPC + * + * @author Il Plebs + * @since 1.5.0 + */ +public class InputShowOSD extends RpcCall { + + public InputShowOSD(AsyncHttpClient client, String uri) { + super(client, uri); + } + + @Override + protected String getName() { + return "Input.ShowOSD"; + } + + @Override + protected Map getParams() { + return Collections.emptyMap(); + } + + @Override + protected void processResponse(Map response) { + } +} diff --git a/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputUp.java b/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputUp.java new file mode 100644 index 00000000000..3f2810bd68c --- /dev/null +++ b/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputUp.java @@ -0,0 +1,43 @@ +/** + * Copyright (c) 2010-2016 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.xbmc.rpc.calls; + +import java.util.Collections; +import java.util.Map; + +import org.openhab.binding.xbmc.rpc.RpcCall; + +import com.ning.http.client.AsyncHttpClient; + +/** + * Input.Up RPC + * + * @author Il Plebs + * @since 1.5.0 + */ +public class InputUp extends RpcCall { + + public InputUp(AsyncHttpClient client, String uri) { + super(client, uri); + } + + @Override + protected String getName() { + return "Input.Up"; + } + + @Override + protected Map getParams() { + return Collections.emptyMap(); + } + + @Override + protected void processResponse(Map response) { + } +} diff --git a/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/PlayerGetItem.java b/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/PlayerGetItem.java index 37176706a1f..1cab356ce35 100644 --- a/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/PlayerGetItem.java +++ b/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/PlayerGetItem.java @@ -58,8 +58,11 @@ protected Map getParams() { if (property.equals("Player.Label")) { continue; } - String paramProperty = getParamProperty(property); - paramProperties.add(paramProperty); + if (property.startsWith("Player.")) { + // properties entered as 'Player.Title' etc - so strip the first 7 chars + String paramProperty = getParamProperty(property); + paramProperties.add(paramProperty); + } } Map params = new HashMap(); diff --git a/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/PlayerGetLabels.java b/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/PlayerGetLabels.java new file mode 100644 index 00000000000..e4cc0060939 --- /dev/null +++ b/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/PlayerGetLabels.java @@ -0,0 +1,129 @@ +/** + * Copyright (c) 2010-2016 by the respective copyright holders. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.binding.xbmc.rpc.calls; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.commons.lang.StringUtils; +import org.openhab.binding.xbmc.rpc.RpcCall; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.ning.http.client.AsyncHttpClient; + +/** + * Player.GetLabels RPC + * + * @author Ben Jones + * @since 1.5.0 + */ +public class PlayerGetLabels extends RpcCall { + + private static final Logger logger = LoggerFactory.getLogger(RpcCall.class); + + private int playerId; + private List properties; + + private Map item; + + public PlayerGetLabels(AsyncHttpClient client, String uri) { + super(client, uri); + } + + public void setPlayerId(int playerId) { + this.playerId = playerId; + } + + public void setProperties(List properties) { + this.properties = properties; + } + + @Override + protected String getName() { + return "XBMC.GetInfoLabels"; + } + + @Override + protected Map getParams() { + List paramProperties = new ArrayList(); + for (String property : properties) { + if (property.startsWith("Label.")) { + String paramProperty = getParamProperty(property); + paramProperties.add(paramProperty); + } + } + + Map params = new HashMap(); + // params.put("playerid", playerId); + params.put("labels", paramProperties); + return params; + } + + @Override + protected void processResponse(Map response) { + Map result = getMap(response, "result"); + // item = getMap(result, "label"); + item = result; + } + + public String getPropertyValue(String property) { + String paramProperty = getParamProperty(property); + if (!item.containsKey(paramProperty)) { + return null; + } + + Object value = item.get(paramProperty); + + if (value instanceof List) { + List values = (List) value; + + // check if list contains any values + if (values.size() == 0) { + return null; + } + + // some properties come back as a list with an indexer + String paramPropertyIndex = getPropertyValue(paramProperty + "id"); + int propertyIndex; + if (!StringUtils.isEmpty(paramPropertyIndex)) { + // attempt to parse the property index + try { + propertyIndex = Integer.parseInt(paramPropertyIndex); + } catch (NumberFormatException e) { + return null; + } + + // check if the index is valid + if (propertyIndex < 0 || propertyIndex >= values.size()) { + return null; + } + } else { + // some properties come back as a list without an indexer, + // e.g. artist, for these we return the first in the list + propertyIndex = 0; + } + + value = values.get(propertyIndex); + } + + if (value == null) { + return null; + } + + return value.toString(); + } + + private String getParamProperty(String property) { + // properties entered as 'Label.Title' etc - so strip the first 6 chars + return property.substring(6); // It should not be in lowercase + } +} diff --git a/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/PlayerGetProperties.java b/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/PlayerGetProperties.java index e9f06ac2e64..0dca829dd2c 100644 --- a/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/PlayerGetProperties.java +++ b/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/PlayerGetProperties.java @@ -13,7 +13,10 @@ import java.util.List; import java.util.Map; +import org.apache.commons.lang.StringUtils; import org.openhab.binding.xbmc.rpc.RpcCall; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import com.ning.http.client.AsyncHttpClient; @@ -25,9 +28,12 @@ */ public class PlayerGetProperties extends RpcCall { + private static final Logger logger = LoggerFactory.getLogger(RpcCall.class); + private int playerId; + private List properties; - private boolean paused = false; + private Map item; public PlayerGetProperties(AsyncHttpClient client, String uri) { super(client, uri); @@ -37,6 +43,10 @@ public void setPlayerId(int playerId) { this.playerId = playerId; } + public void setProperties(List properties) { + this.properties = properties; + } + @Override protected String getName() { return "Player.GetProperties"; @@ -44,25 +54,76 @@ protected String getName() { @Override protected Map getParams() { - List properties = new ArrayList(); - properties.add("speed"); - + List paramProperties = new ArrayList(); + for (String property : properties) { + if (property.startsWith("Property.")) { + String paramProperty = getParamProperty(property); + paramProperties.add(paramProperty); + } + } Map params = new HashMap(); params.put("playerid", playerId); - params.put("properties", properties); + params.put("properties", paramProperties); return params; } @Override protected void processResponse(Map response) { Map result = getMap(response, "result"); + // item = getMap(result, "item"); + item = result; + } - if (result.containsKey("speed")) { - paused = (Integer) result.get("speed") == 0; + public String getPropertyValue(String property) { + String paramProperty = getParamProperty(property); + if (!item.containsKey(paramProperty)) { + return null; } + + Object value = item.get(paramProperty); + + if (value instanceof List) { + List values = (List) value; + + // check if list contains any values + if (values.size() == 0) { + return null; + } + + // some properties come back as a list with an indexer + String paramPropertyIndex = getPropertyValue(paramProperty + "id"); + int propertyIndex; + if (!StringUtils.isEmpty(paramPropertyIndex)) { + // attempt to parse the property index + try { + propertyIndex = Integer.parseInt(paramPropertyIndex); + } catch (NumberFormatException e) { + return null; + } + + // check if the index is valid + if (propertyIndex < 0 || propertyIndex >= values.size()) { + return null; + } + } else { + // some properties come back as a list without an indexer, + // e.g. artist, for these we return the first in the list + propertyIndex = 0; + } + + value = values.get(propertyIndex); + } + + if (value == null) { + return null; + } + + return value.toString(); } - public boolean isPaused() { - return paused; + private String getParamProperty(String property) { + // properties entered as 'Property.Title' etc - so strip the first 9 chars + return property.substring(9).toLowerCase(); } + } diff --git a/features/openhab-addons-external/src/main/resources/conf/xbmc.cfg b/features/openhab-addons-external/src/main/resources/conf/xbmc.cfg index 06bb2fb9f8a..1b4e1964548 100644 --- a/features/openhab-addons-external/src/main/resources/conf/xbmc.cfg +++ b/features/openhab-addons-external/src/main/resources/conf/xbmc.cfg @@ -7,9 +7,12 @@ # Port number for the web socket service (optional, defaults to 9090). Example: #livingRoom.wsPort=9090 -# Username to connect to XBMC. (optional, defaults to none). Example: +# Username to connect to XBMC. (optional, defaults to xbmc). Example: #livingRoom.username=xbmc -# Password to connect to XBMC. (optional, defaults to none). Example: +# Password to connect to XBMC. (optional, defaults to xbmc). Example: #livingRoom.password=xbmc +#Refresh interval in ms (optional, defaults to 60000ms [1 minute]) +#refreshInterval=60000 + From d426f559e1f57573ac127b630fa6cc33495351f8 Mon Sep 17 00:00:00 2001 From: giig1967g Date: Sun, 18 Sep 2016 16:15:36 +0200 Subject: [PATCH 3/4] Hi, I added several hundred commands to xbmc binding. 1) can send all 192 input commands supported by Input.ExecuteActions JSON call directly from the items file using Input.ExecuteAction.<> List of commands are in list 1 below. Source: http://kodi.wiki/view/JSON-RPC_API/v6#Input.Action Usage: {xbmc=">[#xbmcinstance|Input.ExecuteAction.<>"} Examples: Switch sXBMC_SHOWOSD "XBMCosd" {xbmc=">[#kodisalotto|Input.ExecuteAction.osd]"} Switch sXBMC_UP "XBMCup" {xbmc=">[#kodisalotto|Input.ExecuteAction.up]"} Switch sXBMC_ASPECTRATIO "XBMCar" {xbmc=">[#kodisalotto|Input.ExecuteAction.aspectratio]"} Switch sXBMC_TOGGLESCREEN "XBMCtf" {xbmc=">[#kodisalotto|Input.ExecuteAction.togglefullscreen]"} 2) can read all 23 Player.Property.Name values: List of commands in list 2 below. Source: http://kodi.wiki/view/JSON-RPC_API/v6#Player.Property.Name Usage: {xbmc="<[#xbmcinstance|Property.<>"} Examples: String sXBMC2 "XBMC2 [%s]" {xbmc="<[#kodisalotto|Property.Type]"} String sXBMC3 "XBMC3 [%s %%]" {xbmc="<[#kodisalotto|Property.Percentage]"} String sXBMC4 "XBMC4 [%s]" {xbmc="<[#kodisalotto|Property.Time]"} String sXBMC5 "XBMC5 [%s]" {xbmc="<[#kodisalotto|Property.TotalTime]"} String sXBMC6 "XBMC6 [%s]" {xbmc="<[#kodisalotto|Property.CurrentSubtitle]"} 3) can Retrieve info labels about Kodi and the system using XBMC.GetInfoLabels List of possible commands in: http://kodi.wiki/index.php?title=InfoLabels (there are hundreds) Usage: {xbmc="<[#xbmcinstance|Label.<>"} Examples: String sXBMC7 "XBMC7 [%s]" {xbmc="<[#kodisalotto|Label.VideoPlayer.Title]"} String sXBMC8 "XBMC8 [%s]" {xbmc="<[#kodisalotto|Label.Player.Time]"} String sXBMC9 "XBMC9 [%s]" {xbmc="<[#kodisalotto|Label.VideoPlayer.VideoResolution]"} String sXBMC10 "XBMC10 [%s]" {xbmc="<[#kodisalotto|Label.VideoPlayer.VideoCodec]"} String sXBMC11 "XBMC11 [%s]" {xbmc="<[#kodisalotto|Label.System.Uptime]"} list1: left right up down pageup pagedown select highlight parentdir parentfolder back previousmenu info pause stop skipnext skipprevious fullscreen aspectratio stepforward stepback bigstepforward bigstepback osd showsubtitles nextsubtitle codecinfo nextpicture previouspicture zoomout zoomin playlist queue zoomnormal zoomlevel1 zoomlevel2 zoomlevel3 zoomlevel4 zoomlevel5 zoomlevel6 zoomlevel7 zoomlevel8 zoomlevel9 nextcalibration resetcalibration analogmove rotate rotateccw close subtitledelayminus subtitledelay subtitledelayplus audiodelayminus audiodelay audiodelayplus subtitleshiftup subtitleshiftdown subtitlealign audionextlanguage verticalshiftup verticalshiftdown nextresolution audiotoggledigital number0 number1 number2 number3 number4 number5 number6 number7 number8 number9 osdleft osdright osdup osddown osdselect osdvalueplus osdvalueminus smallstepback fastforward rewind play playpause delete copy move mplayerosd hidesubmenu screenshot rename togglewatched scanitem reloadkeymaps volumeup volumedown mute backspace scrollup scrolldown analogfastforward analogrewind moveitemup moveitemdown contextmenu shift symbols cursorleft cursorright showtime analogseekforward analogseekback showpreset presetlist nextpreset previouspreset lockpreset randompreset increasevisrating decreasevisrating showvideomenu enter increaserating decreaserating togglefullscreen nextscene previousscene nextletter prevletter jumpsms2 jumpsms3 jumpsms4 jumpsms5 jumpsms6 jumpsms7 jumpsms8 jumpsms9 filter filterclear filtersms2 filtersms3 filtersms4 filtersms5 filtersms6 filtersms7 filtersms8 filtersms9 firstpage lastpage guiprofile red green yellow blue increasepar decreasepar volampup volampdown channelup channeldown previouschannelgroup nextchannelgroup leftclick rightclick middleclick doubleclick wheelup wheeldown mousedrag mousemove noop list 2: canrepeat canmove canshuffle speed percentage playlistid audiostreams position repeat currentsubtitle canrotate canzoom canchangespeed type partymode subtitles canseek time totaltime shuffled currentaudiostream live subtitleenabled --- .../binding/xbmc/internal/XbmcActivator.java | 5 +- .../xbmc/internal/XbmcActiveBinding.java | 29 ++---- .../internal/XbmcGenericBindingProvider.java | 2 + .../binding/xbmc/internal/XbmcHost.java | 2 + .../org/openhab/binding/xbmc/rpc/RpcCall.java | 2 + .../binding/xbmc/rpc/XbmcConnector.java | 89 +++---------------- .../binding/xbmc/rpc/calls/InputBack.java | 43 --------- .../xbmc/rpc/calls/InputContextMenu.java | 43 --------- .../binding/xbmc/rpc/calls/InputDown.java | 43 --------- .../binding/xbmc/rpc/calls/InputHome.java | 43 --------- .../binding/xbmc/rpc/calls/InputInfo.java | 43 --------- .../binding/xbmc/rpc/calls/InputLeft.java | 43 --------- .../binding/xbmc/rpc/calls/InputRight.java | 43 --------- .../binding/xbmc/rpc/calls/InputSelect.java | 43 --------- .../xbmc/rpc/calls/InputShowCodec.java | 43 --------- .../binding/xbmc/rpc/calls/InputShowOSD.java | 43 --------- .../binding/xbmc/rpc/calls/InputUp.java | 43 --------- .../binding/xbmc/rpc/calls/PlayerGetItem.java | 2 + .../xbmc/rpc/calls/PlayerGetLabels.java | 2 + .../xbmc/rpc/calls/PlayerGetProperties.java | 4 +- .../configurations/openhab_default.cfg | 12 +-- 21 files changed, 40 insertions(+), 582 deletions(-) delete mode 100644 bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputBack.java delete mode 100644 bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputContextMenu.java delete mode 100644 bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputDown.java delete mode 100644 bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputHome.java delete mode 100644 bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputInfo.java delete mode 100644 bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputLeft.java delete mode 100644 bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputRight.java delete mode 100644 bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputSelect.java delete mode 100644 bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputShowCodec.java delete mode 100644 bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputShowOSD.java delete mode 100644 bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputUp.java diff --git a/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/internal/XbmcActivator.java b/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/internal/XbmcActivator.java index 6cc7de84479..5a84bdf51f0 100644 --- a/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/internal/XbmcActivator.java +++ b/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/internal/XbmcActivator.java @@ -16,8 +16,11 @@ /** * Extension of the default OSGi bundle activator * - * @author tlan, Ben Jones,plebs + * @author tlan, Ben Jones * @since 1.5.0 + * @author tlan, Ben Jones, Plebs + * @since 1.9.0 + */ public final class XbmcActivator implements BundleActivator { diff --git a/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/internal/XbmcActiveBinding.java b/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/internal/XbmcActiveBinding.java index 6cd3241f3bb..38f37112b3a 100644 --- a/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/internal/XbmcActiveBinding.java +++ b/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/internal/XbmcActiveBinding.java @@ -33,8 +33,10 @@ * All item updates are received asynchronously via the web socket All item * commands are sent via the web socket * - * @author tlan, Ben Jones, Plebs + * @author tlan, Ben Jones * @since 1.5.0 + * @author tlan, Ben Jones, Plebs + * @since 1.9.0 */ public class XbmcActiveBinding extends AbstractActiveBinding implements ManagedService { @@ -311,28 +313,8 @@ protected void internalReceiveCommand(String itemName, Command command) { connector.playerStop(); } else if (property.equals("Input.ExecuteAction")) { connector.inputExecuteAction(command.toString()); - } else if (property.equals("Input.Back")) { - connector.inputBack(); - } else if (property.equals("Input.ContextMenu")) { - connector.inputContextMenu(); - } else if (property.equals("Input.Down")) { - connector.inputDown(); - } else if (property.equals("Input.Home")) { - connector.inputHome(); - } else if (property.equals("Input.Info")) { - connector.inputInfo(); - } else if (property.equals("Input.Left")) { - connector.inputLeft(); - } else if (property.equals("Input.Right")) { - connector.inputRight(); - } else if (property.equals("Input.Select")) { - connector.inputSelect(); - } else if (property.equals("Input.ShowCodec")) { - connector.inputShowCodec(); - } else if (property.equals("Input.ShowOSD")) { - connector.inputShowOSD(); - } else if (property.equals("Input.Up")) { - connector.inputUp(); + } else if (property.startsWith("Input.ExecuteAction.")) { + connector.inputExecuteAction(property.substring(20).toLowerCase()); } else if (property.equals("GUI.ShowNotification")) { connector.showNotification("openHAB", command.toString()); } else if (property.equals("System.Shutdown") && command == OnOffType.OFF) { @@ -455,7 +437,6 @@ public void updated(Dictionary config) throws ConfigurationException if ("password".equals(parts[1])) { host.setPassword(value); } - hosts.put(hostname, host); } diff --git a/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/internal/XbmcGenericBindingProvider.java b/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/internal/XbmcGenericBindingProvider.java index 687c1e6d7a3..18baa351014 100644 --- a/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/internal/XbmcGenericBindingProvider.java +++ b/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/internal/XbmcGenericBindingProvider.java @@ -25,6 +25,8 @@ * * @author tlan, Ben Jones * @since 1.5.0 + * @author tlan, Ben Jones, Plebs + * @since 1.9.0 */ public class XbmcGenericBindingProvider extends AbstractGenericBindingProvider implements XbmcBindingProvider { diff --git a/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/internal/XbmcHost.java b/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/internal/XbmcHost.java index 3a7040c6e0c..9e86d25883f 100644 --- a/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/internal/XbmcHost.java +++ b/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/internal/XbmcHost.java @@ -13,6 +13,8 @@ * * @author tlan, Ben Jones * @since 1.5.0 + * @author tlan, Ben Jones, Plebs + * @since 1.9.0 */ public class XbmcHost { diff --git a/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/RpcCall.java b/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/RpcCall.java index abdaf0adafd..26f3ebf975e 100644 --- a/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/RpcCall.java +++ b/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/RpcCall.java @@ -37,6 +37,8 @@ * * @author tlan, Ben Jones * @since 1.5.0 + * @author tlan, Ben Jones, Plebs + * @since 1.9.0 */ public abstract class RpcCall { diff --git a/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/XbmcConnector.java b/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/XbmcConnector.java index 5c9a486b5f3..63fafd0b935 100644 --- a/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/XbmcConnector.java +++ b/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/XbmcConnector.java @@ -28,18 +28,7 @@ import org.openhab.binding.xbmc.rpc.calls.ApplicationSetVolume; import org.openhab.binding.xbmc.rpc.calls.FilesPrepareDownload; import org.openhab.binding.xbmc.rpc.calls.GUIShowNotification; -import org.openhab.binding.xbmc.rpc.calls.InputBack; -import org.openhab.binding.xbmc.rpc.calls.InputContextMenu; -import org.openhab.binding.xbmc.rpc.calls.InputDown; import org.openhab.binding.xbmc.rpc.calls.InputExecuteAction; -import org.openhab.binding.xbmc.rpc.calls.InputHome; -import org.openhab.binding.xbmc.rpc.calls.InputInfo; -import org.openhab.binding.xbmc.rpc.calls.InputLeft; -import org.openhab.binding.xbmc.rpc.calls.InputRight; -import org.openhab.binding.xbmc.rpc.calls.InputSelect; -import org.openhab.binding.xbmc.rpc.calls.InputShowCodec; -import org.openhab.binding.xbmc.rpc.calls.InputShowOSD; -import org.openhab.binding.xbmc.rpc.calls.InputUp; import org.openhab.binding.xbmc.rpc.calls.JSONRPCPing; import org.openhab.binding.xbmc.rpc.calls.PVRGetChannels; import org.openhab.binding.xbmc.rpc.calls.PlayerGetActivePlayers; @@ -76,6 +65,8 @@ * * @author tlan, Ben Jones, Ard van der Leeuw * @since 1.5.0 + * @author tlan, Ben Jones, Ard van der Leeuw, Plebs + * @since 1.9.0 */ public class XbmcConnector { @@ -138,7 +129,7 @@ public XbmcConnector(XbmcHost xbmc, EventPublisher eventPublisher) { /*** * Check if the connection to the XBMC instance is active - * + * * @return true if an active connection to the XBMC instance exists, false otherwise */ public boolean isConnected() { @@ -152,7 +143,7 @@ public boolean isConnected() { /** * Attempts to create a connection to the XBMC host and begin listening * for updates over the async http web socket - * + * * @throws ExecutionException * @throws InterruptedException * @throws IOException @@ -289,15 +280,16 @@ public void run() { /** * Create a mapping between an item and an xbmc property - * + * * @param itemName * The name of the item which should receive updates * @param property * The property of this xbmc instance, which is to be * watched for changes - * + * */ public void addItem(String itemName, String property) { + logger.debug("Mapping: itemname=" + itemName + " & property = " + property); if (!watches.containsKey(itemName)) { watches.put(itemName, property); } @@ -320,7 +312,7 @@ public void updatePlayerStatus() { /** * Update the status of the current player - * + * * @param updatePolledPropertiesOnly * If updatePolledPropertiesOnly is true, only update the Player properties that need to be polled * If updatePolledPropertiesOnly is false, update the Player state itself as well @@ -413,61 +405,6 @@ public void playerOpen(String file) { playeropen.execute(); } - public void inputBack() { - final InputBack inputback = new InputBack(client, httpUri); - inputback.execute(); - } - - public void inputContextMenu() { - final InputContextMenu inputcontextmenu = new InputContextMenu(client, httpUri); - inputcontextmenu.execute(); - } - - public void inputDown() { - final InputDown inputdown = new InputDown(client, httpUri); - inputdown.execute(); - } - - public void inputHome() { - final InputHome inputhome = new InputHome(client, httpUri); - inputhome.execute(); - } - - public void inputInfo() { - final InputInfo inputinfo = new InputInfo(client, httpUri); - inputinfo.execute(); - } - - public void inputLeft() { - final InputLeft inputleft = new InputLeft(client, httpUri); - inputleft.execute(); - } - - public void inputRight() { - final InputRight inputright = new InputRight(client, httpUri); - inputright.execute(); - } - - public void inputSelect() { - final InputSelect inputselect = new InputSelect(client, httpUri); - inputselect.execute(); - } - - public void inputShowCodec() { - final InputShowCodec inputshowcodec = new InputShowCodec(client, httpUri); - inputshowcodec.execute(); - } - - public void inputShowOSD() { - final InputShowOSD inputshowosd = new InputShowOSD(client, httpUri); - inputshowosd.execute(); - } - - public void inputUp() { - final InputUp inputup = new InputUp(client, httpUri); - inputup.execute(); - } - public void inputExecuteAction(String action) { final InputExecuteAction executeAction = new InputExecuteAction(client, httpUri); executeAction.setAction(action); @@ -611,7 +548,7 @@ public void run() { /** * Request an update for the Player properties from XBMC - * + * * @param playerId * The id of the currently active player */ @@ -621,7 +558,7 @@ private void requestPlayerUpdate(int playerId) { /** * Request an update for the Player properties from XBMC - * + * * @param playerId * The id of the currently active player * @param updatePolledPropertiesOnly @@ -665,7 +602,7 @@ private void requestPlayerUpdate(int playerId, boolean updatePolledPropertiesOnl } } - // make the request for the player item details + // make the request for the player item details using GETINFO if (!propertiesInfo.isEmpty()) { final PlayerGetItem item = new PlayerGetItem(client, httpUri); item.setPlayerId(playerId); @@ -777,7 +714,7 @@ private void updateProperty(String property, OnOffType value) { /** * get a distinct list of player properties we have items configured for - * + * * @return * A list of property names */ @@ -787,7 +724,7 @@ private List getPlayerProperties() { /** * get a distinct list of player properties we have items configured for - * + * * @param updatePolledPropertiesOnly * Only get the properties that need to be refreshed by polling if true, * otherwise get all the properties that have items configured for diff --git a/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputBack.java b/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputBack.java deleted file mode 100644 index b602a5dc289..00000000000 --- a/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputBack.java +++ /dev/null @@ -1,43 +0,0 @@ -/** - * Copyright (c) 2010-2016 by the respective copyright holders. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package org.openhab.binding.xbmc.rpc.calls; - -import java.util.Collections; -import java.util.Map; - -import org.openhab.binding.xbmc.rpc.RpcCall; - -import com.ning.http.client.AsyncHttpClient; - -/** - * Input.Back RPC - * - * @author Il Plebs - * @since 1.5.0 - */ -public class InputBack extends RpcCall { - - public InputBack(AsyncHttpClient client, String uri) { - super(client, uri); - } - - @Override - protected String getName() { - return "Input.Back"; - } - - @Override - protected Map getParams() { - return Collections.emptyMap(); - } - - @Override - protected void processResponse(Map response) { - } -} diff --git a/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputContextMenu.java b/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputContextMenu.java deleted file mode 100644 index 2175387cbed..00000000000 --- a/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputContextMenu.java +++ /dev/null @@ -1,43 +0,0 @@ -/** - * Copyright (c) 2010-2016 by the respective copyright holders. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package org.openhab.binding.xbmc.rpc.calls; - -import java.util.Collections; -import java.util.Map; - -import org.openhab.binding.xbmc.rpc.RpcCall; - -import com.ning.http.client.AsyncHttpClient; - -/** - * Input.ContextMenu RPC - * - * @author Il Plebs - * @since 1.5.0 - */ -public class InputContextMenu extends RpcCall { - - public InputContextMenu(AsyncHttpClient client, String uri) { - super(client, uri); - } - - @Override - protected String getName() { - return "Input.ContextMenu"; - } - - @Override - protected Map getParams() { - return Collections.emptyMap(); - } - - @Override - protected void processResponse(Map response) { - } -} diff --git a/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputDown.java b/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputDown.java deleted file mode 100644 index 5f11d453f57..00000000000 --- a/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputDown.java +++ /dev/null @@ -1,43 +0,0 @@ -/** - * Copyright (c) 2010-2016 by the respective copyright holders. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package org.openhab.binding.xbmc.rpc.calls; - -import java.util.Collections; -import java.util.Map; - -import org.openhab.binding.xbmc.rpc.RpcCall; - -import com.ning.http.client.AsyncHttpClient; - -/** - * Input.Down RPC - * - * @author Il Plebs - * @since 1.5.0 - */ -public class InputDown extends RpcCall { - - public InputDown(AsyncHttpClient client, String uri) { - super(client, uri); - } - - @Override - protected String getName() { - return "Input.Down"; - } - - @Override - protected Map getParams() { - return Collections.emptyMap(); - } - - @Override - protected void processResponse(Map response) { - } -} diff --git a/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputHome.java b/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputHome.java deleted file mode 100644 index 58f63bc320a..00000000000 --- a/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputHome.java +++ /dev/null @@ -1,43 +0,0 @@ -/** - * Copyright (c) 2010-2016 by the respective copyright holders. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package org.openhab.binding.xbmc.rpc.calls; - -import java.util.Collections; -import java.util.Map; - -import org.openhab.binding.xbmc.rpc.RpcCall; - -import com.ning.http.client.AsyncHttpClient; - -/** - * Input.Home RPC - * - * @author Il Plebs - * @since 1.5.0 - */ -public class InputHome extends RpcCall { - - public InputHome(AsyncHttpClient client, String uri) { - super(client, uri); - } - - @Override - protected String getName() { - return "Input.Home"; - } - - @Override - protected Map getParams() { - return Collections.emptyMap(); - } - - @Override - protected void processResponse(Map response) { - } -} diff --git a/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputInfo.java b/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputInfo.java deleted file mode 100644 index 3fc9b0313f6..00000000000 --- a/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputInfo.java +++ /dev/null @@ -1,43 +0,0 @@ -/** - * Copyright (c) 2010-2016 by the respective copyright holders. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package org.openhab.binding.xbmc.rpc.calls; - -import java.util.Collections; -import java.util.Map; - -import org.openhab.binding.xbmc.rpc.RpcCall; - -import com.ning.http.client.AsyncHttpClient; - -/** - * Input.Info RPC - * - * @author Il Plebs - * @since 1.5.0 - */ -public class InputInfo extends RpcCall { - - public InputInfo(AsyncHttpClient client, String uri) { - super(client, uri); - } - - @Override - protected String getName() { - return "Input.Info"; - } - - @Override - protected Map getParams() { - return Collections.emptyMap(); - } - - @Override - protected void processResponse(Map response) { - } -} diff --git a/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputLeft.java b/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputLeft.java deleted file mode 100644 index 6c603eeaacd..00000000000 --- a/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputLeft.java +++ /dev/null @@ -1,43 +0,0 @@ -/** - * Copyright (c) 2010-2016 by the respective copyright holders. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package org.openhab.binding.xbmc.rpc.calls; - -import java.util.Collections; -import java.util.Map; - -import org.openhab.binding.xbmc.rpc.RpcCall; - -import com.ning.http.client.AsyncHttpClient; - -/** - * Input.Left RPC - * - * @author Il Plebs - * @since 1.5.0 - */ -public class InputLeft extends RpcCall { - - public InputLeft(AsyncHttpClient client, String uri) { - super(client, uri); - } - - @Override - protected String getName() { - return "Input.Left"; - } - - @Override - protected Map getParams() { - return Collections.emptyMap(); - } - - @Override - protected void processResponse(Map response) { - } -} diff --git a/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputRight.java b/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputRight.java deleted file mode 100644 index 971d0d237a3..00000000000 --- a/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputRight.java +++ /dev/null @@ -1,43 +0,0 @@ -/** - * Copyright (c) 2010-2016 by the respective copyright holders. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package org.openhab.binding.xbmc.rpc.calls; - -import java.util.Collections; -import java.util.Map; - -import org.openhab.binding.xbmc.rpc.RpcCall; - -import com.ning.http.client.AsyncHttpClient; - -/** - * Input.Right RPC - * - * @author Il Plebs - * @since 1.5.0 - */ -public class InputRight extends RpcCall { - - public InputRight(AsyncHttpClient client, String uri) { - super(client, uri); - } - - @Override - protected String getName() { - return "Input.Right"; - } - - @Override - protected Map getParams() { - return Collections.emptyMap(); - } - - @Override - protected void processResponse(Map response) { - } -} diff --git a/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputSelect.java b/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputSelect.java deleted file mode 100644 index 95215ec1254..00000000000 --- a/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputSelect.java +++ /dev/null @@ -1,43 +0,0 @@ -/** - * Copyright (c) 2010-2016 by the respective copyright holders. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package org.openhab.binding.xbmc.rpc.calls; - -import java.util.Collections; -import java.util.Map; - -import org.openhab.binding.xbmc.rpc.RpcCall; - -import com.ning.http.client.AsyncHttpClient; - -/** - * Input.Select RPC - * - * @author Il Plebs - * @since 1.5.0 - */ -public class InputSelect extends RpcCall { - - public InputSelect(AsyncHttpClient client, String uri) { - super(client, uri); - } - - @Override - protected String getName() { - return "Input.Select"; - } - - @Override - protected Map getParams() { - return Collections.emptyMap(); - } - - @Override - protected void processResponse(Map response) { - } -} diff --git a/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputShowCodec.java b/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputShowCodec.java deleted file mode 100644 index 3ae5e2e60b2..00000000000 --- a/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputShowCodec.java +++ /dev/null @@ -1,43 +0,0 @@ -/** - * Copyright (c) 2010-2016 by the respective copyright holders. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package org.openhab.binding.xbmc.rpc.calls; - -import java.util.Collections; -import java.util.Map; - -import org.openhab.binding.xbmc.rpc.RpcCall; - -import com.ning.http.client.AsyncHttpClient; - -/** - * Input.ShowCodec RPC - * - * @author Il Plebs - * @since 1.5.0 - */ -public class InputShowCodec extends RpcCall { - - public InputShowCodec(AsyncHttpClient client, String uri) { - super(client, uri); - } - - @Override - protected String getName() { - return "Input.ShowCodec"; - } - - @Override - protected Map getParams() { - return Collections.emptyMap(); - } - - @Override - protected void processResponse(Map response) { - } -} diff --git a/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputShowOSD.java b/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputShowOSD.java deleted file mode 100644 index 465fae10df6..00000000000 --- a/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputShowOSD.java +++ /dev/null @@ -1,43 +0,0 @@ -/** - * Copyright (c) 2010-2016 by the respective copyright holders. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package org.openhab.binding.xbmc.rpc.calls; - -import java.util.Collections; -import java.util.Map; - -import org.openhab.binding.xbmc.rpc.RpcCall; - -import com.ning.http.client.AsyncHttpClient; - -/** - * Input.ShowOSD RPC - * - * @author Il Plebs - * @since 1.5.0 - */ -public class InputShowOSD extends RpcCall { - - public InputShowOSD(AsyncHttpClient client, String uri) { - super(client, uri); - } - - @Override - protected String getName() { - return "Input.ShowOSD"; - } - - @Override - protected Map getParams() { - return Collections.emptyMap(); - } - - @Override - protected void processResponse(Map response) { - } -} diff --git a/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputUp.java b/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputUp.java deleted file mode 100644 index 3f2810bd68c..00000000000 --- a/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/InputUp.java +++ /dev/null @@ -1,43 +0,0 @@ -/** - * Copyright (c) 2010-2016 by the respective copyright holders. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package org.openhab.binding.xbmc.rpc.calls; - -import java.util.Collections; -import java.util.Map; - -import org.openhab.binding.xbmc.rpc.RpcCall; - -import com.ning.http.client.AsyncHttpClient; - -/** - * Input.Up RPC - * - * @author Il Plebs - * @since 1.5.0 - */ -public class InputUp extends RpcCall { - - public InputUp(AsyncHttpClient client, String uri) { - super(client, uri); - } - - @Override - protected String getName() { - return "Input.Up"; - } - - @Override - protected Map getParams() { - return Collections.emptyMap(); - } - - @Override - protected void processResponse(Map response) { - } -} diff --git a/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/PlayerGetItem.java b/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/PlayerGetItem.java index 1cab356ce35..722624583d5 100644 --- a/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/PlayerGetItem.java +++ b/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/PlayerGetItem.java @@ -23,6 +23,8 @@ * * @author tlan, Ben Jones, Marcel Erkel * @since 1.5.0 + * @author tlan, Ben Jones, Plebs + * @since 1.9.0 */ public class PlayerGetItem extends RpcCall { diff --git a/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/PlayerGetLabels.java b/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/PlayerGetLabels.java index e4cc0060939..234f7f11fe2 100644 --- a/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/PlayerGetLabels.java +++ b/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/PlayerGetLabels.java @@ -25,6 +25,8 @@ * * @author Ben Jones * @since 1.5.0 + * @author tlan, Ben Jones, Plebs + * @since 1.9.0 */ public class PlayerGetLabels extends RpcCall { diff --git a/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/PlayerGetProperties.java b/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/PlayerGetProperties.java index 0dca829dd2c..6023855aada 100644 --- a/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/PlayerGetProperties.java +++ b/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/PlayerGetProperties.java @@ -23,8 +23,8 @@ /** * Player.GetProperties RPC * - * @author Ben Jones - * @since 1.5.0 + * @author Plebs + * @since 1.9.0 */ public class PlayerGetProperties extends RpcCall { diff --git a/distribution/openhabhome/configurations/openhab_default.cfg b/distribution/openhabhome/configurations/openhab_default.cfg index d7da4a6109e..b80dae8fc8b 100644 --- a/distribution/openhabhome/configurations/openhab_default.cfg +++ b/distribution/openhabhome/configurations/openhab_default.cfg @@ -2473,23 +2473,23 @@ tcp:refreshinterval=250 ################################# XBMC Binding ###################################### -# Hostname / IP address of your XBMC host (required). Example: +# Hostname / IP address of your XBMC host (defaults to 127.0.0.1). #xbmc:livingRoom.host=192.168.1.6 -# Port number for the json rpc service (optional, defaults to 8080). Example: +# Port number for the json rpc service (optional, defaults to 8080). #xbmc:livingRoom.rsPort=8080 -# Port number for the web socket service (optional, defaults to 9090). Example: +# Port number for the web socket service (optional, defaults to 9090). #xbmc:livingRoom.wsPort=9090 -# Username to connect to XBMC. (optional, defaults to xbmc). Example: +# Username to connect to XBMC. (optional, defaults to xbmc). #xbmc:livingRoom.username=xbmc -# Password to connect to XBMC. (optional, defaults to xbmc). Example: +# Password to connect to XBMC. (optional, defaults to xbmc). #xbmc:livingRoom.password=xbmc #Refresh interval in ms (optional, defaults to 60000ms [1 minute]) -#xbmc:refreshInterval= +#xbmc:refreshInterval=60000 ################################ Garadget Binding ################################### # From 79c4fb4438b70b4e912700a28d771eadc5e6b5a2 Mon Sep 17 00:00:00 2001 From: giig1967g Date: Tue, 20 Sep 2016 19:50:10 +0200 Subject: [PATCH 4/4] Modified files according to comments. Also added a new command: "Refresh" to asynch refresh the labels coming from XBMC --- .../openhab/binding/xbmc/internal/XbmcActivator.java | 3 --- .../binding/xbmc/internal/XbmcActiveBinding.java | 7 +++---- .../xbmc/internal/XbmcGenericBindingProvider.java | 2 -- .../org/openhab/binding/xbmc/internal/XbmcHost.java | 2 -- .../java/org/openhab/binding/xbmc/rpc/RpcCall.java | 12 +++++------- .../org/openhab/binding/xbmc/rpc/XbmcConnector.java | 10 ++-------- .../binding/xbmc/rpc/calls/PlayerGetItem.java | 4 +--- .../binding/xbmc/rpc/calls/PlayerGetLabels.java | 6 +----- .../binding/xbmc/rpc/calls/PlayerGetProperties.java | 5 ++--- 9 files changed, 14 insertions(+), 37 deletions(-) diff --git a/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/internal/XbmcActivator.java b/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/internal/XbmcActivator.java index 5a84bdf51f0..8057233d5bf 100644 --- a/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/internal/XbmcActivator.java +++ b/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/internal/XbmcActivator.java @@ -18,9 +18,6 @@ * * @author tlan, Ben Jones * @since 1.5.0 - * @author tlan, Ben Jones, Plebs - * @since 1.9.0 - */ public final class XbmcActivator implements BundleActivator { diff --git a/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/internal/XbmcActiveBinding.java b/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/internal/XbmcActiveBinding.java index 38f37112b3a..3c4466e18fa 100644 --- a/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/internal/XbmcActiveBinding.java +++ b/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/internal/XbmcActiveBinding.java @@ -33,10 +33,8 @@ * All item updates are received asynchronously via the web socket All item * commands are sent via the web socket * - * @author tlan, Ben Jones - * @since 1.5.0 * @author tlan, Ben Jones, Plebs - * @since 1.9.0 + * @since 1.5.0 */ public class XbmcActiveBinding extends AbstractActiveBinding implements ManagedService { @@ -54,7 +52,6 @@ public class XbmcActiveBinding extends AbstractActiveBinding request, Runnable completeHandler) try { // we fire this request off asynchronously and let the completeHandler // process any response as necessary (can be null) - logger.debug("Write JSON: " + writeJson(request)); // Stefano: logging the JSON request - ListenableFuture future = client.preparePost(uri).setBody(writeJson(request)) + String resultWrite = writeJson(request); + logger.debug("Write JSON: {}", resultWrite ); // Stefano: logging the JSON request + ListenableFuture future = client.preparePost(uri).setBody(resultWrite) .setHeader("content-type", "application/json").setHeader("accept", "application/json") .execute(new AsyncCompletionHandler() { @Override public Response onCompleted(Response response) throws Exception { - logger.debug("Read JSON: " + response.getResponseBody()); // Stefano: logging the JSON - // response + logger.debug("Read JSON: {}", response.getResponseBody()); // Stefano: logging the JSON response Map json = readJson(response.getResponseBody()); // if we get an error then throw an exception to stop the diff --git a/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/XbmcConnector.java b/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/XbmcConnector.java index 63fafd0b935..412b814683c 100644 --- a/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/XbmcConnector.java +++ b/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/XbmcConnector.java @@ -63,10 +63,8 @@ /** * Manages the web socket connection for a single XBMC instance. * - * @author tlan, Ben Jones, Ard van der Leeuw - * @since 1.5.0 * @author tlan, Ben Jones, Ard van der Leeuw, Plebs - * @since 1.9.0 + * @since 1.5.0 */ public class XbmcConnector { @@ -289,7 +287,7 @@ public void run() { * */ public void addItem(String itemName, String property) { - logger.debug("Mapping: itemname=" + itemName + " & property = " + property); + logger.debug("Mapping: itemname = {} & property = {}", itemName, property); if (!watches.containsKey(itemName)) { watches.put(itemName, property); } @@ -614,7 +612,6 @@ public void run() { // now update each of the openHAB items for each property for (String property : propertiesInfo) { String value = item.getPropertyValue(property); - // logger.debug("UPDATEfromGETINFO: property=" + property + " & value=" + value); if (property.equals("Player.Fanart")) { updateFanartUrl(property, value); } else { @@ -637,7 +634,6 @@ public void run() { // now update each of the openHAB items for each property for (String property : propertiesProperties) { String value = item2.getPropertyValue(property); - // logger.debug("UPDATEfromGETPROPERTIES: property=" + property + " & value=" + value); updateProperty(property, value); } } @@ -647,7 +643,6 @@ public void run() { // make the request for the player item3 details using GETLABELS if (!propertiesLabels.isEmpty()) { final PlayerGetLabels item3 = new PlayerGetLabels(client, httpUri); - // item3.setPlayerId(playerId); item3.setProperties(propertiesLabels); item3.execute(new Runnable() { @@ -656,7 +651,6 @@ public void run() { // now update each of the openHAB items for each property for (String property : propertiesLabels) { String value = item3.getPropertyValue(property); - // logger.debug("UPDATEfromGETLABELS: property=" + property + " & value=" + value); updateProperty(property, value); } } diff --git a/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/PlayerGetItem.java b/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/PlayerGetItem.java index 722624583d5..cb988eaac3b 100644 --- a/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/PlayerGetItem.java +++ b/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/PlayerGetItem.java @@ -21,10 +21,8 @@ /** * Player.GetItem RPC * - * @author tlan, Ben Jones, Marcel Erkel + * @author tlan, Ben Jones, Marcel Erkel, Plebs * @since 1.5.0 - * @author tlan, Ben Jones, Plebs - * @since 1.9.0 */ public class PlayerGetItem extends RpcCall { diff --git a/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/PlayerGetLabels.java b/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/PlayerGetLabels.java index 234f7f11fe2..bba4138ef66 100644 --- a/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/PlayerGetLabels.java +++ b/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/PlayerGetLabels.java @@ -23,9 +23,7 @@ /** * Player.GetLabels RPC * - * @author Ben Jones - * @since 1.5.0 - * @author tlan, Ben Jones, Plebs + * @author Plebs * @since 1.9.0 */ public class PlayerGetLabels extends RpcCall { @@ -65,7 +63,6 @@ protected Map getParams() { } Map params = new HashMap(); - // params.put("playerid", playerId); params.put("labels", paramProperties); return params; } @@ -73,7 +70,6 @@ protected Map getParams() { @Override protected void processResponse(Map response) { Map result = getMap(response, "result"); - // item = getMap(result, "label"); item = result; } diff --git a/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/PlayerGetProperties.java b/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/PlayerGetProperties.java index 6023855aada..cdd5c636d57 100644 --- a/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/PlayerGetProperties.java +++ b/bundles/binding/org.openhab.binding.xbmc/src/main/java/org/openhab/binding/xbmc/rpc/calls/PlayerGetProperties.java @@ -23,8 +23,8 @@ /** * Player.GetProperties RPC * - * @author Plebs - * @since 1.9.0 + * @author Ben jones, Plebs + * @since 1.5.0 */ public class PlayerGetProperties extends RpcCall { @@ -70,7 +70,6 @@ protected Map getParams() { @Override protected void processResponse(Map response) { Map result = getMap(response, "result"); - // item = getMap(result, "item"); item = result; }