Emulated Hue - "only local IPs allowed"

Hello,

I’m new to HA. I haven’t had too many problems so far connecting zigbee and z-wave devices. I’m to the point where I want to have some of these devices controlled via Alexa (without having to pay for a monthly subscription). I have added the following to the configuration.yaml file to enable Emulated Hue.

emulated_hue:
host_ip: 11.0.0.35
listen_port: 8300
expose_by_default: true

When I tested the URL to see if the devices are exposed i get the following response:

{“message”: “only local IPs allowed”}

I’m currently in the local network configuring from (11.0.0.9) and not sure whats blacklisting my IP.

I’m running a RPi 3B+ 32Bit HA with HUSBZB-1 gateway.

Any help is much appreciated.

You are using a Department of Defense ip address range at home!

You should be using one of the private address ranges. In your case, the easiest may be to change the first 11 to 10

https://whois.arin.net/rest/net/NET-11-0-0-0-1/pft?s=11.0.0.35

I have the same problem and this is the only topic that comes out from searching. Mine network is 55.55.1.1/255 and when i’ve searched on the whois db it comes out as some usa military shit again… I cannot change my whole network with a snap of my fingers and i cannot wrap my head around the connection of the private ips and networks with the public ones and even emulated_hue component???
Is there another solution or the solution is dead in the water?

looks like this is a restriction from home assistant. Debugging into the code shows that home assistant only allows the following local networks and there’s no way around it.

    
"""Network utilities."""
from ipaddress import IPv4Address, IPv6Address, ip_address, ip_network
from typing import Union

# IP addresses of loopback interfaces
LOCAL_IPS = (
    ip_address('127.0.0.1'),
    ip_address('::1'),
)

# RFC1918 - Address allocation for Private Internets
LOCAL_NETWORKS = (
    ip_network('10.0.0.0/8'),
    ip_network('172.16.0.0/12'),
    ip_network('192.168.0.0/16'),
)


def is_local(address: Union[IPv4Address, IPv6Address]) -> bool:
    """Check if an address is local."""
    return address in LOCAL_IPS or \
        any(address in network for network in LOCAL_NETWORKS)

EDIT: Well, home assistant in general isn’t blocking it, emulated hue is using the func is_local. Which is why you’re getting the error.

1 Like

Can something be changed so that emulated_hue accepts other networks?

Why are you using public network subnets within your LOCAL AREA NETWORK?

Because I can? :thinking: and that’s not the point. The point is, is it possible to use these network subnets within my PRIVATE network?

Sure. If you want to break apps that don’t expect you to be using non-sanctioned private subnets.

1 Like

Same here. My Home Assistant has a public IP adress in a /27 network which is assigned to my DSL line. There’s nothing wrong with this setup, but Emulated Hue refuses to use it.

Any way to change / override the is_local function without changing HA code?

EDIT: I’ve filed an issue: https://github.com/home-assistant/home-assistant/issues/30701

EDIT 2: Workaround:

  1. Create folder custom_components/emulated_hue
  2. Download all files from https://github.com/home-assistant/home-assistant/tree/dev/homeassistant/components/emulated_hue and put them into the newly created folder custom_components/emulated_hue
  3. Edit file hue_api.py and remove all IP checks - several occurrences; look for lines like these and delete them:
        if not is_local(request[KEY_REAL_IP]):
            return self.json_message("Only local IPs allowed", HTTP_UNAUTHORIZED)
  1. Save file
  2. Restart Home Assistant

The custom component overrides the build-in one.

Not a great workaround, but it works for the time being.

1 Like