Ejemplo n.º 1
0
    def connect(self):

        if not self.is_running():
            self.start()
        RxvLogger.debug("TV connect ip:" + self.ip)
        for i in range(0, 10):
            try:
                lg = WebOSClient(self.ip)
                lg.connect()
            except Exception as e:
                RxvLogger.error("Unable connect TV, retry e: " + str(e))
                time.sleep(3)
            else:
                break
        try:
            for status in lg.register(self.store):
                if status == WebOSClient.PROMPTED:
                    RxvLogger.log("Please accept the connect on the TV!")
                elif status == WebOSClient.REGISTERED:
                    RxvLogger.log("Registration successful!")
                    lg_sys = SystemControl(lg)
                    lg_sys.notify("RxvLG: Registration successful!")
            self.save_store()
            return lg
        except Exception as e:
            RxvLogger.error("Registration failed exiting!")
            RxvLogger.debug("Exception" + str(e))
Ejemplo n.º 2
0
 def setup(self):
     self.check_and_create_store()
     if not self.key_correct():
         RxvLogger.log("LG key required please accept connection on tv:")
         if not self.is_running():
             RxvLogger.log("Turning on TV and wait for boot 10s")
             self.start()
             time.sleep(10)
         self.connect()
Ejemplo n.º 3
0
 def power_off(self):
     self.check_and_create_store()
     lg = self.connect()
     lg_sys = SystemControl(lg)
     RxvLogger.log("TV power off")
     lg_sys.notify("RxvLG: TV will be power off!")
     time.sleep(2)
     lg_sys.power_off()
     lg.close()
     time.sleep(2)
Ejemplo n.º 4
0
 def __init__(self):
     self.running = False
     self.amplifier = RxvLGYamaha(
         "http://192.168.0.4:80/YamahaRemoteControl/ctrl", "RX-V477")
     self.tv = RxvLGTv("192.168.0.6")
     self.tv_running = False
     self.yh_tv_running = False
     self.yh_running = False
     RxvLogger.log("Starting")
     self.tv.setup()
     if self.get_tv_running():
         self.tv.register_volume_control(self.volume_control_callback)
Ejemplo n.º 5
0
    def check_and_create_store(self):
        RxvLogger.debug("TV connect read key")

        try:
            with open(RxvLGTv.KEY_FILE, 'r+') as file:
                self.store = yaml.full_load(file)
        except IOError:
            self.store = {}

        RxvLogger.debug("TV connect key:" + str(self.store))
        if not self.key_correct():
            RxvLogger.log("TV connect key empty will be created")
            self.store = {}
Ejemplo n.º 6
0
 def start(self):
     RxvLogger.log("TV power on")
     trying = 0
     while trying < 10:
         self.run_os_command(
             ['/usr/bin/kodi-send', '-a', 'CECActivateSource'])
         time.sleep(2)
         if self.is_running():
             trying = 11
         elif trying > 10:
             RxvLogger.error("Could not turn on TV")
             return
         else:
             RxvLogger.debug("Retrying connect TV")
             time.sleep(1)
     time.sleep(30)
Ejemplo n.º 7
0
 def power_off_all(self):
     RxvLogger.log("Disconnecting...")
     if self.amplifier.is_running():
         RxvLogger.log("Power off amplifier")
         self.amplifier.power_off()
         self.running = False
     elif self.tv_running:
         RxvLogger.log("Power off TV")
         self.tv.power_off()
         self.running = False
Ejemplo n.º 8
0
 def connect_all(self):
     RxvLogger.log("Connecting...")
     if not self.yh_tv_running:
         RxvLogger.log("Starting amplifier")
         self.amplifier.start_and_connect()
         self.running = True
     elif not self.tv_running:
         RxvLogger.log("Starting TV")
         self.tv.start()
         self.running = True
     self.tv.register_volume_control(self.volume_control_callback)
Ejemplo n.º 9
0
 def __init__(self, url, name):
     RxvLogger.log("Yamaha connect ip: " + url)
     self.rv = rxv.RXV(url, name)
Ejemplo n.º 10
0
 def power_off(self):
     RxvLogger.log("Yamaha power off")
     self.rv.on = False
Ejemplo n.º 11
0
 def start_and_connect(self):
     RxvLogger.log("Yamaha power on")
     self.rv.on = True
     self.rv.input = 'AV1'
Ejemplo n.º 12
0
 def __init__(self, ip):
     self.ip = ip
     RxvLogger.log("TV connect ip: " + self.ip)
     self.store = {}