diff --git a/homeassistant/components/panasonic_viera/media_player.py b/homeassistant/components/panasonic_viera/media_player.py index e6546f7c1e2767..f1ac0cd90d461a 100644 --- a/homeassistant/components/panasonic_viera/media_player.py +++ b/homeassistant/components/panasonic_viera/media_player.py @@ -19,12 +19,15 @@ CONF_HOST, CONF_MAC, CONF_NAME, CONF_PORT, STATE_OFF, STATE_ON) import homeassistant.helpers.config_validation as cv -REQUIREMENTS = ['panasonic_viera==0.3.1', 'wakeonlan==1.1.6'] +REQUIREMENTS = ['panasonic_viera==0.3.2', 'wakeonlan==1.1.6'] _LOGGER = logging.getLogger(__name__) +CONF_APP_POWER = 'app_power' + DEFAULT_NAME = 'Panasonic Viera TV' DEFAULT_PORT = 55000 +DEFAULT_APP_POWER = False SUPPORT_VIERATV = SUPPORT_PAUSE | SUPPORT_VOLUME_STEP | \ SUPPORT_VOLUME_SET | SUPPORT_VOLUME_MUTE | \ @@ -37,6 +40,7 @@ vol.Optional(CONF_MAC): cv.string, vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string, vol.Optional(CONF_PORT, default=DEFAULT_PORT): cv.port, + vol.Optional(CONF_APP_POWER, default=DEFAULT_APP_POWER): cv.boolean, }) @@ -47,6 +51,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None): mac = config.get(CONF_MAC) name = config.get(CONF_NAME) port = config.get(CONF_PORT) + app_power = config.get(CONF_APP_POWER) if discovery_info: _LOGGER.debug('%s', discovery_info) @@ -59,20 +64,21 @@ def setup_platform(hass, config, add_entities, discovery_info=None): else: uuid = None remote = RemoteControl(host, port) - add_entities([PanasonicVieraTVDevice(mac, name, remote, host, uuid)]) + add_entities([PanasonicVieraTVDevice( + mac, name, remote, host, app_power, uuid)]) return True host = config.get(CONF_HOST) remote = RemoteControl(host, port) - add_entities([PanasonicVieraTVDevice(mac, name, remote, host)]) + add_entities([PanasonicVieraTVDevice(mac, name, remote, host, app_power)]) return True class PanasonicVieraTVDevice(MediaPlayerDevice): """Representation of a Panasonic Viera TV.""" - def __init__(self, mac, name, remote, host, uuid=None): + def __init__(self, mac, name, remote, host, app_power, uuid=None): """Initialize the Panasonic device.""" import wakeonlan # Save a reference to the imported class @@ -86,6 +92,7 @@ def __init__(self, mac, name, remote, host, uuid=None): self._remote = remote self._host = host self._volume = 0 + self._app_power = app_power @property def unique_id(self) -> str: @@ -134,7 +141,7 @@ def is_volume_muted(self): @property def supported_features(self): """Flag media player features that are supported.""" - if self._mac: + if self._mac or self._app_power: return SUPPORT_VIERATV | SUPPORT_TURN_ON return SUPPORT_VIERATV @@ -143,6 +150,9 @@ def turn_on(self): if self._mac: self._wol.send_magic_packet(self._mac, ip_address=self._host) self._state = STATE_ON + elif self._app_power: + self._remote.turn_on() + self._state = STATE_ON def turn_off(self): """Turn off media player.""" diff --git a/requirements_all.txt b/requirements_all.txt index b82d38d409d7f9..a8e7efa22153f6 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -802,7 +802,7 @@ paho-mqtt==1.4.0 panacotta==0.1 # homeassistant.components.panasonic_viera.media_player -panasonic_viera==0.3.1 +panasonic_viera==0.3.2 # homeassistant.components.dunehd.media_player pdunehd==1.3