supersaiyanmode / PyWebOSTV

Python API for controlling LG TVs (Web OS)
MIT License
271 stars 50 forks source link

Feature request. Add getting state of running app #89

Open OlgaSolod opened 1 year ago

OlgaSolod commented 1 year ago

Hello! For example, some TV can be slowly, so when I run the app, i don't know its current state, and can't be sure, that I can continue to execute another actions with app via code. Now I use sleep for it, but it is still too flaky code. Here is my piece of code:

dev_mode = [x for x in apps if 'developer' in x['title'].lower()][0]
app.launch(dev_mode)
sleep(7) # it needs because smarttv too slowly, may be needed more

Or, may be you can show me more effective way for it?

supersaiyanmode commented 1 year ago

I can think of a few things:

  1. app.subscribe_get_current(..) would let you know when the foreground application has changed. However, this may or may not be what you're looking for. The application could still be loading after this message gets delivered to you.
  2. Can you try app.launch(..., block=True)?
OlgaSolod commented 1 year ago

Thank you for response and recommendations. I will check both of them and will write you the result.