Emulated Roku for Harmony


#143

Then it is close!

Though I think there are work arounds.


#144

Yep, use a proper browser :slight_smile:


#145

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":[[],[],[],[],[],[],[],[],[],[],[],[],[],[]]}]

#146

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.


#147

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?


#148

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:


#149

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:


#150

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)


#151

In some regard this does the same as the Homekit component


#152

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!


#153

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?


#154

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:


#155

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?)


#156

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.


#157

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?


#158

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


#159

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?


#160

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)


#161

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.


#162

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.