sermayoral / ha-samsungtv-encrypted

Samsung TV Encrypted Models (H & J Series) custom component for Home Assistant
Apache License 2.0
39 stars 24 forks source link

Detected I/O inside the event loop. #57

Open Holland1 opened 3 years ago

Holland1 commented 3 years ago

Just wanted to share the following HA warning, It likely happened right after I adjusted the volume.

Logger: homeassistant.util.async Source: util/async.py:105 First occurred: 5:58:10 PM (1 occurrences) Last logged: 5:58:10 PM

Detected I/O inside the event loop. This is causing stability issues. Please report issue to the custom component author for samsungtv_encrypted doing I/O at custom_components/samsungtv_encrypted/PySmartCrypto/pysmartcrypto.py, line 95: websocket_response = requests.get(step4_url)

Config; Samsung UE50HU6900 HA: 0.117.5

sermayoral commented 3 years ago

No happen to me

albizrik commented 3 years ago

same here Logger: homeassistant.util.async Source: util/async.py:132 First occurred: 16:24:22 (2 occurrences) Last logged: 16:25:12

Detected I/O inside the event loop. This is causing stability issues. Please report issue to the custom component author for samsungtv_encrypted doing I/O at custom_components/samsungtv_encrypted/PySmartCrypto/pysmartcrypto.py, line 95: websocket_response = requests.get(step4_url)

torsten2k6 commented 2 years ago

Just wanted to share the following HA warning, It likely happened right after I adjusted the volume.

Logger: homeassistant.util.async Source: util/async.py:105 First occurred: 5:58:10 PM (1 occurrences) Last logged: 5:58:10 PM

Detected I/O inside the event loop. This is causing stability issues. Please report issue to the custom component author for samsungtv_encrypted doing I/O at custom_components/samsungtv_encrypted/PySmartCrypto/pysmartcrypto.py, line 95: websocket_response = requests.get(step4_url)

Config; Samsung UE50HU6900 HA: 0.117.5

Same for me.

By the way, as you have the same TV model than me (Samsung UE50HU6900), do you have the Turn on / Power On function working?

santosdiez commented 2 years ago

I was having that same issue and I've been able to remove those warnings by creating the remote instance on a separate thread.

import threading

...

def create_remote_instance(self):
        self._remote = self._remote_class(self._host, self._port, self._token, self._sessionid)

def get_remote(self):
        """Create or return a remote control instance."""
        _LOGGER.debug("function get_remote")
        if self._remote is None:
            # We need to create a new instance to reconnect.
            thread = threading.Thread(target=self.create_remote_instance, name="Create instance")
            thread.start()
            thread.join()            

        return self._remote

Hope this helps..

Ei187 commented 2 years ago

I was having that same issue and I've been able to remove those warnings by creating the remote instance on a separate thread.

import threading

...

def create_remote_instance(self):
        self._remote = self._remote_class(self._host, self._port, self._token, self._sessionid)

def get_remote(self):
        """Create or return a remote control instance."""
        _LOGGER.debug("function get_remote")
        if self._remote is None:
            # We need to create a new instance to reconnect.
            thread = threading.Thread(target=self.create_remote_instance, name="Create instance")
            thread.start()
            thread.join()            

        return self._remote

Hope this helps..

Hey my friend you can tell me how to do it ?

fcassirer commented 1 year ago

I updated my local copy of media_player.py in the custom_components directory and replaced the get_remote with the one above that instead calls the create_remote_instance wrapper and this appeared to make the error go away. Unfortunately, still not working for me. @santosdiez have you considered submitting a pull request for your fix?

service: media_player.play_media
data:
  media_content_id: KEY_HDMI1
  media_content_type: send_key
  enqueue: play
target:
  entity_id: media_player.samsung_65

executed from the developer tools SERVICES interface does not work, however,

type: entities
entities:
  - entity: media_player.samsung_65
  - entity: media_player.samsung_43
  - entity: media_player.samsung_46
state_color: true
title: TVs

which is a entities card config on my dashboard allows me to click on the Samsung_65 entity and it shows a full media editor including the Sourcelist and this correctly changes the INPUT ... can't for the life of me see why it is different:

Samsung65_media_widget

My configuration.yaml looks like:

media_player:
  - platform: samsungtv_encrypted
    name: Samsung_65
    host: 192.168.68.91
    mac: 24-4B-03-XX-XX-XX
    token: xxxxxxxxxxxxxxxxxxxxxxx
    port: 8080
    sessionid: 1

Anyone have any idea why calling the service directly might fail but yet the built in media player widget seems to work fine? I'm trying to automate turning on the TV and setting it to one or more of the HDMI inputs.

Thanks in advance for any insights -Fred

fcassirer commented 1 year ago

Apparently there is another media_player command called "media_player.select_source" and that appears to work. Perhaps the built-in widget with the Source pulldown uses that ... would be nice if there was a trace/debug option to figure that out. The examples here and on all the SamsungTV clones of the original all show using send_key and then KEY_HDMIx which clearly doesn't work on my H series TV ...

Hope this helps somebody, it was a real time sink for me