roberodin/ha-samsungtv-custom

Bunch of errors on key send

Closed this issue · 1 comments

HASSIO: 0.100.2
Samsung custom: 3.0.2
TV: Not 100% sure, not at home right now, but should be a UE55D8090
Protocol used: ws

Service call tried:
2019-10-18 09_25_24-Home Assistant

Invalid close opcode.
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 133, in handle_call_service
    connection.context(msg),
  File "/usr/src/homeassistant/homeassistant/core.py", line 1233, in async_call
    await asyncio.shield(self._execute_service(handler, service_call))
  File "/usr/src/homeassistant/homeassistant/core.py", line 1258, in _execute_service
    await handler.func(service_call)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 213, in handle_service
    self._platforms.values(), func, call, service_name, required_features
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 348, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 370, in _handle_service_platform_call
    await getattr(entity, func)(**data)
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/samsungtv_custom/media_player.py", line 815, in turn_off
    self.send_key("KEY_POWER")
  File "/config/custom_components/samsungtv_custom/media_player.py", line 750, in send_key
    self._remote.send_key(key)
  File "/config/custom_components/samsungtv_custom/samsungtvws/remote.py", line 134, in send_key
    self._ws_send(payload)
  File "/config/custom_components/samsungtv_custom/samsungtvws/remote.py", line 87, in _ws_send
    self.open()
  File "/config/custom_components/samsungtv_custom/samsungtvws/remote.py", line 105, in open
    response = json.loads(self.connection.recv())
  File "/usr/local/lib/python3.7/site-packages/websocket/_core.py", line 310, in recv
    opcode, data = self.recv_data()
  File "/usr/local/lib/python3.7/site-packages/websocket/_core.py", line 327, in recv_data
    opcode, frame = self.recv_data_frame(control_frame)
  File "/usr/local/lib/python3.7/site-packages/websocket/_core.py", line 340, in recv_data_frame
    frame = self.recv_frame()
  File "/usr/local/lib/python3.7/site-packages/websocket/_core.py", line 374, in recv_frame
    return self.frame_buffer.recv_frame()
  File "/usr/local/lib/python3.7/site-packages/websocket/_abnf.py", line 383, in recv_frame
    frame.validate(self.skip_utf8_validation)
  File "/usr/local/lib/python3.7/site-packages/websocket/_abnf.py", line 182, in validate
    raise WebSocketProtocolException("Invalid close opcode.")
websocket._exceptions.WebSocketProtocolException: Invalid close opcode.
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/core.py", line 1258, in _execute_service
    await handler.func(service_call)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 213, in handle_service
    self._platforms.values(), func, call, service_name, required_features
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 348, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 370, in _handle_service_platform_call
    await getattr(entity, func)(**data)
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/samsungtv_custom/media_player.py", line 815, in turn_off
    self.send_key("KEY_POWER")
  File "/config/custom_components/samsungtv_custom/media_player.py", line 750, in send_key
    self._remote.send_key(key)
  File "/config/custom_components/samsungtv_custom/samsungtvws/remote.py", line 134, in send_key
    self._ws_send(payload)
  File "/config/custom_components/samsungtv_custom/samsungtvws/remote.py", line 87, in _ws_send
    self.open()
  File "/config/custom_components/samsungtv_custom/samsungtvws/remote.py", line 105, in open
    response = json.loads(self.connection.recv())
  File "/usr/local/lib/python3.7/site-packages/websocket/_core.py", line 310, in recv
    opcode, data = self.recv_data()
  File "/usr/local/lib/python3.7/site-packages/websocket/_core.py", line 327, in recv_data
    opcode, frame = self.recv_data_frame(control_frame)
  File "/usr/local/lib/python3.7/site-packages/websocket/_core.py", line 340, in recv_data_frame
    frame = self.recv_frame()
  File "/usr/local/lib/python3.7/site-packages/websocket/_core.py", line 374, in recv_frame
    return self.frame_buffer.recv_frame()
  File "/usr/local/lib/python3.7/site-packages/websocket/_abnf.py", line 383, in recv_frame
    frame.validate(self.skip_utf8_validation)
  File "/usr/local/lib/python3.7/site-packages/websocket/_abnf.py", line 182, in validate
    raise WebSocketProtocolException("Invalid close opcode.")
websocket._exceptions.WebSocketProtocolException: Invalid close opcode.

NVM... TV showed way too late the accept message. When accepted, it works fine now ^^