Emulated Roku for Harmony

Awesome, this worked! Thank you so much, my Harmony is way more useful now :grinning:
Could you please add this to the documentation?

Another question unrelated to emulated_roku, since the firmware update of the harmony and the problems it caused I’m afraid that it will stop working altogether with a future firmware upgrade. Can I block internet access for the harmony without losing any critical functionalities?

As long as Harmony supports Roku players and the Roku API is open it should continue to work. Unfortunately I don’t know any ways without crippling the app.

I’ve already pushed the changes to the Home Assistant docs here. The code has changed quite a lot over time since I’ve submitted the PR and I haven’t updated the gitlab repo since.

I’m more interested in the “harmony” side of things like does controlling devices with the harmony need an internet connection? Does the android app need internet connection?

I’m not so familiar with the harmony, I bought it years ago and only used it to control some devices with the remote and with the android app for configurations.

Controlling devices, I don’t think so, but I’m pretty sure adding devices / modifying activities needs internet access, that’s why I said “crippling the app”.

Ah now I understand. How do you handle this? As far as I know there is no way to block firmware updates except for blocking the internet connection right?

I don’t use the Harmony API at all, so I just let it be. I have an activity that’s perpetually on, and everything pretty much goes through emulated roku. I just use the physical remote and hope to never touch the app. (Logitech should make a companion remote that works with the unifying receiver like a keyboard)

Good news everyone! emulated_roku has been merged and should be available in the next release.
There have been couple of changes to the configuration syntax and it’s also available via the Integrations page so you can set up the component more easily.

If you want let Harmony auto-find the Roku if your Home Assistant IP changes, you can either set the name property to your already used auto-generated name, or re-add the component in Harmony. This step is completely optional, and the component will keep working whatever name you specify.

emulated_roku:
  host_ip: 192.168.1.67
  listen_ports:
    - 8060:8060

becomes:

emulated_roku:
  servers:
    - name: Home Assistant
      listen_port: 8060
      advertise_port: 8060
      host_ip: 192.168.1.67
3 Likes

@mindigmarton, thanks so much! This component is quite essential if you own a harmony. I love that it has made its way into home assistant. Cheers!

The custom component was working but the new integrated version will not start

I am getting the following los message:

2019-02-03 21:11:26 DEBUG (MainThread) [homeassistant.components.emulated_roku] Intializing emulated_roku Home Assistant 2 on 192.168.1.100:8061
2019-02-03 21:11:26 DEBUG (MainThread) [homeassistant.components.emulated_roku] Starting emulated_roku Home Assistant 2
2019-02-03 21:11:26 ERROR (MainThread) [homeassistant.components.emulated_roku] Failed to start Emulated Roku Home Assistant 2 on 192.168.1.100:8061
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/emulated_roku/binding.py", line 112, in emulated_roku_start
    await self._api_server.start()
  File "/config/deps/lib/python3.6/site-packages/emulated_roku/__init__.py", line 424, in start
    reuse_address=True)
  File "uvloop/loop.pyx", line 2893, in create_datagram_endpoint
  File "uvloop/loop.pyx", line 2878, in uvloop.loop.Loop.create_datagram_endpoint
OSError: [Errno 98] Address in use
2019-02-03 21:11:26 DEBUG (MainThread) [homeassistant.components.emulated_roku] Stopping emulated_roku Home Assistant 2

Any idea?

[EDIT]

Solved, I think it was a port which was already in use… Now it is working :slight_smile:

Thanks!

I’m trying to connect the roku android app with emulated_roku.

emulated_roku:
  servers:
    - name: Studio Remote
      listen_port: 8060
    - name: TV Remote
      listen_port: 8061

They appear in the roku app on my phone but when I try to connect I get:

“Connection Error” : “Error connecting to Studio Remote. Please try again”.

Tried quite a few times with home assistant restarts. There is nothing in the home assistant logs. Any ideas?

Looks like they’re using an undocumented API endpoint (/ecp-session) which is missing from emulated_roku. Unfortunately I don’t have a Roku and I can’t find any info on it.

I enabled the emulated Roku integration as advised On this page and my integrations page now shows it. If I drill into it I see “This Integration has no devices” - which I kind of expected. To be very clear, I have NO configuration.yaml changes - it was done solely by adding an integration.

However, I cannot add it to Harmony. If I use the ‘Scan for Wifi devices’ functionality in the Harmony app it does not discover it. If I use Add Entertainment Device, the Harmony app insists on a serial number.

I tried accessing Hassio:8060 but get a ‘connection refused’ message

