Emulated Roku for Harmony

Then it is close!

Though I think there are work arounds.

Yep, use a proper browser :slight_smile:

Got my harmony yesterday and love this component! Thanks to @mindigmarton for your hard work!

Thought I would share this for anyone using node-red. Basically you just have to add your actions.
All possible key presses are already included.

[{"id":"b34ad378.5c0a1","type":"tab","label":"Emulated Roku","disabled":false,"info":""},{"id":"d8f4dc3b.615e1","type":"server-events","z":"b34ad378.5c0a1","name":"All Events","server":"9582d396.920b1","x":180,"y":220,"wires":[["ff39f1d7.a208e"]]},{"id":"ff39f1d7.a208e","type":"switch","z":"b34ad378.5c0a1","name":"Roku Command","property":"payload.event_type","propertyType":"msg","rules":[{"t":"eq","v":"roku_command","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":370,"y":220,"wires":[["5a37ded2.5f34c"]]},{"id":"5a37ded2.5f34c","type":"switch","z":"b34ad378.5c0a1","name":"Key Type","property":"payload.event.key","propertyType":"msg","rules":[{"t":"eq","v":"Up","vt":"str"},{"t":"eq","v":"Down","vt":"str"},{"t":"eq","v":"Left","vt":"str"},{"t":"eq","v":"Right","vt":"str"},{"t":"eq","v":"Select","vt":"str"},{"t":"eq","v":"Back","vt":"str"},{"t":"eq","v":"Play","vt":"str"},{"t":"eq","v":"Rev","vt":"str"},{"t":"eq","v":"Fwd","vt":"str"},{"t":"eq","v":"Search","vt":"str"},{"t":"eq","v":"PowerOff","vt":"str"},{"t":"eq","v":"Info","vt":"str"},{"t":"eq","v":"Home","vt":"str"},{"t":"eq","v":"InstantReplay","vt":"str"}],"checkall":"true","repair":false,"outputs":14,"x":630,"y":290,"wires":[[],[],[],[],[],[],[],[],[],[],[],[],[],[]]}]
2 Likes

PR is open! https://github.com/home-assistant/home-assistant/pull/17596

For some reason my build env in WSL kept failing. Took me a while to fix.

Unfortunately Iā€™ve had to break compatibility with the configuration.yaml entry format because of a few reasons, if it merges as is, everyone using this component will have to update their yaml, or use the new Integration UI.

1 Like

Nice, well done, love this and consider it an essential for any Harmony user.

Hopefully more people will look into it when itā€™s released, though to be honest, I still think most are confused by the name and, given how averse people are at reading anything nowadays, dismiss it even when you tell them itā€™s exactly what theyā€™re looking for, worth considering a rename for the component and just explain the way it does it is by emulating a wifi Roku perhaps?

Iā€™m not sure what would be an appropriate name, as emulated_hue already exists and it pretty much works the same.
The docs do mention use cases for harmony, android remotes.
Iā€™ve expanded the docs heavily from the responses in this thread so hopefully it covers all questions:

https://github.com/home-assistant/home-assistant.io/pull/6928/files

1 Like

I think itā€™'s because itā€™s an easy leap for people to see why theyā€™d find emulating Hue useful, particularly as itā€™s going from HA to Alexa, Harmony or whatever, and they know what Hue is.

On the other hand yours emulating a Roku isnā€™t obvious why youā€™d want it from the name, several Iā€™ve recommended it to thought it was some sort of media player.

Like you, Iā€™m not sure what would be a good name but something directly related to Harmony and HA would be better and personally Iā€™d just mention it does its magic by emulating a Roku in the docs. Following zigbee2mqtt you could do worse than harmony2ha perhaps? Given this is in effect a new release itā€™s the ideal time to do it.

Either way, many thanks for the excellent work :+1:

That is true. Though I donā€™t think a suitable name or category currently exists.

Home Assistant needs better discovery for functionality, the current categories for components are starting to be weird. Currently the doc is assigned to the ā€˜Hubā€™ category like emulated_hue.

Browsing the docs atm, maybe it should be in the ā€˜Automationsā€™ category? (itā€™s pretty much like LIRC)
Though thereā€™s REST command in there too, which is just confusing.

Even as a developer, Iā€™m quite confused whenever Iā€™m searching the docs. Does this component allow me to receive input via another system (LIRC, Some random API, emulated_hue)? Call another system (REST Command, Harmony remote)? Does it connect to a hub (deconz)? A random device? Is it using auto-discovery (lifx)? Is it just a dummy entity in HA? (templates, scripts, etc)

In some regard this does the same as the Homekit component

I was monkeying with my aging iobroker installation which I use for Roku emulation. I was thinking man I wish somebody smarter than me would roll this into hass, and thought then hey maybe I should look and here I am. THANK YOU @mindigmarton ! This is exactly what I needed!

edit: disregard below, setting global log level to debug seems to have worked and I can now see my events.

Turns out my excitement was premature. This is almost working but I canā€™t seem to get it to actually trigger events when commands are sent.

configuration.yaml entries

emulated_roku:
  host_ip: 10.0.0.22 # should be set to Home Assistant's address
  advertise_ip: 10.0.0.22 # optional, defaults to host_ip if not specified
  upnp_bind_multicast: true # optional, defaults to True
  listen_ports:
    - 8060
logger:
  default: info

log results

2018-11-26 15:22:14 INFO (MainThread) [homeassistant.loader] Loaded emulated_roku from custom_components.emulated_roku
2018-11-26 15:22:14 WARNING (MainThread) [homeassistant.loader] You are using a custom component for emulated_roku 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.
2018-11-26 15:22:14 INFO (MainThread) [homeassistant.setup] Setting up emulated_roku
2018-11-26 15:22:14 INFO (MainThread) [custom_components.emulated_roku] Initializing emulated roku
2018-11-26 15:22:14 INFO (MainThread) [homeassistant.setup] Setup of domain emulated_roku took 0.0 seconds.
2018-11-26 15:22:24 INFO (MainThread) [custom_components.emulated_roku] Intializing emulated roku 10.0.0.22:8060

This all looks good (I think). When I run discovery from Harmony I see the device, when I open http://10.0.0.22:8060 I get the Roku XML. However, I donā€™t seem to be receiving any messages. When I press buttons on the Harmony I never get any events from emulated_roku. curl -X POST http://10.0.0.22:8060/keypress/Back similarly never seems to trigger any event. I have logger set to info, which I believe is what I should be after. Setting to debug yields the same result.

Any guidance as to what might be going wrong here?

Iā€™ve been toying with the version in gitlab (is this the latest?) - but one thing that Iā€™m struggling with is that I cannot do a ā€˜powerupā€™ or ā€˜powerdownā€™ with it (i think) - I want to add this as the first item in a Harmony activity, but sofar iā€™m failing to do so :frowning:

Unfortunately there is no Power On / Off command on the API.
(Harmony probably sends an IR command when turning the Roku on like app launching?)

1 Like

Thanks for the answer - Iā€™ve never seen a Roku in the ā€¦ ehā€¦ box, since we donā€™t have those here - so I was freewheeling on how it might work.

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