2019-04-03 15:40:03 +00:00
|
|
|
"""Support for interface with an Samsung TV."""
|
2018-06-26 14:22:10 +00:00
|
|
|
import asyncio
|
2018-09-09 12:26:06 +00:00
|
|
|
from datetime import timedelta
|
2016-12-16 06:20:00 +00:00
|
|
|
import socket
|
2018-01-29 22:55:39 +00:00
|
|
|
|
2019-11-05 14:04:19 +00:00
|
|
|
from samsungctl import exceptions as samsung_exceptions, Remote as SamsungRemote
|
2016-09-05 17:22:26 +00:00
|
|
|
import voluptuous as vol
|
2019-11-05 14:04:19 +00:00
|
|
|
import wakeonlan
|
2019-11-25 09:45:50 +00:00
|
|
|
from websocket import WebSocketException
|
2016-09-05 17:22:26 +00:00
|
|
|
|
2019-10-24 20:41:07 +00:00
|
|
|
from homeassistant.components.media_player import (
|
|
|
|
MediaPlayerDevice,
|
|
|
|
PLATFORM_SCHEMA,
|
|
|
|
DEVICE_CLASS_TV,
|
|
|
|
)
|
2019-02-08 22:18:18 +00:00
|
|
|
from homeassistant.components.media_player.const import (
|
2019-07-31 19:25:30 +00:00
|
|
|
MEDIA_TYPE_CHANNEL,
|
|
|
|
SUPPORT_NEXT_TRACK,
|
|
|
|
SUPPORT_PAUSE,
|
|
|
|
SUPPORT_PLAY,
|
|
|
|
SUPPORT_PLAY_MEDIA,
|
|
|
|
SUPPORT_PREVIOUS_TRACK,
|
|
|
|
SUPPORT_SELECT_SOURCE,
|
|
|
|
SUPPORT_TURN_OFF,
|
|
|
|
SUPPORT_TURN_ON,
|
|
|
|
SUPPORT_VOLUME_MUTE,
|
|
|
|
SUPPORT_VOLUME_STEP,
|
|
|
|
)
|
2016-01-31 09:06:39 +00:00
|
|
|
from homeassistant.const import (
|
2019-11-17 12:17:22 +00:00
|
|
|
CONF_BROADCAST_ADDRESS,
|
2019-07-31 19:25:30 +00:00
|
|
|
CONF_HOST,
|
|
|
|
CONF_MAC,
|
|
|
|
CONF_NAME,
|
|
|
|
CONF_PORT,
|
|
|
|
CONF_TIMEOUT,
|
|
|
|
STATE_OFF,
|
|
|
|
STATE_ON,
|
|
|
|
)
|
2016-09-05 17:22:26 +00:00
|
|
|
import homeassistant.helpers.config_validation as cv
|
2017-12-03 17:34:45 +00:00
|
|
|
from homeassistant.util import dt as dt_util
|
2016-01-31 21:17:00 +00:00
|
|
|
|
2019-10-25 12:32:12 +00:00
|
|
|
from .const import LOGGER
|
2016-01-31 09:06:39 +00:00
|
|
|
|
2019-07-31 19:25:30 +00:00
|
|
|
DEFAULT_NAME = "Samsung TV Remote"
|
2018-10-09 19:43:59 +00:00
|
|
|
DEFAULT_TIMEOUT = 1
|
2019-11-17 12:17:22 +00:00
|
|
|
DEFAULT_BROADCAST_ADDRESS = "255.255.255.255"
|
2016-01-31 18:12:00 +00:00
|
|
|
|
2018-09-09 12:26:06 +00:00
|
|
|
KEY_PRESS_TIMEOUT = 1.2
|
2019-07-31 19:25:30 +00:00
|
|
|
KNOWN_DEVICES_KEY = "samsungtv_known_devices"
|
2019-10-25 12:32:12 +00:00
|
|
|
METHODS = ("websocket", "legacy")
|
2019-07-31 19:25:30 +00:00
|
|
|
SOURCES = {"TV": "KEY_TV", "HDMI": "KEY_HDMI"}
|
|
|
|
|
|
|
|
SUPPORT_SAMSUNGTV = (
|
|
|
|
SUPPORT_PAUSE
|
|
|
|
| SUPPORT_VOLUME_STEP
|
|
|
|
| SUPPORT_VOLUME_MUTE
|
|
|
|
| SUPPORT_PREVIOUS_TRACK
|
|
|
|
| SUPPORT_SELECT_SOURCE
|
|
|
|
| SUPPORT_NEXT_TRACK
|
|
|
|
| SUPPORT_TURN_OFF
|
|
|
|
| SUPPORT_PLAY
|
|
|
|
| SUPPORT_PLAY_MEDIA
|
|
|
|
)
|
|
|
|
|
|
|
|
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
|
|
|
{
|
|
|
|
vol.Required(CONF_HOST): cv.string,
|
|
|
|
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
|
2019-10-25 12:32:12 +00:00
|
|
|
vol.Optional(CONF_PORT): cv.port,
|
2019-07-31 19:25:30 +00:00
|
|
|
vol.Optional(CONF_MAC): cv.string,
|
2019-11-17 12:17:22 +00:00
|
|
|
vol.Optional(
|
|
|
|
CONF_BROADCAST_ADDRESS, default=DEFAULT_BROADCAST_ADDRESS
|
|
|
|
): cv.string,
|
2019-07-31 19:25:30 +00:00
|
|
|
vol.Optional(CONF_TIMEOUT, default=DEFAULT_TIMEOUT): cv.positive_int,
|
|
|
|
}
|
|
|
|
)
|
2016-09-05 17:22:26 +00:00
|
|
|
|
2016-01-31 09:06:39 +00:00
|
|
|
|
2018-08-24 14:37:30 +00:00
|
|
|
def setup_platform(hass, config, add_entities, discovery_info=None):
|
2017-05-02 16:18:47 +00:00
|
|
|
"""Set up the Samsung TV platform."""
|
2016-12-16 06:20:00 +00:00
|
|
|
known_devices = hass.data.get(KNOWN_DEVICES_KEY)
|
|
|
|
if known_devices is None:
|
|
|
|
known_devices = set()
|
|
|
|
hass.data[KNOWN_DEVICES_KEY] = known_devices
|
|
|
|
|
2018-11-02 09:50:07 +00:00
|
|
|
uuid = None
|
2016-12-16 06:20:00 +00:00
|
|
|
# Is this a manual configuration?
|
|
|
|
if config.get(CONF_HOST) is not None:
|
|
|
|
host = config.get(CONF_HOST)
|
|
|
|
port = config.get(CONF_PORT)
|
|
|
|
name = config.get(CONF_NAME)
|
2017-02-21 15:57:29 +00:00
|
|
|
mac = config.get(CONF_MAC)
|
2019-11-17 12:17:22 +00:00
|
|
|
broadcast = config.get(CONF_BROADCAST_ADDRESS)
|
2016-12-16 06:20:00 +00:00
|
|
|
timeout = config.get(CONF_TIMEOUT)
|
|
|
|
elif discovery_info is not None:
|
2019-07-31 19:25:30 +00:00
|
|
|
tv_name = discovery_info.get("name")
|
|
|
|
model = discovery_info.get("model_name")
|
|
|
|
host = discovery_info.get("host")
|
2019-09-03 19:14:39 +00:00
|
|
|
name = f"{tv_name} ({model})"
|
2019-10-25 12:32:12 +00:00
|
|
|
if name.startswith("[TV]"):
|
|
|
|
name = name[4:]
|
|
|
|
port = None
|
2016-12-16 06:20:00 +00:00
|
|
|
timeout = DEFAULT_TIMEOUT
|
2017-03-05 22:52:15 +00:00
|
|
|
mac = None
|
2019-11-17 12:17:22 +00:00
|
|
|
broadcast = DEFAULT_BROADCAST_ADDRESS
|
2019-10-25 12:32:12 +00:00
|
|
|
uuid = discovery_info.get("udn")
|
|
|
|
if uuid and uuid.startswith("uuid:"):
|
|
|
|
uuid = uuid[len("uuid:") :]
|
2016-12-16 06:20:00 +00:00
|
|
|
|
|
|
|
# Only add a device once, so discovered devices do not override manual
|
|
|
|
# config.
|
|
|
|
ip_addr = socket.gethostbyname(host)
|
|
|
|
if ip_addr not in known_devices:
|
|
|
|
known_devices.add(ip_addr)
|
2019-11-17 12:17:22 +00:00
|
|
|
add_entities([SamsungTVDevice(host, port, name, timeout, mac, broadcast, uuid)])
|
2019-10-25 12:32:12 +00:00
|
|
|
LOGGER.info("Samsung TV %s added as '%s'", host, name)
|
2016-12-16 06:20:00 +00:00
|
|
|
else:
|
2019-10-25 12:32:12 +00:00
|
|
|
LOGGER.info("Ignoring duplicate Samsung TV %s", host)
|
2016-01-31 09:06:39 +00:00
|
|
|
|
|
|
|
|
|
|
|
class SamsungTVDevice(MediaPlayerDevice):
|
2016-03-08 09:34:33 +00:00
|
|
|
"""Representation of a Samsung TV."""
|
2016-01-31 09:06:39 +00:00
|
|
|
|
2019-11-17 12:17:22 +00:00
|
|
|
def __init__(self, host, port, name, timeout, mac, broadcast, uuid):
|
2016-09-05 17:22:26 +00:00
|
|
|
"""Initialize the Samsung device."""
|
2019-07-31 19:25:30 +00:00
|
|
|
|
2017-01-03 22:28:23 +00:00
|
|
|
# Save a reference to the imported classes
|
2016-01-31 09:06:39 +00:00
|
|
|
self._name = name
|
2017-02-21 15:57:29 +00:00
|
|
|
self._mac = mac
|
2019-11-17 12:17:22 +00:00
|
|
|
self._broadcast = broadcast
|
2018-11-02 09:50:07 +00:00
|
|
|
self._uuid = uuid
|
2016-01-31 09:06:39 +00:00
|
|
|
# Assume that the TV is not muted
|
|
|
|
self._muted = False
|
|
|
|
# Assume that the TV is in Play mode
|
|
|
|
self._playing = True
|
2018-10-15 09:42:27 +00:00
|
|
|
self._state = None
|
2016-01-31 09:06:39 +00:00
|
|
|
self._remote = None
|
2017-12-03 17:34:45 +00:00
|
|
|
# Mark the end of a shutdown command (need to wait 15 seconds before
|
|
|
|
# sending the next command to avoid turning the TV back ON).
|
|
|
|
self._end_of_power_off = None
|
2016-12-16 06:20:00 +00:00
|
|
|
# Generate a configuration for the Samsung library
|
|
|
|
self._config = {
|
2019-07-31 19:25:30 +00:00
|
|
|
"name": "HomeAssistant",
|
|
|
|
"description": name,
|
|
|
|
"id": "ha.component.samsung",
|
2019-10-25 12:32:12 +00:00
|
|
|
"method": None,
|
2019-07-31 19:25:30 +00:00
|
|
|
"port": port,
|
|
|
|
"host": host,
|
|
|
|
"timeout": timeout,
|
2016-12-16 06:20:00 +00:00
|
|
|
}
|
2016-01-31 09:06:39 +00:00
|
|
|
|
2019-10-25 12:32:12 +00:00
|
|
|
# Select method by port number, mainly for fallback
|
2019-07-31 19:25:30 +00:00
|
|
|
if self._config["port"] in (8001, 8002):
|
|
|
|
self._config["method"] = "websocket"
|
2019-10-25 12:32:12 +00:00
|
|
|
elif self._config["port"] == 55000:
|
2019-07-31 19:25:30 +00:00
|
|
|
self._config["method"] = "legacy"
|
2017-01-03 22:28:23 +00:00
|
|
|
|
2016-01-31 09:06:39 +00:00
|
|
|
def update(self):
|
2018-01-22 08:11:16 +00:00
|
|
|
"""Update state of device."""
|
2018-10-12 12:51:03 +00:00
|
|
|
self.send_key("KEY")
|
2016-01-31 09:06:39 +00:00
|
|
|
|
|
|
|
def get_remote(self):
|
2016-03-08 09:34:33 +00:00
|
|
|
"""Create or return a remote control instance."""
|
2019-10-25 12:32:12 +00:00
|
|
|
|
|
|
|
# Try to find correct method automatically
|
|
|
|
if self._config["method"] not in METHODS:
|
|
|
|
for method in METHODS:
|
|
|
|
try:
|
|
|
|
self._config["method"] = method
|
|
|
|
LOGGER.debug("Try config: %s", self._config)
|
2019-11-05 14:04:19 +00:00
|
|
|
self._remote = SamsungRemote(self._config.copy())
|
2019-10-25 12:32:12 +00:00
|
|
|
self._state = STATE_ON
|
|
|
|
LOGGER.debug("Found working config: %s", self._config)
|
|
|
|
break
|
|
|
|
except (
|
2019-11-05 14:04:19 +00:00
|
|
|
samsung_exceptions.UnhandledResponse,
|
|
|
|
samsung_exceptions.AccessDenied,
|
2019-10-25 12:32:12 +00:00
|
|
|
):
|
|
|
|
# We got a response so it's working.
|
|
|
|
self._state = STATE_ON
|
|
|
|
LOGGER.debug(
|
|
|
|
"Found working config without connection: %s", self._config
|
|
|
|
)
|
|
|
|
break
|
|
|
|
except OSError as err:
|
|
|
|
LOGGER.debug("Failing config: %s error was: %s", self._config, err)
|
|
|
|
self._config["method"] = None
|
|
|
|
|
|
|
|
# Unable to find working connection
|
|
|
|
if self._config["method"] is None:
|
|
|
|
self._remote = None
|
|
|
|
self._state = None
|
|
|
|
return None
|
|
|
|
|
2016-01-31 09:06:39 +00:00
|
|
|
if self._remote is None:
|
|
|
|
# We need to create a new instance to reconnect.
|
2019-11-05 14:04:19 +00:00
|
|
|
self._remote = SamsungRemote(self._config.copy())
|
2016-01-31 09:06:39 +00:00
|
|
|
|
|
|
|
return self._remote
|
|
|
|
|
|
|
|
def send_key(self, key):
|
2016-03-08 09:34:33 +00:00
|
|
|
"""Send a key to the tv and handles exceptions."""
|
2019-07-31 19:25:30 +00:00
|
|
|
if self._power_off_in_progress() and key not in ("KEY_POWER", "KEY_POWEROFF"):
|
2019-10-25 12:32:12 +00:00
|
|
|
LOGGER.info("TV is powering off, not sending command: %s", key)
|
2017-12-03 17:34:45 +00:00
|
|
|
return
|
2016-01-31 09:06:39 +00:00
|
|
|
try:
|
2018-06-09 13:22:34 +00:00
|
|
|
# recreate connection if connection was dead
|
|
|
|
retry_count = 1
|
|
|
|
for _ in range(retry_count + 1):
|
|
|
|
try:
|
|
|
|
self.get_remote().control(key)
|
|
|
|
break
|
2019-11-25 09:45:50 +00:00
|
|
|
except (
|
|
|
|
samsung_exceptions.ConnectionClosed,
|
|
|
|
BrokenPipeError,
|
|
|
|
WebSocketException,
|
|
|
|
):
|
2018-06-09 13:22:34 +00:00
|
|
|
# BrokenPipe can occur when the commands is sent to fast
|
2019-11-25 09:45:50 +00:00
|
|
|
# WebSocketException can occur when timed out
|
2018-06-09 13:22:34 +00:00
|
|
|
self._remote = None
|
2018-11-20 12:29:05 +00:00
|
|
|
self._state = STATE_ON
|
2019-10-25 12:32:12 +00:00
|
|
|
except AttributeError:
|
|
|
|
# Auto-detect could not find working config yet
|
|
|
|
pass
|
2019-11-25 09:45:50 +00:00
|
|
|
except (samsung_exceptions.UnhandledResponse, samsung_exceptions.AccessDenied):
|
2016-01-31 09:06:39 +00:00
|
|
|
# We got a response so it's on.
|
2018-11-20 12:29:05 +00:00
|
|
|
self._state = STATE_ON
|
2016-01-31 09:06:39 +00:00
|
|
|
self._remote = None
|
2019-10-25 12:32:12 +00:00
|
|
|
LOGGER.debug("Failed sending command %s", key, exc_info=True)
|
2017-12-03 17:34:45 +00:00
|
|
|
return
|
2018-06-09 13:22:34 +00:00
|
|
|
except OSError:
|
2019-11-25 09:45:50 +00:00
|
|
|
# Different reasons, e.g. hostname not resolveable
|
2016-01-31 09:06:39 +00:00
|
|
|
self._state = STATE_OFF
|
|
|
|
self._remote = None
|
2017-12-03 17:34:45 +00:00
|
|
|
if self._power_off_in_progress():
|
|
|
|
self._state = STATE_OFF
|
2016-01-31 09:06:39 +00:00
|
|
|
|
2017-12-03 17:34:45 +00:00
|
|
|
def _power_off_in_progress(self):
|
2019-07-31 19:25:30 +00:00
|
|
|
return (
|
|
|
|
self._end_of_power_off is not None
|
|
|
|
and self._end_of_power_off > dt_util.utcnow()
|
|
|
|
)
|
2016-01-31 09:06:39 +00:00
|
|
|
|
2018-11-02 09:50:07 +00:00
|
|
|
@property
|
|
|
|
def unique_id(self) -> str:
|
|
|
|
"""Return the unique ID of the device."""
|
|
|
|
return self._uuid
|
|
|
|
|
2016-01-31 09:06:39 +00:00
|
|
|
@property
|
|
|
|
def name(self):
|
2016-03-08 09:34:33 +00:00
|
|
|
"""Return the name of the device."""
|
2016-01-31 09:06:39 +00:00
|
|
|
return self._name
|
|
|
|
|
|
|
|
@property
|
|
|
|
def state(self):
|
2016-03-08 09:34:33 +00:00
|
|
|
"""Return the state of the device."""
|
2016-01-31 09:06:39 +00:00
|
|
|
return self._state
|
|
|
|
|
|
|
|
@property
|
|
|
|
def is_volume_muted(self):
|
2016-03-08 09:34:33 +00:00
|
|
|
"""Boolean if volume is currently muted."""
|
2016-01-31 09:06:39 +00:00
|
|
|
return self._muted
|
|
|
|
|
2019-06-17 22:00:11 +00:00
|
|
|
@property
|
|
|
|
def source_list(self):
|
|
|
|
"""List of available input sources."""
|
|
|
|
return list(SOURCES)
|
|
|
|
|
2016-01-31 09:06:39 +00:00
|
|
|
@property
|
2017-02-08 04:42:45 +00:00
|
|
|
def supported_features(self):
|
|
|
|
"""Flag media player features that are supported."""
|
2017-02-21 15:57:29 +00:00
|
|
|
if self._mac:
|
|
|
|
return SUPPORT_SAMSUNGTV | SUPPORT_TURN_ON
|
2016-01-31 09:06:39 +00:00
|
|
|
return SUPPORT_SAMSUNGTV
|
|
|
|
|
2019-10-24 20:41:07 +00:00
|
|
|
@property
|
|
|
|
def device_class(self):
|
|
|
|
"""Set the device class to TV."""
|
|
|
|
return DEVICE_CLASS_TV
|
|
|
|
|
2016-01-31 09:06:39 +00:00
|
|
|
def turn_off(self):
|
2016-03-08 09:34:33 +00:00
|
|
|
"""Turn off media player."""
|
2017-12-03 17:34:45 +00:00
|
|
|
self._end_of_power_off = dt_util.utcnow() + timedelta(seconds=15)
|
|
|
|
|
2019-07-31 19:25:30 +00:00
|
|
|
if self._config["method"] == "websocket":
|
|
|
|
self.send_key("KEY_POWER")
|
2017-01-03 22:28:23 +00:00
|
|
|
else:
|
2019-07-31 19:25:30 +00:00
|
|
|
self.send_key("KEY_POWEROFF")
|
2016-11-18 06:00:18 +00:00
|
|
|
# Force closing of remote session to provide instant UI feedback
|
2017-12-07 16:30:51 +00:00
|
|
|
try:
|
|
|
|
self.get_remote().close()
|
2018-06-09 13:22:34 +00:00
|
|
|
self._remote = None
|
2017-12-07 16:30:51 +00:00
|
|
|
except OSError:
|
2019-10-25 12:32:12 +00:00
|
|
|
LOGGER.debug("Could not establish connection.")
|
2016-01-31 09:06:39 +00:00
|
|
|
|
|
|
|
def volume_up(self):
|
2016-03-08 09:34:33 +00:00
|
|
|
"""Volume up the media player."""
|
2019-07-31 19:25:30 +00:00
|
|
|
self.send_key("KEY_VOLUP")
|
2016-01-31 09:06:39 +00:00
|
|
|
|
|
|
|
def volume_down(self):
|
2016-03-08 09:34:33 +00:00
|
|
|
"""Volume down media player."""
|
2019-07-31 19:25:30 +00:00
|
|
|
self.send_key("KEY_VOLDOWN")
|
2016-01-31 09:06:39 +00:00
|
|
|
|
|
|
|
def mute_volume(self, mute):
|
2016-03-08 09:34:33 +00:00
|
|
|
"""Send mute command."""
|
2019-07-31 19:25:30 +00:00
|
|
|
self.send_key("KEY_MUTE")
|
2016-01-31 09:06:39 +00:00
|
|
|
|
|
|
|
def media_play_pause(self):
|
2016-03-08 09:34:33 +00:00
|
|
|
"""Simulate play pause media player."""
|
2016-01-31 09:06:39 +00:00
|
|
|
if self._playing:
|
|
|
|
self.media_pause()
|
|
|
|
else:
|
|
|
|
self.media_play()
|
|
|
|
|
|
|
|
def media_play(self):
|
2016-03-08 09:34:33 +00:00
|
|
|
"""Send play command."""
|
2016-01-31 09:06:39 +00:00
|
|
|
self._playing = True
|
2019-07-31 19:25:30 +00:00
|
|
|
self.send_key("KEY_PLAY")
|
2016-01-31 09:06:39 +00:00
|
|
|
|
|
|
|
def media_pause(self):
|
2016-03-08 09:34:33 +00:00
|
|
|
"""Send media pause command to media player."""
|
2016-01-31 09:06:39 +00:00
|
|
|
self._playing = False
|
2019-07-31 19:25:30 +00:00
|
|
|
self.send_key("KEY_PAUSE")
|
2016-01-31 09:06:39 +00:00
|
|
|
|
|
|
|
def media_next_track(self):
|
2016-03-08 09:34:33 +00:00
|
|
|
"""Send next track command."""
|
2019-11-15 08:53:16 +00:00
|
|
|
self.send_key("KEY_CHUP")
|
2016-01-31 09:06:39 +00:00
|
|
|
|
|
|
|
def media_previous_track(self):
|
2016-03-08 09:34:33 +00:00
|
|
|
"""Send the previous track command."""
|
2019-11-15 08:53:16 +00:00
|
|
|
self.send_key("KEY_CHDOWN")
|
2016-01-31 09:06:39 +00:00
|
|
|
|
2018-06-26 14:22:10 +00:00
|
|
|
async def async_play_media(self, media_type, media_id, **kwargs):
|
|
|
|
"""Support changing a channel."""
|
|
|
|
if media_type != MEDIA_TYPE_CHANNEL:
|
2019-10-25 12:32:12 +00:00
|
|
|
LOGGER.error("Unsupported media type")
|
2018-06-26 14:22:10 +00:00
|
|
|
return
|
|
|
|
|
|
|
|
# media_id should only be a channel number
|
|
|
|
try:
|
|
|
|
cv.positive_int(media_id)
|
|
|
|
except vol.Invalid:
|
2019-10-25 12:32:12 +00:00
|
|
|
LOGGER.error("Media ID must be positive integer")
|
2018-06-26 14:22:10 +00:00
|
|
|
return
|
|
|
|
|
|
|
|
for digit in media_id:
|
2019-07-31 19:25:30 +00:00
|
|
|
await self.hass.async_add_job(self.send_key, "KEY_" + digit)
|
2018-06-26 14:22:10 +00:00
|
|
|
await asyncio.sleep(KEY_PRESS_TIMEOUT, self.hass.loop)
|
2019-07-31 19:25:30 +00:00
|
|
|
await self.hass.async_add_job(self.send_key, "KEY_ENTER")
|
2018-06-26 14:22:10 +00:00
|
|
|
|
2016-01-31 09:06:39 +00:00
|
|
|
def turn_on(self):
|
2016-03-08 09:34:33 +00:00
|
|
|
"""Turn the media player on."""
|
2017-02-21 15:57:29 +00:00
|
|
|
if self._mac:
|
2019-11-17 12:17:22 +00:00
|
|
|
wakeonlan.send_magic_packet(self._mac, ip_address=self._broadcast)
|
2017-02-21 15:57:29 +00:00
|
|
|
else:
|
2019-07-31 19:25:30 +00:00
|
|
|
self.send_key("KEY_POWERON")
|
2019-06-17 22:00:11 +00:00
|
|
|
|
|
|
|
async def async_select_source(self, source):
|
|
|
|
"""Select input source."""
|
|
|
|
if source not in SOURCES:
|
2019-10-25 12:32:12 +00:00
|
|
|
LOGGER.error("Unsupported source")
|
2019-06-17 22:00:11 +00:00
|
|
|
return
|
|
|
|
|
|
|
|
await self.hass.async_add_job(self.send_key, SOURCES[source])
|