TIA
Steve

Aha - Restared HA this it seems Roku is throwing an error:

RokuError

Drill into it and I can see this:

Fri Mar 29 2019 10:19:24 GMT+0000 (Greenwich Mean Time)
Error doing job: Future exception was never retrieved
Traceback (most recent call last):
File “/usr/local/lib/python3.7/site-packages/urllib3/connection.py”, line 159, in _new_conn
(self._dns_host, self.port), self.timeout, **extra_kw)
File “/usr/local/lib/python3.7/site-packages/urllib3/util/connection.py”, line 80, in create_connection
raise err
File “/usr/local/lib/python3.7/site-packages/urllib3/util/connection.py”, line 70, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py”, line 600, in urlopen
chunked=chunked)
File “/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py”, line 354, in _make_request
conn.request(method, url, **httplib_request_kw)
File “/usr/local/lib/python3.7/http/client.py”, line 1229, in request
self._send_request(method, url, body, headers, encode_chunked)
File “/usr/local/lib/python3.7/http/client.py”, line 1275, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File “/usr/local/lib/python3.7/http/client.py”, line 1224, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File “/usr/local/lib/python3.7/http/client.py”, line 1016, in _send_output
self.send(msg)
File “/usr/local/lib/python3.7/http/client.py”, line 956, in send
self.connect()
File “/usr/local/lib/python3.7/site-packages/urllib3/connection.py”, line 181, in connect
conn = self._new_conn()
File “/usr/local/lib/python3.7/site-packages/urllib3/connection.py”, line 168, in _new_conn
self, “Failed to establish a new connection: %s” % e)
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x6cf3a3f0>: Failed to establish a new connection: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/usr/local/lib/python3.7/site-packages/requests/adapters.py”, line 449, in send
timeout=timeout
File “/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py”, line 638, in urlopen
_stacktrace=sys.exc_info()[2])
File “/usr/local/lib/python3.7/site-packages/urllib3/util/retry.py”, line 398, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host=‘192.168.2.170’, port=8060): Max retries exceeded with url: /query/device-info (Caused by NewConnectionError(’<urllib3.connection.HTTPConnection object at 0x6cf3a3f0>: Failed to establish a new connection: [Errno 111] Connection refused’))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/usr/local/lib/python3.7/concurrent/futures/thread.py”, line 57, in run
result = self.fn(*self.args, **self.kwargs)
File “/usr/local/lib/python3.7/site-packages/homeassistant/components/roku/init.py”, line 51, in roku_discovered
CONF_HOST: info[‘host’]
File “/usr/local/lib/python3.7/site-packages/homeassistant/components/roku/init.py”, line 100, in _setup_roku
r_info = roku.device_info
File “/usr/local/lib/python3.7/site-packages/roku/core.py”, line 213, in device_info
resp = self._get(’/query/device-info’)
File “/usr/local/lib/python3.7/site-packages/roku/core.py”, line 172, in _get
return self._call(‘GET’, path, *args, **kwargs)
File “/usr/local/lib/python3.7/site-packages/roku/core.py”, line 189, in _call
resp = func(url, *args, **kwargs)
File “/usr/local/lib/python3.7/site-packages/requests/sessions.py”, line 546, in get
return self.request(‘GET’, url, **kwargs)
File “/usr/local/lib/python3.7/site-packages/requests/sessions.py”, line 533, in request
resp = self.send(prep, **send_kwargs)
File “/usr/local/lib/python3.7/site-packages/requests/sessions.py”, line 646, in send
r = adapter.send(request, **kwargs)
File “/usr/local/lib/python3.7/site-packages/requests/adapters.py”, line 516, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host=‘192.168.2.170’, port=8060): Max retries exceeded with url: /query/device-info (Caused by NewConnectionError(’<urllib3.connection.HTTPConnection object at 0x6cf3a3f0>: Failed to establish a new connection: [Errno 111] Connection refused’))
Connection lost. Reconnecting…

The error is from the roku component trying to connect to the emulated_roku. I guess it finds it via autodiscovery (UPNP) then tries to connect, but the port isn’t open?
First and foremost, you should be able to access it via <hass address>:8060. If that doesn’t work, UPNP discovery for Harmony won’t work either. (which is another thing that people have problems with, but there are workarounds on the component page)

There might be some other errors in the log preventing emulated_roku to bind to port 8060.

<hass address>:8060 in a browser also gives connection refused. I just upgraded to the latest stable version of HA so my full log is quite short, and I am not seeing anything other then the Roku error itself.

