LGWebOSRemote icon indicating copy to clipboard operation
LGWebOSRemote copied to clipboard

setTVChannel

Open grrosminet opened this issue 4 years ago • 14 comments

Hi

I've a LG TV model :

{
   "returnValue":true,
   "product_name":"webOSTV 3.0",
   "model_name":"HE_DTV_W16N_AFADABAA",
   "sw_type":"FIRMWARE",
   "major_ver":"05",
   "minor_ver":"50.95",
   "country":"EU7",
   "country_group":"EU",
   "device_id":"c8:08:e9:c4:41:d2",
   "auth_flag":"N",
   "ignore_disable":"N",
   "eco_info":"01",
   "config_key":"00",
   "language_code":"fr-FR"
}

getTVChannel returns this data :

{
   "type":"response",
   "id":"channels_0",
   "payload":{
      "returnValue":true,
      "channelId":"1_29_1_1_6_1537_8442",
      "signalChannelId":"6_1537_8442",
      "channelModeId":0,
      "channelModeName":"Terrestrial",
      "channelTypeId":1,
      "channelTypeName":"Terrestrial Digital TV",
      "channelNumber":"1",
      "channelName":"TF1",
      "physicalNumber":29,
      "isSkipped":false,
      "isLocked":false,
      "isDescrambled":false,
      "isScrambled":false,
      "isFineTuned":false,
      "isInvisible":false,
      "isHEVCChannel":false,
      "favoriteGroup":null,
      "hybridtvType":"HBBTV",
      "dualChannel":{
         "dualChannelId":null,
         "dualChannelTypeId":null,
         "dualChannelTypeName":null,
         "dualChannelNumber":null
      }
   }
}

I have tried several channelId with setTVChannel

lgtv TV setTVChannel 1
lgtv TV setTVChannel 6_1537_8442
lgtv TV setTVChannel 1_29_1_1_6_1537_8442

But I still have the same error :

{
   "type":"error",
   "id":"0",
   "error":"500 Application error",
   "payload":{
      "returnValue":false,
      "errorCode":-1000,
      "errorText":"invalid channel id"
   }
}

Any idea what's wrong ?

grrosminet avatar Jan 29 '21 19:01 grrosminet

❯ lgtv stue setTVChannel 3_9_17_17_4_7227_70
DEBUG:root:{'id': '0', 'type': 'request', 'uri': 'ssap://tv/openChannel', 'payload': '{"channelId": 3917174722770}'}

From the log it looks like the client is stripping out the underscores before sending it to the TV.

bjornreppen avatar Jul 21 '21 11:07 bjornreppen

A workaround that seems to work is to change one of the underscores to a dash:

❯ lgtv stue setTVChannel 3-9_17_17_4_7227_70
DEBUG:root:{'id': '0', 'type': 'request', 'uri': 'ssap://tv/openChannel', 'payload': '{"channelId": "3-9_17_17_4_7227_70"}'}

bjornreppen avatar Jul 21 '21 12:07 bjornreppen

Thanks for this bug report, I honestly have the opinion (and I've looked it through about a dozen times), that this is entirely LG's fault. In API terms, having a value intended to be sent back in a different form that it was provided is just absurd. I imagine they have a "reason" and I suspect it's laziness.

klattimer avatar Jul 25 '21 06:07 klattimer

That's not to say I won't accept a pull request - if someone wants to make one - it should be as simple as modifying the set channel method to strip the - characters out. str.replace('-', '')

klattimer avatar Jul 25 '21 06:07 klattimer

It looks like the underscores are being stripped out by parseargs in __init__.py. It calls int on the argument to see if it's a number, but Python's int is quite permissive:

>>> int('1_2_3')
123

rogual avatar Nov 29 '21 16:11 rogual

It looks like the underscores are being stripped out by parseargs in __init__.py. It calls int on the argument to see if it's a number, but Python's int is quite permissive:

>>> int('1_2_3')
123

Thanks for your workaround, it worked for me for me long time, but now I had to new install the program and the fix seems to be no longer working. Do you have an idea what could be the issue now?

Tone866 avatar Oct 11 '23 19:10 Tone866

Hi, I just faced the same issue. The underscores are still being stripped, so you need to fake the string to make it a more evident string, like concatenating some of its elements with separate string. E.g.:

lgtv myTv setTVChannel "1"+"_22_2_0_1016_578_8916"

That worked for me!

TheRoam avatar Nov 04 '23 00:11 TheRoam

My solution works, if the command is setTVChannel skip the changing to int type

if command == "setTVChannel":
    # ILB
else:
    f = int(argv[i])
    argv[i] = f

file: lib64/python3.10/site-packages/LGTV/init.py function: parseargs() line: ~45

clownbreath avatar Mar 31 '24 21:03 clownbreath

Can you make this a PR?

klattimer avatar Mar 31 '24 21:03 klattimer

I don't know what that is. I have had a sheltered career of working on projects with myself or a crack team that handled GIT.

If you tell me what to do I'll be happy to do it.

clownbreath avatar Apr 02 '24 03:04 clownbreath

Meh, it's easy.

Hit the fork button - then you'll have a copy of the repository in your repositories.

Change the file or files you want to merge into the project.

Commit, push, then a create pull request button will appear for you, press it, fill out the form and you're good. Then I'll check it here, press the merge button, and you earn a merit badge from GitHub :)

klattimer avatar Apr 02 '24 08:04 klattimer

I'll do it. As soon as I'm able to get all the other functions to work. Can't have regression tests yet. I can use pause/play/stop but can't send buttons like ENTER or LEFT.

I can start Youtube videos. Lot's of functionality left to verify.

clownbreath avatar Apr 02 '24 12:04 clownbreath

Screenshot from 2024-04-02 08-00-52

I can add a little bash testing script as well if you'd like

clownbreath avatar Apr 02 '24 13:04 clownbreath

Done :)

clownbreath avatar Apr 27 '24 16:04 clownbreath