Use strict timeout when polling Samsung TV (Fix for #6375) (#11759)

This commit is contained in:
kennedyshead 2018-01-22 09:11:16 +01:00 committed by Lewis Juggins
parent 5513ffc33c
commit 0f26ebe954

View File

@ -121,9 +121,14 @@ class SamsungTVDevice(MediaPlayerDevice):
self._config['method'] = 'legacy' self._config['method'] = 'legacy'
def update(self): def update(self):
"""Retrieve the latest data.""" """Update state of device."""
# Send an empty key to see if we are still connected try:
self.send_key('KEY') sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.settimeout(self._config[CONF_TIMEOUT])
sock.connect((self._config['host'], self._config['port']))
self._state = STATE_ON
except socket.error:
self._state = STATE_OFF
def get_remote(self): def get_remote(self):
"""Create or return a remote control instance.""" """Create or return a remote control instance."""