kdschlosser / samsungctl

Remote control Samsung televisions via a TCP/IP connection
MIT License
154 stars 33 forks source link

Fix missing connection on Application method #43

Closed matthieut59 closed 5 years ago

matthieut59 commented 5 years ago

Just fixing this using copy/paste but you might want to do something else :) But at least I can get list of application installed on my samsung frame now :)

matthieut59 commented 5 years ago

my bad, was just a dumb copy paste, tested on my smart TV frame, and working

matthieut59 commented 5 years ago

I tested it both remote command and retrieve applications are working

kdschlosser commented 5 years ago

well there is still a glitch in that code as well. I was just using that as an example.

this will cover all of the bases properly

@LogIt
    def send(self, method, **params):
        if self.sock is None:
            if method != 'ms.remote.control':
                if not self._running:
                    try:
                        self.open()
                        return self.send(method, **params)
                    except RuntimeError:
                        pass

            logger.info('Is the TV on???')
            return

        payload = dict(
            method=method,
            params=params
        )
        self.sock.send(json.dumps(payload))
        self.send_event.wait(0.2)