Update panasonic_viera.py (#21365)

pull/21379/head
Tony763 2019-02-23 23:39:51 +01:00 committed by Fabian Affolter
parent a1c3a38428
commit 6743ef10ab
1 changed files with 5 additions and 4 deletions

View File

@ -59,20 +59,20 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
else: else:
uuid = None uuid = None
remote = RemoteControl(host, port) remote = RemoteControl(host, port)
add_entities([PanasonicVieraTVDevice(mac, name, remote, uuid)]) add_entities([PanasonicVieraTVDevice(mac, name, remote, host, uuid)])
return True return True
host = config.get(CONF_HOST) host = config.get(CONF_HOST)
remote = RemoteControl(host, port) remote = RemoteControl(host, port)
add_entities([PanasonicVieraTVDevice(mac, name, remote)]) add_entities([PanasonicVieraTVDevice(mac, name, remote, host)])
return True return True
class PanasonicVieraTVDevice(MediaPlayerDevice): class PanasonicVieraTVDevice(MediaPlayerDevice):
"""Representation of a Panasonic Viera TV.""" """Representation of a Panasonic Viera TV."""
def __init__(self, mac, name, remote, uuid=None): def __init__(self, mac, name, remote, host, uuid=None):
"""Initialize the Panasonic device.""" """Initialize the Panasonic device."""
import wakeonlan import wakeonlan
# Save a reference to the imported class # Save a reference to the imported class
@ -84,6 +84,7 @@ class PanasonicVieraTVDevice(MediaPlayerDevice):
self._playing = True self._playing = True
self._state = None self._state = None
self._remote = remote self._remote = remote
self._host = host
self._volume = 0 self._volume = 0
@property @property
@ -140,7 +141,7 @@ class PanasonicVieraTVDevice(MediaPlayerDevice):
def turn_on(self): def turn_on(self):
"""Turn on the media player.""" """Turn on the media player."""
if self._mac: if self._mac:
self._wol.send_magic_packet(self._mac) self._wol.send_magic_packet(self._mac, ip_address=self._host)
self._state = STATE_ON self._state = STATE_ON
def turn_off(self): def turn_off(self):