The ping command will not detect device in standby as off (#17358)
This commit is contained in:
1 parent
7b28963a88
commit
e00ed84d84
2 files changed
+7
-58
No files matched your search
@@ -8,8 +8,6 @@ import asyncio
|
||||
from datetime import timedelta
|
||||
import logging
|
||||
import socket
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
@@ -124,24 +122,7 @@ class SamsungTVDevice(MediaPlayerDevice):
|
||||
|
||||
def update(self):
|
||||
"""Update state of device."""
|
||||
if sys.platform == 'win32':
|
||||
timeout_arg = '-w {}000'.format(self._config['timeout'])
|
||||
_ping_cmd = [
|
||||
'ping', '-n 3', timeout_arg, self._config['host']]
|
||||
else:
|
||||
timeout_arg = '-W{}'.format(self._config['timeout'])
|
||||
_ping_cmd = [
|
||||
'ping', '-n', '-q',
|
||||
'-c3', timeout_arg, self._config['host']]
|
||||
|
||||
ping = subprocess.Popen(
|
||||
_ping_cmd,
|
||||
stdout=subprocess.PIPE, stderr=subprocess.DEVNULL)
|
||||
try:
|
||||
ping.communicate()
|
||||
self._state = STATE_ON if ping.returncode == 0 else STATE_OFF
|
||||
except subprocess.CalledProcessError:
|
||||
self._state = STATE_OFF
|
||||
self.send_key("KEY")
|
||||
|
||||
def get_remote(self):
|
||||
"""Create or return a remote control instance."""
|
||||
|
||||
Reference in new issue
Block a user