Emulated Roku for Harmony

There’s a requirements entry where you can specify the version in manifest.json. Just replace 0.1.8 with 0.1.9 .

in configuration.yaml correct?

didn’t see that as one of the option entries on the component page

It’s in the manifest.json file in the folder you copied over to custom_components.

@Burningstone like this?

{
  "domain": "roku",
  "name": "Roku",
  "documentation": "https://www.home-assistant.io/integrations/roku",
  "requirements": [
    "roku==0.1.8"
  ],
  "dependencies": [],
  "codeowners": []
}

No this is roku, you need emulated_roku. However, I’d just wait for the next version, saw on Github that the version got bumped a few days ago, so should be in the next HA release.

I went away for a few days, in the meantime ha updated an emulated Roku no longer working.
Is anyone else experiencing this?
I haven’t changed anything in the meantime

Yes, emulated_roku was broken by a python upgrade, then the hotfix wasn’t working with some configurations. The working fix should be available with 0.104.4

1 Like

Ok thanks, will keep an eye out for the update

Hello, i’m hoping someone can help me. I have Homeassistant running in docker, it’s running under host networking on my unraid box. My unraid box has a normal nic on a 192.168.1.x range and a vlan in 192.168.2.x range so Homeassistant can talk to my IOT devices.

I have this in my configuration.yaml

emulated_roku:
  servers:
    - name: Home Assistant
      listen_port: 8060
      advertise_port: 8060
      host_ip: 192.168.2.6
      advertise_ip: 192.168.2.6

But for some reason it’s only accessible on 192.168.1.6:8060 and not 192.168.2.6:8060. Watching home assistant docker logs i see

2020-03-20 18:49:11 INFO (MainThread) [homeassistant.components.discovery] Found new service: roku {'host': '192.168.1.6', 'port': 8060, 'ssdp_description': 'http://192.168.1.6:8060/', 'name': 'Home Assistant', 'model_name': 'Roku 4', 'model_number': '4400x', 'serial': 'Home Assistant', 'manufacturer': 'Roku', 'udn': 'uuid:2833e761-db6f-561a-8f8e-c74c1f63609c', 'upnp_device_type': 'urn:roku-com:device:player:1-0'}

For some reason it’s ignoring my options. My emulated hue component works as expected with very similar options.
Any idea whats up? I also noticed a few people mentioning manually downloading the component and adding it to the custom_components folder, I haven’t done this, could this be what’s causing my issue?

Once the config is imported from configuration.yaml (so it shows up on the Integrations page), it won’t import it again, even if it changes.

I have no idea what the stance is on config.yaml vs Integrations currently, but it’s probably a bug, it was copied from another component.

Removing the emulated roku integration from the UI and restarting home assistant should import it again.

That’s done the job, thank you very much! Now successfully added to my Harmony as well, superstar

Current guidelines is that configuration.yaml supercedes what’s in config options

Hi,

I recently moved my Harmony Hub to a separate VLAN and I have it working with Homeassistant (which is in my LAN). However the hub cannot detect the emulated_roku anymore. I read a few suggestions in this thread about running the advertise.py from the emulated_roku in the VLAN where the hub is, but I couldn’t get it working.

Does anyone have this same setup working? I use pfSense as my router.

Cheers.

I have a similar setup with the harmony in a separate VLAN. Here’s what I did back then to make it work:
From a computer in the same VLAN as the harmony hub do the following:

  • install python3 and pip3
  • pip3 install aiohttp
  • create a file advertise.py with the following content
"""Advertise an emulated Roku API on the specified address."""

