Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[lgwebos] mediaPlayer does not accept NextPreviousType #7278

Closed
optmax opened this issue Apr 3, 2020 · 15 comments
Closed

[lgwebos] mediaPlayer does not accept NextPreviousType #7278

optmax opened this issue Apr 3, 2020 · 15 comments
Labels
bug An unexpected problem or unintended behavior of an add-on

Comments

@optmax
Copy link

optmax commented Apr 3, 2020

Expected Behavior

Within a mediaPlayer clicking the Next icon should move to the next track
Similarly clicking Previous icon should move to the previous track
(Pause and Play work as PlayPauseType input is accepted)

Current Behavior

==> /var/log/openhab2/openhab.log <==
2020-04-02 21:25:18.529 [DEBUG] [ebos.internal.handler.LGWebOSHandler] - handleCommand(lgwebos:WebOSTV:a3c77ba0-654a-0982-c480-f726662f05b8:mediaPlayer,NEXT)
2020-04-02 21:25:18.534 [INFO ] [.lgwebos.internal.MediaControlPlayer] - Only accept PlayPauseType, RewindFastforwardType, RefreshType. Type was class org.eclipse.smarthome.core.library.types.NextPreviousType.

Possible Solution

Steps to Reproduce (for Bugs)

  1. Create an Item Player with Channel mediaPlayer
  2. Send a command NEXT or Previous (either clicking within Controls on Paper UI or create a Sstemap including a Player and click within Basic UI or create a rule that sends command)

Context

Control apps on webOS TV

Your Environment

Raspberry Pi 3 ARMv7
Raspbian GNU/Linux 9 (stretch)

openHAB 2.5.4 Build #74

LG web OS Binding 2.5.4.202004020414

Item
Player TV_Player { channel="lgwebos:WebOSTV:a3c77ba0-654a-0982-c480-f726662f05b8:mediaPlayer"}

Wihin a Rule
TV_Player.sendCommand( NEXT )

==> /var/log/openhab2/openhab.log <==
2020-04-02 21:25:18.529 [DEBUG] [ebos.internal.handler.LGWebOSHandler] - handleCommand(lgwebos:WebOSTV:a3c77ba0-654a-0982-c480-f726662f05b8:mediaPlayer,NEXT)
2020-04-02 21:25:18.534 [INFO ] [.lgwebos.internal.MediaControlPlayer] - Only accept PlayPauseType, RewindFastforwardType, RefreshType. Type was class org.eclipse.smarthome.core.library.types.NextPreviousType.

@optmax optmax added the bug An unexpected problem or unintended behavior of an add-on label Apr 3, 2020
@lolodomo
Copy link
Contributor

lolodomo commented Apr 3, 2020

@sprehn : do previous and next commands exist in the API? I don't see these commands in the code.
Is the webOS API public or was it reverse engineered?

@sprehn
Copy link
Contributor

sprehn commented Apr 3, 2020

It is all reverse engineered based on connectsdk.

@sprehn
Copy link
Contributor

sprehn commented Apr 3, 2020

option A)
These are the events we can send via the API.
"ssap://media.controls/play";
"ssap://media.controls/pause";
"ssap://media.controls/stop";
"ssap://media.controls/rewind";
"ssap://media.controls/fastForward";

we could simply give it a try, for example with
"ssap://media.controls/next"

No access to my TV at the moment, so cannot try.

option B)
TV_Player.sendCommand( RIGHT )

@optmax
Copy link
Author

optmax commented Apr 3, 2020

@sprehn: Thank you for getting back to me and indeed for all your work on the lgwebos binding.

I am self-isolating due to the coronavirus at the moment and set myself a project to get to grips with openHAB to control my entertainment system. It is proving to be a most enjoyable way to isolate :-)

Option A
Any pointers as to how to implement ssap within my project?

Option B
I have tried
TV_Player.sendCommand( RIGHT )
from inside a rule called "skip"
It generates this error
2020-04-03 23:40:14.540 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'skip': The name 'RIGHT' cannot be resolved to an item or type

But...
For the PLEX app on my webOSTV
TV_RCButton.sendCommand("RIGHT")
via a rcButton channel works :-)

Thanks for the pointer.

@lolodomo
Copy link
Contributor

lolodomo commented Apr 4, 2020

I updated the code to use ssap://media.controls/previous and ssap://media.controls/next but it does not work:

