-4

I'm coding a universal controller that controls all smart devices in the house my script runs correctly but show's nothing`

##this is a universal controller
#1_controlling LG Webos smart tv
import os
from pylgtv import WebOsClient
import sys
import logging
class Device:
    counter=0
    def __init__(self,ip,name):
        self.ip=(ip)
        self.name=(name)
        Device.counter += 1
smarttv=Device('192.168.0.105','Smart')

class tv(Device):
    #launching an application
    def launch_app(self):
        logging.basicConfig(stream=sys.stdout, level=logging.INFO)

        try:
            webos_client = WebOsClient(self)
            webos_client.launch_app('com.webos.app.music')

            for app in webos_client.get_apps():
                print(app)
        except:
            print("Error connecting to TV")
OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
Dave
  • 3
  • 1
  • 4

1 Answers1

0

tv should be capitalized since it is a class name

And it is a type of Device, so you can use that instead, and you'll need to call launch_app(), which is only available on an instance of that class, not a Device, so you should assign that to a variable.

You might want to double check what actual objects that WebOsClient accepts as parameters, too. The documentation says it's a IP string, not a tv object

class SmartTV(Device):
    #launching an application
    def launch_app(self, app):
        try:
            webos_client = WebOsClient(self.ip)
            webos_client.launch_app(app)

            for app in webos_client.get_apps():
                print(app)

smarttv = SmartTV('192.168.0.105','Smart')
smarttv.launch_app('com.webos.app.music')  # You're missing this
OneCricketeer
  • 179,855
  • 19
  • 132
  • 245