if __name__ == "__main__":
    import logging

    from asyncio import get_event_loop
    from argparse import ArgumentParser
    from os import name as osname

    from emulated_roku import EmulatedRokuDiscoveryProtocol, \
        get_local_ip, \
        MULTICAST_GROUP, MULTICAST_PORT

    logging.basicConfig(level=logging.DEBUG)

    parser = ArgumentParser(description='Advertise an emulated Roku API on the specified address.')
    parser.add_argument('--multicast_ip', type=str,
                        help='Multicast interface to listen on')
    parser.add_argument('--api_ip', type=str, required=True,
                        help='IP address of the emulated Roku API')
    parser.add_argument('--api_port', type=int, required=True,
                        help='Port of the emulated Roku API.')
    parser.add_argument('--name', type=str, default="Home Assistant",
                        help='Name of the emulated Roku instance')
    parser.add_argument('--bind_multicast', type=bool,
                        help='Whether to bind the multicast group or interface')

    args = parser.parse_args()


    async def start_emulated_roku(loop):
        multicast_ip = args.multicast_ip if args.multicast_ip else get_local_ip()
        bind_multicast = args.bind_multicast if args.bind_multicast else osname != "nt"

        _, discovery_proto = await loop.create_datagram_endpoint(
            lambda: EmulatedRokuDiscoveryProtocol(loop,
                                                  multicast_ip, args.name,
                                                  args.api_ip,
                                                  args.api_port),
            local_addr=(
                MULTICAST_GROUP if bind_multicast else multicast_ip,
                MULTICAST_PORT),
            reuse_address=True)


    loop = get_event_loop()

    loop.run_until_complete(start_emulated_roku(loop))

    loop.run_forever()
  • python3 advertise.py --api_ip=ip_of_home_assistant --api_port=8060 --name=name_defined_in_configuration.yaml
  • search for the roku device on the harmony hub

It was a long time ago when I did this, probably it’s easier now and I’m not even sure if this will still work but it’s worth a try

Also check if multicast is enabled in your router, as far as I know this is an issue due to missing multicast.

1 Like

Thanks that worked.

However I needed to use the full emulated roku component (from this post Emulated Roku for Harmony - #162 by mindigmarton) . The advertise.py on its own is not enough, it needs the other files in the component to run properly.

Yeah, your absolutely right, sorry forgot about that :slight_smile: was a long time ago :sweat_smile:

I have an issue when trying to use Emulated Roku and Emulated Hue. If I only set up Emulated Roku:

emulated_roku:
  servers:
    - name: Roku HA
      listen_port: 8060
      advertise_port: 8060

it works ok. But when I add Emulated Hue to my system with the following config:

emulated_hue:
  listen_port: 8070

Hue starts ok but Emulated Roku ends up with errors and does not start:

2020-10-20 12:59:42 ERROR (MainThread) [homeassistant.components.emulated_roku] Failed to start Emulated Roku Roku HA on 10.144.1.163:8060
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.8/site-packages/homeassistant/components/emulated_roku/binding.py", line 142, in emulated_roku_start
    await self._api_server.start()
  File "/srv/homeassistant/lib/python3.8/site-packages/emulated_roku/__init__.py", line 419, in start
    self.sock.bind(("", MULTICAST_PORT))

I have also tried to add the upnp_bind_multicast: false option to my Roku config but the result is the same.
Finally, I was able to configure both to work by specifying different advertise_port for both (although not really sure what is the minimum configuration required to make it work):

emulated_roku:
  servers:
    - name: Roku HA
      listen_port: 8060
      advertise_port: 8080
      upnp_bind_multicast: false

emulated_hue:
  listen_port: 8070
  advertise_port: 8090
  upnp_bind_multicast: false

Has anyone been able to solve this error when running emulated_roku in docker?

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/emulated_roku/binding.py", line 142, in emulated_roku_start
    await self._api_server.start()
  File "/usr/local/lib/python3.8/site-packages/emulated_roku/__init__.py", line 419, in start
    self.sock.bind(("", MULTICAST_PORT))
OSError: [Errno 98] Address in use

I’m currently using host networking, and it doesn’t matter what listen port I use, I get the same error with literally any port.
Here’s my relevant config:

emulated_roku:
  servers:
    - name: HA
      host_ip: 192.168.1.5
      upnp_bind_multicast: True
      listen_port: 8060

emulated_roku might be missing a socket configuration option that causes the “Address in use” when something else is already using upnp with different socket configuration (like emulated_hue)

I’ll check it out tonight. Should be a 1 line fix, easy to reproduce.

The listen port has no effect on this, the error happens with setting up the auto-discovery mechanism, which uses a constant port number.