The odd Hue and TPLink errors are to be expected - they represent devices in Config that are not currently plugged in!

019-03-29 11:05:16 WARNING (MainThread) [homeassistant.loader] You are using a custom component for huesensor.device_tracker which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you do experience issues with Home Assistant.
2019-03-29 11:05:16 WARNING (MainThread) [homeassistant.loader] You are using a custom component for huesensor.sensor which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you do experience issues with Home Assistant.
2019-03-29 11:05:16 WARNING (MainThread) [homeassistant.loader] You are using a custom component for huesensor.binary_sensor which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you do experience issues with Home Assistant.
2019-03-29 11:05:19 WARNING (MainThread) [homeassistant.components.hue] Connected to Hue at 192.168.2.147 but not registered.
2019-03-29 11:05:19 ERROR (SyncWorker_8) [homeassistant.components.tplink] Unable to connect to device 192.168.2.177: Communication error
2019-03-29 11:05:19 WARNING (MainThread) [homeassistant.components.hue] Connected to Hue at 192.168.2.147 but not registered.
2019-03-29 11:05:19 ERROR (Thread-2) [pychromecast.socket_client] [AFTN-158:8010] Exception caught while sending message to controller ReceiverController: Message urn:x-cast:com.google.cast.receiver from receiver-0 to sender-0: {‘requestId’: 1, ‘status’: {‘applications’: [], ‘isActiveInput’: True, ‘volume’: {‘controlType’: ‘attenuation’, ‘level’: 1, ‘muted’: False, ‘stepInterval’: 0.05}}, ‘type’: ‘RECEIVER_STATUS’}
Traceback (most recent call last):
File “/usr/local/lib/python3.7/site-packages/pychromecast/socket_client.py”, line 563, in _route_message
message, data)
File “/usr/local/lib/python3.7/site-packages/pychromecast/socket_client.py”, line 889, in receive_message
self._process_get_status(data)
File “/usr/local/lib/python3.7/site-packages/pychromecast/socket_client.py”, line 1019, in _process_get_status
status = self._parse_status(data, self.cast_type)
File “/usr/local/lib/python3.7/site-packages/pychromecast/socket_client.py”, line 997, in _parse_status
app_data = data[‘applications’][0]
IndexError: list index out of range
2019-03-29 11:05:19 ERROR (MainThread) [homeassistant.components.device_tracker] Unable to load /config/known_devices.yaml: Config file not found: /config/known_devices.yaml
2019-03-29 11:05:22 ERROR (SyncWorker_8) [homeassistant.components.tplink] Unable to connect to device 192.168.2.178: Communication error
2019-03-29 11:05:25 ERROR (SyncWorker_8) [homeassistant.components.tplink] Unable to connect to device 192.168.2.179: Communication error
2019-03-29 11:05:28 ERROR (SyncWorker_8) [homeassistant.components.tplink] Unable to connect to device 192.168.2.181: Communication error
2019-03-29 11:05:50 ERROR (MainThread) [homeassistant.core] Error doing job: Future exception was never retrieved
Traceback (most recent call last):
File “/usr/local/lib/python3.7/site-packages/urllib3/connection.py”, line 159, in _new_conn
(self._dns_host, self.port), self.timeout, **extra_kw)
File “/usr/local/lib/python3.7/site-packages/urllib3/util/connection.py”, line 80, in create_connection
raise err
File “/usr/local/lib/python3.7/site-packages/urllib3/util/connection.py”, line 70, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py”, line 600, in urlopen
chunked=chunked)
File “/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py”, line 354, in _make_request
conn.request(method, url, **httplib_request_kw)
File “/usr/local/lib/python3.7/http/client.py”, line 1229, in request
self._send_request(method, url, body, headers, encode_chunked)
File “/usr/local/lib/python3.7/http/client.py”, line 1275, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File “/usr/local/lib/python3.7/http/client.py”, line 1224, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File “/usr/local/lib/python3.7/http/client.py”, line 1016, in _send_output
self.send(msg)
File “/usr/local/lib/python3.7/http/client.py”, line 956, in send
self.connect()
File “/usr/local/lib/python3.7/site-packages/urllib3/connection.py”, line 181, in connect
conn = self._new_conn()
File “/usr/local/lib/python3.7/site-packages/urllib3/connection.py”, line 168, in _new_conn
self, “Failed to establish a new connection: %s” % e)
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x6f4cc9b0>: Failed to establish a new connection: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/usr/local/lib/python3.7/site-packages/requests/adapters.py”, line 449, in send
timeout=timeout
File “/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py”, line 638, in urlopen
_stacktrace=sys.exc_info()[2])
File “/usr/local/lib/python3.7/site-packages/urllib3/util/retry.py”, line 398, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host=‘192.168.2.170’, port=8060): Max retries exceeded with url: /query/device-info (Caused by NewConnectionError(’<urllib3.connection.HTTPConnection object at 0x6f4cc9b0>: Failed to establish a new connection: [Errno 111] Connection refused’))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/usr/local/lib/python3.7/concurrent/futures/thread.py”, line 57, in run
result = self.fn(*self.args, **self.kwargs)
File “/usr/local/lib/python3.7/site-packages/homeassistant/components/roku/init.py”, line 51, in roku_discovered
CONF_HOST: info[‘host’]
File “/usr/local/lib/python3.7/site-packages/homeassistant/components/roku/init.py”, line 100, in _setup_roku
r_info = roku.device_info
File “/usr/local/lib/python3.7/site-packages/roku/core.py”, line 213, in device_info
resp = self._get(’/query/device-info’)
File “/usr/local/lib/python3.7/site-packages/roku/core.py”, line 172, in _get
return self._call(‘GET’, path, *args, **kwargs)
File “/usr/local/lib/python3.7/site-packages/roku/core.py”, line 189, in _call
resp = func(url, *args, **kwargs)
File “/usr/local/lib/python3.7/site-packages/requests/sessions.py”, line 546, in get
return self.request(‘GET’, url, **kwargs)
File “/usr/local/lib/python3.7/site-packages/requests/sessions.py”, line 533, in request
resp = self.send(prep, **send_kwargs)
File “/usr/local/lib/python3.7/site-packages/requests/sessions.py”, line 646, in send
r = adapter.send(request, **kwargs)
File “/usr/local/lib/python3.7/site-packages/requests/adapters.py”, line 516, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host=‘192.168.2.170’, port=8060): Max retries exceeded with url: /query/device-info (Caused by NewConnectionError(’<urllib3.connection.HTTPConnection object at 0x6f4cc9b0>: Failed to establish a new connection: [Errno 111] Connection refused’))