10:35:44.447 [INFO ] [smarthome.event.ItemCommandEvent     ] - Item 'TvPlayer' received command PREVIOUS
10:35:44.499 [DEBUG] [webos.internal.handler.LGWebOSHandler] - handleCommand(lgwebos:WebOSTV:tv:mediaPlayer,PREVIOUS)
10:35:44.511 [TRACE] [ebos.internal.handler.LGWebOSTVSocket] - Message [out]: {"type":"request","id":15,"uri":"ssap://media.controls/previous"}
10:35:44.539 [TRACE] [ebos.internal.handler.LGWebOSTVSocket] - Message [in]: {"type":"error","id":15,"error":"404 no such service or method","payload":{}}
10:35:44.556 [DEBUG] [ebos.internal.handler.LGWebOSTVSocket] - Error: {"type":"error","id":15,"error":"404 no such service or method","payload":{}}
10:35:44.565 [DEBUG] [g.lgwebos.internal.BaseChannelHandler] - MediaControlPlayer received error response: 404 no such service or method
10:35:50.442 [INFO ] [smarthome.event.ItemCommandEvent     ] - Item 'TvPlayer' received command NEXT
10:35:50.512 [DEBUG] [webos.internal.handler.LGWebOSHandler] - handleCommand(lgwebos:WebOSTV:tv:mediaPlayer,NEXT)
10:35:50.522 [TRACE] [ebos.internal.handler.LGWebOSTVSocket] - Message [out]: {"type":"request","id":16,"uri":"ssap://media.controls/next"}
10:35:50.542 [TRACE] [ebos.internal.handler.LGWebOSTVSocket] - Message [in]: {"type":"error","id":16,"error":"404 no such service or method","payload":{}}
10:35:50.553 [DEBUG] [ebos.internal.handler.LGWebOSTVSocket] - Error: {"type":"error","id":16,"error":"404 no such service or method","payload":{}}
10:35:50.562 [DEBUG] [g.lgwebos.internal.BaseChannelHandler] - MediaControlPlayer received error response: 404 no such service or method

Failing too with ssap://media.controls/nextTrack

PS: I tested for the first time play/pause when the Music app is running and it works as expected.

@lolodomo
Copy link
Contributor

lolodomo commented Apr 4, 2020

Now that I checked the code and tested the media player feature, I can see that something is missing in the code, the state of the channels mediaPlayer and mediaStop is never updated.
As an example, when PLAY command is pushed by the user and you receive a positive feedback, you should update the state of these 2 channels accordingly.
I will try to improove that.

@optmax
Copy link
Author

optmax commented Apr 4, 2020

@lolodomo: Thank you for investigating. I am of no help looking at the source code side of things but if there is any testing I can help with in openHAB then do let me know.

@lolodomo
Copy link
Contributor

lolodomo commented Apr 4, 2020

@optmax : unfortunately, this is clearly not obvious to guess what are the SSAP commands to be used for PREVIOUS/NEXT commands. We are not sure they even exist. I just tried the most probable ones but without any success.

@optmax
Copy link
Author

optmax commented Apr 4, 2020

@lomodomo: I have just tried the Next and Previous buttons in the LG TV Plus app on Android and they don’t work! So maybe LG never implemented the code?
Thanks for investigating.

@lolodomo
Copy link
Contributor

@sprehn : if sendRCButton is working with LEFT and RIGHT, we could simply use it as commands for the player item.
I am going to test that.

@lolodomo
Copy link
Contributor

Tested but not really "reliable" because it depends on what was the previous mouse position.

@optmax
Copy link
Author

optmax commented Apr 11, 2020

I've been experimenting with an RCButton sequence and find that its slightly more reliable if you also have a sequence to step back through the PLEX App to the Home page before changing to another input.

I found that starting the 'escape sequnce' with
TV_RCButton.sendCommand("BLUE")
helps if the screensaver is active

@optmax optmax closed this as completed Apr 11, 2020
@memphi2
Copy link

memphi2 commented May 23, 2020

Hi,
I've connected my LG today via Alexa V3 skill and openhab.
I found out, that if i say "NEXT" it's not working, but if i say "FASTFORWARD" it is working!
Two different commands are send to openhab:

Item 'TV_Bed_Player' received command NEXT
Result: Only accept PlayPauseType, RewindFastforwardType, RefreshType.........

Item 'TV_Bed_Player' received command FASTFORWARD
Result: TV_Bed_Player predicted to become FASTFORWARD
TV_Bed_Player changed from PLAY to FASTFORWARD

The Player item in openhab sends "NEXT". If it would send "FASTWORDWARD" the buttons will work.
Regards,
Olli

@memphi2
Copy link

memphi2 commented May 23, 2020

This simple workarourd will do the job:

rule "Set working Player FASTFORWARD Command"
when 
	TV_Player received command NEXT 
then 
	TV_Player.sendCommand(FASTFORWARD)
end

rule "Set working Player PREVIOUS Command"
when 
	TV_Player received command PREVIOUS 
then 
	TV_Player.sendCommand(REWIND)
end

@lolodomo
Copy link
Contributor

The normal commands for the openHAB player widget are play/pause, previopus and next.

memphi2 added a commit to memphi2/openhab-addons that referenced this issue Jun 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An unexpected problem or unintended behavior of an add-on
Projects
None yet
Development

No branches or pull requests

4 participants