Emulated Roku for Harmony

Ive been working on this for 3 days now and am about to pull my hair out.

So far i have

  • Emulated Roku installed and recognized by Home Assistant
  • Automation Setup to tie Emulated Roku and Hue together
  • Pressing Trigger from Home Assistant does cause lights to turn on and off, so automation is working
  • Have Emulated Roku added as a device in Harmony
  • Assigned the Emulated Roku “Info” button to the red button on the Harmony remote

Problem is, when I press the button on the Harmony remote, nothing happens. Ive tried pressing the button on the smartphone app as well and its not working either. Its like Harmony isnt speaking with Home Assistant. What could be causing the issue?

fixed this. Had to update harmony firmware to the beta and i had to fix my roku serial # under roku_usn. After that, it works

I tried to setup emulated roku yesterday.

  • I copied the emulated_roku.py into my custom_components folder
  • I configured the emulated roku in the configuration.yaml
  • I rebooted HA, the log shows no errors and a message with something like “You are using a custom component for emulated_roku which has not been tested…”
  • I can browse to the address ha_ip:8060 and see the serial number etc.

However when I try to find the Roku device in the harmony via searching for new WiFi devices, my emulated Roku doesn’t show up.

The Harmony itself is working with HA.

HA is running inside a docker container, which runs inside a VM on a Intel NUC. The VM is on the same network as the Harmony Hub. The NUC has a wired connection to the network.

What am I missing here?

What is your configuration? (usually you don’t need advertise_ip set)
Is docker running in host networking? (UPnP will only work in host networking AFAIK)

My configuration looks like this:

emulated_roku:
  host_ip: 192.168.0.5  #<-- IP of VM running Docker container
  listen_ports:
    - 8060:8060

Here the configuration of the docker-compose hass part:

  hass:
    build:
      context: ./volumes/hass
      args:
        version: 0.84.5
    container_name: hass
    image: burningstone/hass
    depends_on:
      - influxdb
      - mosquitto
      - deconz
    devices:
      - "/dev/zwave:/dev/zwave"
    network_mode: host
    ports:
      - 8123:8123
      - 8060:8060
    restart: unless-stopped
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - ./volumes/hass/configuration:/config

Could the problem maybe come from the fact that I have a virtual bridge inside my Proxmox server (which manages the VMs) which routes the traffic from 192.168.0.5 to 192.168.1.x? I’ve openend the port there and I’m able to access 192.168.1.x:8060 and see the roku serial number etc.

Perhaps multicast traffic is not routed to the docker container? Unfortunately I don’t know enough about networking to know how it is usually handled.

You could download the newest emulated_roku library to a host where multicast is working, and run advertise.py pointing to the docker host. Something like: ./advertise.py --api_ip=192.168.0.5 --api_port=8060 --name=generated_roku_usn
That should allow Harmony to find it, and you can shut down advertise.py after pairing.

1 Like

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.