Skip to content

Conversation

@SmoothMC
Copy link

Fix for LG TVs pre 2012.
Without it cant get the session id

Fix for LG TVs pre 2012.
Without it cant get the session id
@SmoothMC SmoothMC changed the title Update pylgnetcast.py Fix LG TVs pre 2012 (can't get session id) Jul 25, 2024
@splinter98
Copy link
Collaborator

I've had a look at this - and as this logic originates from the prior to this fork - I wanted to see if I can verify if this logic was always incorrect. From the other code I've seen that does looks to be the case.

For my understanding, after you made this change can you confirm if you are also able to get a valid response from the [get_volume](https://github.com/Drafteed/python-lgnetcast/blob/e5781eba2c1d246edfc40163c2a435e88e98f8da/pylgnetcast/pylgnetcast.py#L212) function as this change will also affect that function as well and whilst it seems this PR seems to suggest the HDCP support never worked properly (as authentication didn't work) it be good to ensure we ensure all the features work as expected.

Unfortunately I have a 2012 TV, so I cannot verify any pre-2012 functionality myself.

@Drafteed
Copy link
Owner

Before I switched from wokar/pylgnetcast, HA depended on v0.2.0. HDCP support was added in v0.3.0 (5ad0e36).
HDCP is a very rare case and it seems almost nobody used it. In addition, HA integration does not support the HDCP protocol.

I think we can accept this and in case of problems we will roll back.

Copy link
Owner

@Drafteed Drafteed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For my understanding, after you made this change can you confirm if you are also able to get a valid response from the get_volume function as this change will also affect that function as well and whilst it seems this PR seems to suggest the HDCP support never worked properly (as authentication didn't work) it be good to ensure we ensure all the features work as expected.

After confirmation we can merge.

@SmoothMC
Copy link
Author

I will have a look.
I recognized another issue with the hdcp protocol. The Key Codes are completely different at hdcp.
i will try to find a way to add this key codes to the script

POWER = 8
NUMBER_0 = 16
NUMBER_1 = 17
NUMBER_2 = 18
NUMBER_3 = 19
NUMBER_4 = 20
NUMBER_5 = 21
NUMBER_6 = 22
NUMBER_7 = 23
NUMBER_8 = 24
NUMBER_9 = 25
MUTE_TOGGLE = 9
HOME_MENU = 67
DASH = 76
FLASHBACK = 26
CHANNEL_LIST = 83
OK = 68
CHANNEL_UP = 0
CHANNEL_DOWN = 1
VOLUME_UP = 2
VOLUME_DOWN = 3
UP = 64
DOWN = 65
LEFT = 7
RIGHT = 6
BACK = 40
EXIT = 91
CONFIRM = 68
QUICK_MENU = 69
RED = 114
GREEN = 113
YELLOW = 99
BLUE = 97
LIVE_TV = 158
STOP = 177
PLAY = 176
PAUSE = 186
SKIP_BACKWARD = 143
SKIP_FORWARD = 142
RECORD = 189
EPG = 169
ENERGY_SAVING = 149
AV_MODE = 48
EXTERNAL_INPUT = 11
FAVORITE_CHANNEL = 30
SIMPLINK = 126
ASPECT_RATIO = 121
PROGRAM_INFORMATION = 170
NETCAST = 89
GUIDE = 169
SHOW_SUBTITLE = 57
TELE_TEXT = 32
TEXT_OPTION = 33
AUDIO_DESCRIPTION = 145

@whyscream
Copy link

I have an LG 42LW650S from 2011, and am happy to test or debug this.

I can get a session id with the change in this PR:

python -m pylgnetcast --host 192.168.178.84 --protocol hdcp --verbose                                  

_send_to_tv: message_type=auth, message=<?xml version="1.0" encoding="utf-8"?><auth><type>AuthKeyReq</type></auth>, payload=None
DEBUG:urllib3.connectionpool:Starting new HTTP connection (1): 192.168.178.84:8080
DEBUG:urllib3.connectionpool:http://192.168.178.84:8080 "POST /hdcp/api/auth HTTP/1.1" 200 122
Access token is displayed on TV - use it for the --pairing_key parameter to connect to your TV.

But when trying one of the commands from the list above, I only get HTTP 406 responses (pairing key redacted):

python -m pylgnetcast --host 192.168.178.84 --protocol hdcp --pairing_key FOO --verbose --command 83
_send_to_tv: message_type=auth, message=<?xml version="1.0" encoding="utf-8"?><auth><type>AuthReq</type><value>FOO</value></auth>, payload=None
DEBUG:urllib3.connectionpool:Starting new HTTP connection (1): 192.168.178.84:8080
DEBUG:urllib3.connectionpool:http://192.168.178.84:8080 "POST /hdcp/api/auth HTTP/1.1" 200 150
_send_to_tv: message_type=command, message=<?xml version="1.0" encoding="utf-8"?><command><session>123456789</session><type>HandleKeyInput</type><value>83</value></command>, payload=None
DEBUG:urllib3.connectionpool:Starting new HTTP connection (1): 192.168.178.84:8080
DEBUG:urllib3.connectionpool:http://192.168.178.84:8080 "POST /hdcp/api/command HTTP/1.1" 406 134
Sent command 83
_send_to_tv: message_type=data, message=None, payload={'target': 'cur_channel'}
DEBUG:urllib3.connectionpool:Starting new HTTP connection (1): 192.168.178.84:8080
DEBUG:urllib3.connectionpool:http://192.168.178.84:8080 "GET /hdcp/api/dtv_wifirc?target=cur_channel HTTP/1.1" 406 162
_send_to_tv: message_type=data, message=None, payload={'target': 'volume_info'}
DEBUG:urllib3.connectionpool:Starting new HTTP connection (1): 192.168.178.84:8080
DEBUG:urllib3.connectionpool:http://192.168.178.84:8080 "GET /hdcp/api/dtv_wifirc?target=volume_info HTTP/1.1" 406 162
_send_to_tv: message_type=data, message=None, payload={'target': 'context_ui'}
DEBUG:urllib3.connectionpool:Starting new HTTP connection (1): 192.168.178.84:8080
DEBUG:urllib3.connectionpool:http://192.168.178.84:8080 "GET /hdcp/api/dtv_wifirc?target=context_ui HTTP/1.1" 406 162
_send_to_tv: message_type=data, message=None, payload={'target': 'is_3d'}
DEBUG:urllib3.connectionpool:Starting new HTTP connection (1): 192.168.178.84:8080
DEBUG:urllib3.connectionpool:http://192.168.178.84:8080 "GET /hdcp/api/dtv_wifirc?target=is_3d HTTP/1.1" 406 162

@whyscream
Copy link

I found some docs at https://webostv.developer.lge.com/more/netcast, but no HDCP protocol description yet (only UDAP). If you have any hints, that would be great.

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

Successfully merging this pull request may close these issues.

4 participants