The emulated_roku correctly starts up as it looks like it’s advertising the 8060 port via UPNP (roku component finds it) and that should mean it’s available at 8060. (if any error happens when binding the HTTP port the UPNP advertising shuts down too)

Do you use the hassio OS or the hassio docker container on a generic linux host?
If you’re using hassio OS, and it’s not working, the problem is probably with your router’s network configuration.
On generic linux, you might have to use docker host networking, expose docker ports or open the ports with firewalld, etc.

I use Hassio

Not sure why the router would be an issue. I have a big internal network and am always running services up and down of different machines on different ports - all of which work - ie I have nothing set up on my internal network to prevent any kind of port connection.

Accessing the emulated roku directly by IP and port doesn’t work, and I can see in the HA log that it tries the same thing and fails there too. (Last two entries in the log I posted previously)

If anyone can suggest anything I might try, I’d be grateful.

PS Emulated Hue works just fine, if that sheds any additional light. The problem is I already have a Hue hub so cannot connect Emulated Hue to Harmony!

I originally posted this question here, but since there appears to be more activity here, I will try here also.

I want to add the emulated_roku component, but in the documentation, there is a warning stating the below information:

This component opens an unauthenticated API on the host, allowing anything on the local network to access your Home Assistant instance through the automations you create with emulated Roku as the trigger. Using a proxy with whitelisted IP addresses is recommended. (set advertise_ip to the proxy’s ip or DNS name)

What exactly does this mean and how do I configure this proxy so I keep my HA safe and secure?

Anyone know how to setup the emulated_roku component securely?

Hi,

After initialization of Emulated Roku (through integrations or configuration.yaml) I do have following error.
I’m using Hass.io on Rpi 3

Failed to start Emulated Roku Home Assistant 2 on 192.168.0.148:14

Traceback (most recent call last):
File “/usr/local/lib/python3.7/site-packages/homeassistant/components/emulated_roku/binding.py”, line 112, in emulated_roku_start
await self._api_server.start()
File “/usr/local/lib/python3.7/site-packages/emulated_roku/init.py”, line 424, in start
reuse_address=True)
File “uvloop/loop.pyx”, line 2946, in create_datagram_endpoint
File “uvloop/loop.pyx”, line 2931, in uvloop.loop.Loop.create_datagram_endpoint
OSError: [Errno 98] Address in use

Anybody know how to overcome it?