Emulated Roku for Harmony

I bought a Harmony a while ago and I got tired of not being able to run arbitrary stuff through wifi.
Emulated Hue worked, but creating switches was too cumbersome and you can only map the Home Control buttons to it.
Luckily, Harmony can control Roku through wifi too, and the Roku API is well documented, so I implemented it in python:
Emulated Roku

With this, you can map all the buttons on the Harmony remote to Roku keys, which fire events you can use in automations.
You can create multiple roku servers if you run out of the predefined buttons.

I’ve been only using asyncio for a few days and my python is quite rusty so it may crash / burn your pi.
Only tested it with Harmony, but it could work with other Roku remotes.
Currently using it to control my NAD amplifier’s volume through WIFI instead of IR.
Follow the README and the Harmony app should auto discover it.

Bug reports are welcome:)


Sounds very useful. I’ve bought two harmony companion but not integrated them into hass yet. Might look into this further on

Awesome, Marton!

This is home assistant’s equivalent to fhem/iobroker’s “fakeroku”. (search word bump :-)) I was looking for this for so long. We need to get this integrated into the home assistant core.

1 Like

Interesting, missed this when you announced and am guessing many others did too by the lack of feedback. Not sure what I’m going to do with it yet but I’ll get my thinking hat on.

I would like to try this but can’t figure out how to load it?

Put it in the custom_components folder.

1 Like

I did that (./custom:components/emulated_eoku/emulated_roku.py) and just coped the config (changed the ip to the HA ip) and restarted. But it says in the log that emulated_roku can’t be found?

Pointless extra folder that also has a typo would be my guess.

The typo wasn’t in the original folder, that was just me be a bit too quick typing :wink:

I’ll try without the folder, thanks :slight_smile:

Error during setup of component emulated_roku
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/homeassistant/setup.py", line 190, in _async_setup_component
    result = yield from component.async_setup(hass, processed_config)
  File "/usr/lib/python3.6/asyncio/coroutines.py", line 210, in coro
    res = func(*args, **kw)
  File "/config/custom_components/emulated_roku.py", line 41, in async_setup
    from emulated_roku import RokuDiscoveryServerProtocol, RokuEventHandler, make_roku_api
ModuleNotFoundError: No module named 'emulated_roku'

The emulated_roku.py should be just under the components folder like ‘custom_components/emulated_roku.py’

I have that, I think I need this also:

As a test I just copied the folder (emulated_roku) to /custom_components/emulated_roku and now it says:

Error during setup of component emulated_roku
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/homeassistant/setup.py", line 193, in _async_setup_component
    component.setup, hass, processed_config)
AttributeError: module 'custom_components.emulated_roku' has no attribute 'setup'

So something happened but I guess I need to do something else…
Probably run this file? https://gitlab.com/mindig.marton/emulated_roku/blob/master/setup.py

The code needs some clean up because the behavior of advertise_* properties are not the same as in emulated_hue which can be misleading.

There are some weirdness going on with windows multicasting (which works, but I’m not sure how portable it is)

No, it should download the dependency dynamically. The only file you need is emulated_roku.py.
The last hass version I’ve tested was 0.55, maybe something has changed? It uses ‘async_setup’ instead of ‘setup’. I’ll take a look tomorrow.

1 Like

As I haven’t coded anything for HA or in python this might be obvious for those into it but for me I can’t see any references in the code (https://gitlab.com/mindig.marton/ha-emulated_roku/blob/master/components/emulated_roku.py) to where it should download the requirements, especially as it seam to reside on a private gitlab?

The pure python emulated roku library is published to the python package index. Unfortunately third party components must be installed manually so it requires some knowledge, which is the same for all third party components.

The file that needs installing is just a bridge between the package on pypi and hass:)

It would be greatly appreciated if you could have a look at it when you get some time :slight_smile:

Good to have you back :slight_smile:

HA has updated python very recently and a load of components have needed sorting because of it.

Seems to work fine on 0.58.1 (official docker image)

Perhaps you have mixed up ha-emulated_roku and emulated_roku? (there’s no setup function in emulated_roku as it has nothing to do with HASS)

What you need to copy is ha-emulated_roku/components/emulated_roku.py to custom_components/emulated_roku.py and HASS should download the emulated_roku dependency from pypi when it starts up.
Your first error says that it couldn’t find (didn’t download from pypi) the emulated_roku library, which is weird.
I don’t know enough about HASS internals to know why that could happen. Have you tried restarting HASS again? (I’ve had errors like this once, a restart solved it)

I’ve used the component daily since I’ve posted it, and it is pretty stable, except for Harmony Hub losing WiFi all the time and having to reset it…

I re-enabled it (I had the config commented out and the .py file left since yesterday) and now it just loaded?!

I seriously haven’t changed it and I rebooted my haas.io docker 0.58.1 several times yesterday, so weird but I’m happy as it seams to work :slight_smile:

  "app_id": "None",
  "app_name": "Roku",
  "source": "Roku",
  "source_list": [
    "Amazon Instant Video",
    "Hulu Plus",
  "friendly_name": "Emulated Roku nPb9BmbSmALkfjKHwN28oh",
  "supported_features": 19004,
  "custom_ui_state_card": "state-card-custom-ui"

Now I’ll start looking into how set it up properly, if you have some examples feel free to share :smiley: