kdschlosser / samsungctl

Remote control Samsung televisions via a TCP/IP connection
MIT License
154 stars 33 forks source link

It broke after some time of using with home assistant py35 #44

Closed AidasK closed 5 years ago

AidasK commented 5 years ago

Worked a few times, but then I saw this in the log:

2019-01-18 20:24:50 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/lib/python3.5/asyncio/tasks.py", line 241, in _step
    result = coro.throw(exc)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/service.py", line 286, in _handle_service_platform_call
    await getattr(entity, func)(**data)
  File "/usr/lib/python3.5/asyncio/futures.py", line 380, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.5/asyncio/tasks.py", line 304, in _wakeup
    future.result()
  File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result
    raise self._exception
  File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/media_player/samsungtv.py", line 207, in turn_off
    self.send_key('KEY_POWER')
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/media_player/samsungtv.py", line 151, in send_key
    self.get_remote().control(key)
  File "/srv/homeassistant/lib/python3.5/site-packages/samsungctl-0.8.0b0-py3.5.egg/samsungctl/remote.py", line 29, in control
    return self.remote.control(key)
  File "/srv/homeassistant/lib/python3.5/site-packages/samsungctl-0.8.0b0-py3.5.egg/samsungctl/utils.py", line 27, in wrapper
    return func(*args, **kwargs)
  File "/srv/homeassistant/lib/python3.5/site-packages/samsungctl-0.8.0b0-py3.5.egg/samsungctl/remote_websocket.py", line 322, in control
    self.power = True
  File "/srv/homeassistant/lib/python3.5/site-packages/samsungctl-0.8.0b0-py3.5.egg/samsungctl/utils.py", line 27, in wrapper
    return func(*args, **kwargs)
  File "/srv/homeassistant/lib/python3.5/site-packages/samsungctl-0.8.0b0-py3.5.egg/samsungctl/remote_websocket.py", line 96, in power
    wake_on_lan.send_wol(self.mac_address)
  File "/srv/homeassistant/lib/python3.5/site-packages/samsungctl-0.8.0b0-py3.5.egg/samsungctl/wake_on_lan.py", line 239, in send_wol
    packet = '\xff' * 6 + hex_mac * 16
TypeError: Can't convert 'bytes' object to str implicitly
AidasK commented 5 years ago

mac address I am using: 9C:8C:6E:D7:7A:51

AidasK commented 5 years ago

fixed by changing this line: https://github.com/kdschlosser/samsungctl/blob/master/samsungctl/wake_on_lan.py#L239

    packet = '\xff' * 6 + hex_mac * 16

to

    packet = b'\xff' * 6 + hex_mac * 16
AidasK commented 5 years ago

feel free to make a pull request with this fix

kdschlosser commented 5 years ago

Yes please. A PR would be most helpful