setTVChannel
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 ?
❯ 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.
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"}'}
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.
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('-', '')
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
It looks like the underscores are being stripped out by
parseargsin__init__.py. It callsinton the argument to see if it's a number, but Python'sintis 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?
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!
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
Can you make this a PR?
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.
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 :)
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.
I can add a little bash testing script as well if you'd like
Done :)