Add channels for screensaver state and virtual keyboard state (#11984)
Include OnAVStart for playing state detection Fixes: #7542 Signed-off-by: Flole <flole@flole.de>
This commit is contained in:
@@ -45,6 +45,8 @@ public class KodiBindingConstants {
|
||||
public static final String REFRESH_PARAMETER = "refreshInterval";
|
||||
|
||||
// List of all Channel ids
|
||||
public static final String CHANNEL_SCREENSAVER = "screensaver";
|
||||
public static final String CHANNEL_INPUTREQUESTED = "inputrequested";
|
||||
public static final String CHANNEL_MUTE = "mute";
|
||||
public static final String CHANNEL_VOLUME = "volume";
|
||||
public static final String CHANNEL_STOP = "stop";
|
||||
|
||||
@@ -51,7 +51,9 @@ public interface KodiEventListener extends EventListener {
|
||||
|
||||
void updateConnectionState(boolean connected);
|
||||
|
||||
void updateScreenSaverState(boolean screenSaveActive);
|
||||
void updateScreenSaverState(boolean screenSaverActive);
|
||||
|
||||
void updateInputRequestedState(boolean inputRequested);
|
||||
|
||||
void updatePlaylistState(KodiPlaylistState playlistState);
|
||||
|
||||
|
||||
@@ -91,6 +91,8 @@ public class KodiHandler extends BaseThingHandler implements KodiEventListener {
|
||||
private final KodiDynamicCommandDescriptionProvider commandDescriptionProvider;
|
||||
private final KodiDynamicStateDescriptionProvider stateDescriptionProvider;
|
||||
|
||||
private final ChannelUID screenSaverChannelUID;
|
||||
private final ChannelUID inputRequestedChannelUID;
|
||||
private final ChannelUID volumeChannelUID;
|
||||
private final ChannelUID mutedChannelUID;
|
||||
private final ChannelUID favoriteChannelUID;
|
||||
@@ -108,6 +110,8 @@ public class KodiHandler extends BaseThingHandler implements KodiEventListener {
|
||||
this.commandDescriptionProvider = commandDescriptionProvider;
|
||||
this.stateDescriptionProvider = stateDescriptionProvider;
|
||||
|
||||
screenSaverChannelUID = new ChannelUID(getThing().getUID(), CHANNEL_SCREENSAVER);
|
||||
inputRequestedChannelUID = new ChannelUID(getThing().getUID(), CHANNEL_INPUTREQUESTED);
|
||||
volumeChannelUID = new ChannelUID(getThing().getUID(), CHANNEL_VOLUME);
|
||||
mutedChannelUID = new ChannelUID(getThing().getUID(), CHANNEL_MUTE);
|
||||
favoriteChannelUID = new ChannelUID(getThing().getUID(), CHANNEL_PLAYFAVORITE);
|
||||
@@ -141,6 +145,11 @@ public class KodiHandler extends BaseThingHandler implements KodiEventListener {
|
||||
@Override
|
||||
public void handleCommand(ChannelUID channelUID, Command command) {
|
||||
switch (channelUID.getIdWithoutGroup()) {
|
||||
case CHANNEL_SCREENSAVER:
|
||||
if (RefreshType.REFRESH == command) {
|
||||
connection.updateScreenSaverState();
|
||||
}
|
||||
break;
|
||||
case CHANNEL_MUTE:
|
||||
if (command.equals(OnOffType.ON)) {
|
||||
connection.setMute(true);
|
||||
@@ -741,7 +750,13 @@ public class KodiHandler extends BaseThingHandler implements KodiEventListener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateScreenSaverState(boolean screenSaveActive) {
|
||||
public void updateScreenSaverState(boolean screenSaverActive) {
|
||||
updateState(screenSaverChannelUID, OnOffType.from(screenSaverActive));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateInputRequestedState(boolean inputRequested) {
|
||||
updateState(inputRequestedChannelUID, OnOffType.from(inputRequested));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -67,6 +67,7 @@ public class KodiConnection implements KodiClientSocketEventListener {
|
||||
private static final String PROPERTY_FANART = "fanart";
|
||||
private static final String PROPERTY_THUMBNAIL = "thumbnail";
|
||||
private static final String PROPERTY_VERSION = "version";
|
||||
private static final String PROPERTY_SCREENSAVER = "System.ScreensaverActive";
|
||||
private static final String PROPERTY_VOLUME = "volume";
|
||||
private static final String PROPERTY_MUTED = "muted";
|
||||
private static final String PROPERTY_TOTALTIME = "totaltime";
|
||||
@@ -978,7 +979,9 @@ public class KodiConnection implements KodiClientSocketEventListener {
|
||||
} else if (method.startsWith("System.On")) {
|
||||
processSystemStateChanged(method, params);
|
||||
} else if (method.startsWith("GUI.OnScreensaver")) {
|
||||
processScreensaverStateChanged(method, params);
|
||||
processScreenSaverStateChanged(method, params);
|
||||
} else if (method.startsWith("Input.OnInput")) {
|
||||
processInputRequestedStateChanged(method, params);
|
||||
} else if (method.startsWith("Playlist.On")) {
|
||||
processPlaylistStateChanged(method, params);
|
||||
} else {
|
||||
@@ -988,7 +991,7 @@ public class KodiConnection implements KodiClientSocketEventListener {
|
||||
}
|
||||
|
||||
private void processPlayerStateChanged(String method, JsonObject json) {
|
||||
if ("Player.OnPlay".equals(method)) {
|
||||
if ("Player.OnPlay".equals(method) || "Player.OnAVStart".equals(method)) {
|
||||
// get the player id and make a new request for the media details
|
||||
|
||||
JsonObject data = json.get("data").getAsJsonObject();
|
||||
@@ -1059,7 +1062,7 @@ public class KodiConnection implements KodiClientSocketEventListener {
|
||||
}
|
||||
}
|
||||
|
||||
private void processScreensaverStateChanged(String method, JsonObject json) {
|
||||
private void processScreenSaverStateChanged(String method, JsonObject json) {
|
||||
if ("GUI.OnScreensaverDeactivated".equals(method)) {
|
||||
listener.updateScreenSaverState(false);
|
||||
} else if ("GUI.OnScreensaverActivated".equals(method)) {
|
||||
@@ -1070,6 +1073,17 @@ public class KodiConnection implements KodiClientSocketEventListener {
|
||||
listener.updateConnectionState(true);
|
||||
}
|
||||
|
||||
private void processInputRequestedStateChanged(String method, JsonObject json) {
|
||||
if ("Input.OnInputFinished".equals(method)) {
|
||||
listener.updateInputRequestedState(false);
|
||||
} else if ("Input.OnInputRequested".equals(method)) {
|
||||
listener.updateInputRequestedState(true);
|
||||
} else {
|
||||
logger.debug("Unknown event from Kodi {}: {}", method, json);
|
||||
}
|
||||
listener.updateConnectionState(true);
|
||||
}
|
||||
|
||||
private void processPlaylistStateChanged(String method, JsonObject json) {
|
||||
if ("Playlist.OnAdd".equals(method)) {
|
||||
currentPlaylistState = KodiPlaylistState.ADDED;
|
||||
@@ -1091,6 +1105,25 @@ public class KodiConnection implements KodiClientSocketEventListener {
|
||||
}
|
||||
}
|
||||
|
||||
public void updateScreenSaverState() {
|
||||
if (socket.isConnected()) {
|
||||
String[] props = { PROPERTY_SCREENSAVER };
|
||||
|
||||
JsonObject params = new JsonObject();
|
||||
params.add("booleans", getJsonArray(props));
|
||||
JsonElement response = socket.callMethod("XBMC.GetInfoBooleans", params);
|
||||
|
||||
if (response instanceof JsonObject) {
|
||||
JsonObject data = response.getAsJsonObject();
|
||||
if (data.has(PROPERTY_SCREENSAVER)) {
|
||||
listener.updateScreenSaverState(data.get(PROPERTY_SCREENSAVER).getAsBoolean());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
listener.updateScreenSaverState(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void updateVolume() {
|
||||
if (socket.isConnected()) {
|
||||
String[] props = { PROPERTY_VOLUME, PROPERTY_MUTED };
|
||||
|
||||
@@ -311,6 +311,8 @@ channel-type.kodi.inputaction.state.option.error = error
|
||||
channel-type.kodi.inputaction.state.option.noop = noop
|
||||
channel-type.kodi.inputbuttonevent.label = Sends a button press event as Input
|
||||
channel-type.kodi.inputbuttonevent.description = Sends a generic button press event to Kodi
|
||||
channel-type.kodi.inputrequested.label = Input requested
|
||||
channel-type.kodi.inputrequested.description = Status that shows if Kodi is asking for user input.
|
||||
channel-type.kodi.inputtext.label = Sends Text as Input
|
||||
channel-type.kodi.inputtext.description = Sends a generic input (unicode) text to Kodi
|
||||
channel-type.kodi.language.label = Language
|
||||
@@ -337,6 +339,8 @@ channel-type.kodi.pvr-open-tv.label = Play PVR TV
|
||||
channel-type.kodi.pvr-open-tv.description = Play the given PVR TV channel by sending a command with the channel's name
|
||||
channel-type.kodi.rating.label = Rating
|
||||
channel-type.kodi.rating.description = Rating
|
||||
channel-type.kodi.screensaver.label = Screensaver
|
||||
channel-type.kodi.screensaver.description = Status of the screensaver
|
||||
channel-type.kodi.shownotification.label = Show Notification
|
||||
channel-type.kodi.shownotification.description = Shows a notification on the UI
|
||||
channel-type.kodi.showtitle.label = Show Title
|
||||
|
||||
@@ -110,6 +110,8 @@
|
||||
<channel id="userrating" typeId="rating">
|
||||
<label>User Rating</label>
|
||||
</channel>
|
||||
<channel id="screensaver" typeId="screensaver"/>
|
||||
<channel id="inputrequested" typeId="inputrequested"/>
|
||||
</channels>
|
||||
|
||||
<properties>
|
||||
@@ -560,4 +562,16 @@
|
||||
<description>Profile of Kodi</description>
|
||||
<state pattern="%s"/>
|
||||
</channel-type>
|
||||
<channel-type id="screensaver">
|
||||
<item-type>Switch</item-type>
|
||||
<label>Screensaver</label>
|
||||
<description>Status of the screensaver</description>
|
||||
<state readOnly="true"/>
|
||||
</channel-type>
|
||||
<channel-type id="inputrequested">
|
||||
<item-type>Switch</item-type>
|
||||
<label>Input requested</label>
|
||||
<description>Status that shows if Kodi is asking for user input.</description>
|
||||
<state readOnly="true"/>
|
||||
</channel-type>
|
||||
</thing:thing-descriptions>
|
||||
|
||||
Reference in New Issue
Block a user