{"id":24540738,"url":"https://github.com/masu-baumgartner/lgconnectws","last_synced_at":"2025-10-28T03:42:33.417Z","repository":{"id":218496541,"uuid":"746580346","full_name":"Masu-Baumgartner/LgConnectWs","owner":"Masu-Baumgartner","description":"A wrapper for the lg connect websocket api in c#","archived":false,"fork":false,"pushed_at":"2024-01-22T10:21:30.000Z","size":14,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-08T13:47:52.961Z","etag":null,"topics":["lg","lgconnect","websocket"],"latest_commit_sha":null,"homepage":"https://www.nuget.org/packages/LgConnectWs","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Masu-Baumgartner.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2024-01-22T09:45:52.000Z","updated_at":"2024-04-18T12:36:50.000Z","dependencies_parsed_at":"2024-01-22T11:20:26.912Z","dependency_job_id":null,"html_url":"https://github.com/Masu-Baumgartner/LgConnectWs","commit_stats":null,"previous_names":["marcel-baumgartner/lgconnectws"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Masu-Baumgartner%2FLgConnectWs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Masu-Baumgartner%2FLgConnectWs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Masu-Baumgartner%2FLgConnectWs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Masu-Baumgartner%2FLgConnectWs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Masu-Baumgartner","download_url":"https://codeload.github.com/Masu-Baumgartner/LgConnectWs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243830914,"owners_count":20354850,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["lg","lgconnect","websocket"],"created_at":"2025-01-22T18:14:48.700Z","updated_at":"2025-10-28T03:42:28.378Z","avatar_url":"https://github.com/Masu-Baumgartner.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"## LgConnectWs\n### A wrapper for the lg connect websocket api in c#\n\n**Description:**\n\nThis little library helps you controlling your tv using the lg connect websocket api.\nSome basic packets have already been implemented, if you want to perform custom operations,\nyou mostly just need to add custom payloads. You can take a look at the example project for more information\n\n**Getting started:**\n\nFirst, search and install the library via [nuget.org](https://www.nuget.org/packages/LgConnectWs)\n\nThe lg connect feature has to be enabled in the network settings in order to work. You will need the ip address of your tv.\n\nThen start with creating a basic client and adding a connect event handler\n\n````csharp\nvar lgConnect = new LgConnect();\n\nlgConnect.Connected += async (_, _) =\u003e\n{\n    Console.WriteLine(\"Connected\");\n    \n    var paringRequest = JsonConvert.DeserializeObject\u003cPairingRequest\u003e(File.ReadAllText(\"pairing.json\"))!;\n    await lgConnect.Send(\"register\", paringRequest);\n};\n\nlgConnect.Disconnected += (sender, eventArgs) =\u003e\n{\n    Console.WriteLine(\"Disconnected\");\n};\n\nawait lgConnect.Connect(\"your ip address here\");\n\nawait Task.Delay(-1);\n````\n\nYou will need to provide a pairing request, i put a json file into the example project for you to use.\nIf you run this program now, you should get a prompt on your tv asking if you want to allow your program to connect.\nYou accept it and now your program and the tv are paired and requests could be sent. To execute code when pairing was successful,\nadd a new event handler like this:\n\n````csharp\nlgConnect.Paired += async (sender, s) =\u003e\n{\n    Console.WriteLine($\"Paired with client id: {s}\");\n\n    // Execute requests here\n};\n````\n\nThe string you get as a parameter is your client id. If you dont want to accept the prompt all the time,\nsave this client id and add it in every pairing request you want to make.\n\n````csharp\nvar paringRequest = JsonConvert.DeserializeObject\u003cPairingRequest\u003e(File.ReadAllText(\"pairing.json\"))!;\n\nparingRequest.ClientKey = \"81cc63d0de8da3117473925398d782ce\";\n\nawait lgConnect.Send(\"register\", paringRequest);\n````\n\nNow we want to switch the channel of your tv, as an example of sending requests.\nEvery request needs a uri which identifies the action you want to perform.\nThese urls are of course not documented ;) All i know of the requests is from [this repo](https://github.com/hobbyquaker/lgtv2)\n\nA request to switch the current channel looks like this:\n\n````csharp\nConsole.WriteLine($\"Paired with client id: {s}\");\n\nawait lgConnect.Request(\"ssap://tv/openChannel\", new OpenChannelPayload()\n{\n   ChannelNumber = \"1\" // in the json its a string as well, dont ask me why :/\n});\n````\n\nThese requests should only be made if you are paired. Otherwise they will fail.\n\nIf you want to retrieve information an easy way is to subscribe to events. You can do this by providing a url and the payload model. The library will handle the rest for you.\n\nA example to track which channel is currently playing:\n\n````csharp\nawait lgConnect.Subscribe\u003cCurrentChannelPayload\u003e(\"ssap://tv/getCurrentChannel\", arg =\u003e\n{\n    Console.WriteLine($\"Current channel: {arg.ChannelNumber}\");\n    return Task.CompletedTask;\n});\n````\n\nThe LgConnect object has some more event handlers to manually handle responses and see errors. Just take a look in the class to find out which events are available","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmasu-baumgartner%2Flgconnectws","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmasu-baumgartner%2Flgconnectws","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmasu-baumgartner%2Flgconnectws/lists"}