Tenzer/alga

channel set error

AlfredoCubitos opened this issue · 17 comments

when I call
lga channel current
I get his output:
The current channel is Euronews (158)
When I call
alga channel set 158
I get the following error:

cli_channel.py:42 in set                                                                                                                                                                                  │
│                                                                                                                                                                                                         │
│   39 def set(value: Annotated[int, Argument()]) -> None:                                      ╭── locals ───╮                                                                                           │
│   40 │   """Change to specific channel"""                                                     │ value = 168 │                                                                                           │
│   41 │                                                                                        ╰─────────────╯                                                                                           │
│ ❱ 42 │   client.request("ssap://tv/openChannel", {"channelNumber": value})                                                                                                                              │
│   43                                                                                                                                                                                                    │
│   44                                                                                                                                                                                                    │
│   45 @app.command()                                                                                                                                                                                     │
│                                                                                                                                                                                                         │
│ /client.py:63 in request                                                                                                                                                                                │
│                                                                                                                                                                                                         │
│   60 │   │   raw_response = connection.recv()                                                 ╭─────────────────────────────────────────────── locals ────────────────────────────────────────────────╮ │
│   61 │   │   response = json.loads(raw_response)                                              │   connection = <websocket._core.WebSocket object at 0x7f88c6a29190>                                   │ │
│   62 │   │                                                                                    │         data = {'channelNumber': 168}                                                                 │ │
│ ❱ 63 │   │   assert response.get("payload", {}).get("returnValue") is True                    │ raw_response = '{"type":"error","error":"500 Application error","payload":{"returnValue":false}}'     │ │
│   64 │   │   return cast(dict[str, Any], response["payload"])                                 │      request = {'type': 'request', 'uri': 'ssap://tv/openChannel', 'payload': {'channelNumber': 168}} │ │
│   65                                                                                          │     response = {'type': 'error', 'error': '500 Application error', 'payload': {'returnValue': False}} │ │
│                                                                                               │          uri = 'ssap://tv/openChannel'                                                                │ │
│                                                                                               ╰───────────────────────────────────────────────────────────────────────────────────────────────────────╯ │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

any idea whats going wrong

Tenzer commented

According to the output you have posted, it looks like you are changing the channel to 168. Is that correct? Is that a valid channel? Does it work with other channel numbers?

Tenzer commented

I just tried to change to a TV channel that doesn't exist on my TV (108) and it gave me this error message (I have cleaned up the output a bit):

connection = <websocket._core.WebSocket object at 0x10668c110>
data = {'channelNumber': 108}
raw_response = '{"type":"error","error":"500 Application error","payload":{"returnValue":false,"'+86
request = {'type': 'request', 'uri': 'ssap://tv/openChannel', 'payload': {'channelNumber': 108}}
response = {
    'type': 'error',
    'error': '500 Application error',
    'payload': {
        'returnValue': False,
        'errorCode': 'CHANNEL_ERROR_9',
        'errorText': 'return value of interface func. is not ok'
    }
}
uri = 'ssap://tv/openChannel'

The error message broadly looks similar, although it also contains a CHANNEL_ERROR_9 reference. I guess different versions of webOS might have different responses to this kind of issue.

yes, it seems that I put a wrong channel number. I edited the content after posting and I made an error.
I'm sorry.

So, I used the channel number which I get first, then I tried to change the channel with the number I got and It throws the error every time. Doesn't matter which channel number I used, every time it throws this error. :-(

I think I found the problem.
It seems that my TV does not support channel change by channel numbers, my TV needs a channel id.

Tenzer commented

That is what I was wondering as well. Can I ask which model of TV you've got?

Does the other channel ... commands work? channel list, channel up and channel down?

my Model is: 50UN73006LA
All other channel commands are working well :-)

Tenzer commented

Okay, well, that's annoying.

You can try to run alga adhoc ssap://tv/getChannelList. It will give you the raw output from the TV about the channels available. You can then take one of the channelId values and provide to: `alga ad-hoc ssap://tv/openChannel '{"channelId": ""}' to see if that allows you to change the channel.

The channel IDs on my TV are annoyingly long, so wouldn't be easy to enter manually.

I might need to make a UI component where you would get the list of channels like what alga channel list provides, but which then lets you pick what channel you want to see from the list, so it isn't necessary to enter the channel ID.

yes, the command 'alga ad-hoc ssap://tv/openChannel '{"channelId": ""}' works well. :-)
I can change the channel with this command.

Tenzer commented

Thank you for confirming. I'll try to see if I can make an interactive command for setting the channel by picking the channel from a list. It can then use the channelId under the hood.

thank you, that would be nice :-)
You can output the channel id with the channel list command and add a new command something like:
channel setbyid

Tenzer commented

I found a simpler way to fix this. I have just released version 1.2.1 with the fix. alga channel set will now allow you to either provide a channel ID or a channel number. If a channel number is provided, alga will look up the channel ID for the number, and send that to the TV.

Please try it out and let me know if it doesn't work.

is the new version available with pipx?

Tenzer commented

Yes, you can update with pipx upgrade alga.

ok, it works fine. :-)
But I need also a way to get the channel id. Can you add the id to the channel list command?
And, is there a way to get the channels from the favorite list?

Tenzer commented

You should be able to enter the channel number directly, so you can for instance enter alga channel set 158 and the channel will then be changed by using the channel ID under the hood.

I'm not aware of any way of accessing favourited channels. It's not a feature I use myself, either, so I must admit it's not something I've been looking for.

I can see the raw output from alga adhoc ssap://tv/getChannelList includes a 'favoriteGroup': [] entry for each channel for me. It might be it's possible to filter out the channels which aren't favourites based on that.

aah, ok.
That works also. :-)
Thank you!!

Tenzer commented

You're welcome!