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

Added functionality for setting backlight intensity #80

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Remcodebemco
Copy link

https://github.com/bendavid/aiopylgtv found a workaround to access luna URI's that are usually hidden.
I made a script that adds onto, without changing the functionality that is already there. Basically, whever "lunahack.py" is included, it adds on to the "exec_command" function within "WebOSControlBase". Whenever the uri that's given in controls.py contains "luna://" it kicks in, and handles it with the luna hack. Otherwise, it'll behave the same as original.

Feel free to do with this whatever you want, but I think some other people might like this functionality. If this isn't the way to handle pull requests, please tell me; this is my first time ever working with github :'D

@supersaiyanmode
Copy link
Owner

This PR sounds interesting! I have a few questions, however:

  1. What is the user facing behavior when calls to luna:// are being intercept via a system notification?
  2. Can we perhaps merge this behavior with WebOSControlBase directly? I'm personally against the idea of import something and then having behaviors changed behind the scene (via patching).

And some requests (so we can have this PR merged):

  • Can you improve the existing payload template for SystemControl.notify(..) to include buttons, onclose, onfail etc?
  • When uri.startswith('luna://'), can you then create an instance of SystemControl(self.client) in WebOSControlBase.request(..), to intercept the luna call and turn that into a notification?

@jasonlboggs
Copy link

jasonlboggs commented Jun 13, 2024

I just wanted to chime in and say this works quite well. I implemented it in my own wrapper API that handles and simplifies many LG TV commands, but I did need to make one major change. I had an issue where the initial command to set the backlight would succeed, but subsequent calls would fail. I tracked this down to the luna_command method overwriting cmd_info["payload"] on the initial call, replacing the function arguments(0) with the actual value. Subsequent calls always had the original value instead of the function. I simply changed out cmd_info["payload"] with a new processed_payload variable, and then I utilized this below when building the payload variable

        def luna_command(*args, **kwargs):
            processed_payload = process_payload(cmd_info.get("payload"), *args, **kwargs)
            payload = {
                "uri": "ssap://system.notifications/createAlert",
                "payload": {
                        "message": " ",
                        "buttons": [{"label": "", "onClick": cmd_info["uri"], "params": processed_payload}],
                        "onclose": {"uri": cmd_info["uri"], "params": processed_payload},
                        "onfail":  {"uri": cmd_info["uri"], "params": processed_payload},
                    },
                }
            alert_id = original_exec_command(self, "blank", payload)()["alertId"]
            payload = {
                "uri": "ssap://system.notifications/closeAlert",
                "payload": {
                    "alertId": alert_id
                }
            }
            original_exec_command(self, "blank", payload)()

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.

3 participants