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

setTVChannel #71

Open
grrosminet opened this issue Jan 29, 2021 · 14 comments
Open

setTVChannel #71

grrosminet opened this issue Jan 29, 2021 · 14 comments

Comments

@grrosminet
Copy link

grrosminet commented Jan 29, 2021

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 ?

@bjornreppen
Copy link

❯ 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
Copy link

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"}'}

@klattimer
Copy link
Owner

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
Copy link
Owner

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('-', '')

@rogual
Copy link

rogual commented Nov 29, 2021

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

dragon-gt added a commit to dragon-gt/LGWebOSRemote that referenced this issue Aug 9, 2022
@Tone866
Copy link

Tone866 commented Oct 11, 2023

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?

@TheRoam
Copy link

TheRoam commented Nov 4, 2023

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!

@clownbreath
Copy link
Contributor

clownbreath commented Mar 31, 2024

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

@klattimer
Copy link
Owner

Can you make this a PR?

@clownbreath
Copy link
Contributor

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.

@klattimer
Copy link
Owner

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 :)

@clownbreath
Copy link
Contributor

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
Copy link
Contributor

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

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

@clownbreath
Copy link
Contributor

Done :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants