Working on multiple emulated_hue instances

the scens are not too many I think. This is HUE 2 (only scene)

{"scene.acqua_blue_front_yard": {"modelid": "HASS123", "name": "Acqua blue front yard", "state": {"bri": 255, "on": true, "reachable": true}, "swversion": "123", "type": "Dimmable light", "uniqueid": "scene.acqua_blue_front_yard"}, "scene.acqua_blue_kitchen": {"modelid": "HASS123", "name": "Acqua blue kitchen", "state": {"bri": 255, "on": true, "reachable": true}, "swversion": "123", "type": "Dimmable light", "uniqueid": "scene.acqua_blue_kitchen"}, "scene.acqua_blue_livingroom": {"modelid": "HASS123", "name": "Acqua blue livingroom", "state": {"bri": 255, "on": true, "reachable": true}, "swversion": "123", "type": "Dimmable light", "uniqueid": "scene.acqua_blue_livingroom"}, "scene.acqua_blue_tv_room": {"modelid": "HASS123", "name": "Acqua blue TV room", "state": {"bri": 255, "on": true, "reachable": true}, "swversion": "123", "type": "Dimmable light", "uniqueid": "scene.acqua_blue_tv_room"}, "scene.blue_front_yard": {"modelid": "HASS123", "name": "Blue front yard", "state": {"bri": 255, "on": true, "reachable": true}, "swversion": "123", "type": "Dimmable light", "uniqueid": "scene.blue_front_yard"}, "scene.blue_kitchen": {"modelid": "HASS123", "name": "Blue kitchen", "state": {"bri": 255, "on": true, "reachable": true}, "swversion": "123", "type": "Dimmable light", "uniqueid": "scene.blue_kitchen"}, "scene.blue_livingroom": {"modelid": "HASS123", "name": "Blue livingroom", "state": {"bri": 255, "on": true, "reachable": true}, "swversion": "123", "type": "Dimmable light", "uniqueid": "scene.blue_livingroom"}, "scene.bright_kitchen": {"modelid": "HASS123", "name": "Bright kitchen", "state": {"bri": 255, "on": true, "reachable": true}, "swversion": "123", "type": "Dimmable light", "uniqueid": "scene.bright_kitchen"}, "scene.concentrate_kitchen": {"modelid": "HASS123", "name": "Concentrate kitchen", "state": {"bri": 255, "on": true, "reachable": true}, "swversion": "123", "type": "Dimmable light", "uniqueid": "scene.concentrate_kitchen"}, "scene.dimmed_kitchen": {"modelid": "HASS123", "name": "Dimmed kitchen", "state": {"bri": 255, "on": true, "reachable": true}, "swversion": "123", "type": "Dimmable light", "uniqueid": "scene.dimmed_kitchen"}, "scene.green_front_yard": {"modelid": "HASS123", "name": "Green front yard", "state": {"bri": 255, "on": true, "reachable": true}, "swversion": "123", "type": "Dimmable light", "uniqueid": "scene.green_front_yard"}, "scene.green_kitchen": {"modelid": "HASS123", "name": "Green kitchen", "state": {"bri": 255, "on": true, "reachable": true}, "swversion": "123", "type": "Dimmable light", "uniqueid": "scene.green_kitchen"}, "scene.green_livingroom": {"modelid": "HASS123", "name": "Green livingroom", "state": {"bri": 255, "on": true, "reachable": true}, "swversion": "123", "type": "Dimmable light", "uniqueid": "scene.green_livingroom"}, "scene.purple_front_yard": {"modelid": "HASS123", "name": "Purple front yard", "state": {"bri": 255, "on": true, "reachable": true}, "swversion": "123", "type": "Dimmable light", "uniqueid": "scene.purple_front_yard"}, "scene.purple_kitchen": {"modelid": "HASS123", "name": "Purple kitchen", "state": {"bri": 255, "on": true, "reachable": true}, "swversion": "123", "type": "Dimmable light", "uniqueid": "scene.purple_kitchen"}, "scene.purple_livingroom": {"modelid": "HASS123", "name": "Purple livingroom", "state": {"bri": 255, "on": true, "reachable": true}, "swversion": "123", "type": "Dimmable light", "uniqueid": "scene.purple_livingroom"}, "scene.red_front_yard": {"modelid": "HASS123", "name": "Red front yard", "state": {"bri": 255, "on": true, "reachable": true}, "swversion": "123", "type": "Dimmable light", "uniqueid": "scene.red_front_yard"}, "scene.red_kitchen": {"modelid": "HASS123", "name": "Red kitchen", "state": {"bri": 255, "on": true, "reachable": true}, "swversion": "123", "type": "Dimmable light", "uniqueid": "scene.red_kitchen"}, "scene.red_livingroom": {"modelid": "HASS123", "name": "Red livingroom", "state": {"bri": 255, "on": true, "reachable": true}, "swversion": "123", "type": "Dimmable light", "uniqueid": "scene.red_livingroom"}, "scene.relax_kitchen": {"modelid": "HASS123", "name": "Relax kitchen", "state": {"bri": 255, "on": true, "reachable": true}, "swversion": "123", "type": "Dimmable light", "uniqueid": "scene.relax_kitchen"}, "scene.white_front_yard": {"modelid": "HASS123", "name": "White front yard", "state": {"bri": 255, "on": true, "reachable": true}, "swversion": "123", "type": "Dimmable light", "uniqueid": "scene.white_front_yard"}, "scene.white_kitchen": {"modelid": "HASS123", "name": "White kitchen", "state": {"bri": 255, "on": true, "reachable": true}, "swversion": "123", "type": "Dimmable light", "uniqueid": "scene.white_kitchen"}, "scene.white_livingroom": {"modelid": "HASS123", "name": "White livingroom", "state": {"bri": 255, "on": true, "reachable": true}, "swversion": "123", "type": "Dimmable light", "uniqueid": "scene.white_livingroom"}}

I count 23 entries. This should be ok.

Ohh it found, needed to wait a while now 161 devices

Sweet!.

Yep - I do it from the alexa web page and it can spin for a while some times.

1 Like

thanks, great code, you should ask to put it in regular distribution. Is handy for many

Yep. I’ll look into it.

I’m considering how to change the configuration so it will be backward compatible with the majority of configurations that don’t need multiple instances.

Let me know if you discover any issues.

nope, added also groups, now 195 devices.

Problem now I have to exclude some names, since they might conflict (because of my naming of groups)

Excellent code

@anon35356645 - if you have multiple Echo’s you might want to use target_ip. This setting is used to restrict responses of the emulated_hue to only that IP address.

In my network I have two Echo’s and other services (e.g. Plex, iMacs, etc.) that are constantly sending out multicast UPNP requests. Without target_ip the emulated_hue is responding to these various requests. With target_ip it will only respond if the request that is from that particular ip address.

In an network with multiple Echo’s — each of the Echo’s will go through the multicast UPNP request/response, GET /desciption.xml and GET /lights request for each configured emulated_hue. This can be a lot of traffic this all going to update the same Alexa account.

If you set target_ip to be one Echo IP address the emulated_hues would not respond to other Echo requests and the amount of network traffic will be minimized.

Just something to think about.

I would eventually like to allow for the listen_port to be optional and for the port to be automatically selected from the ephemeral range. But, that requires changes in HomeAssistantWSGI.

mmhh I see, I have 4 echo and 191 devices (emulated hue + physical hue). Shall I make distinction?

You might try the target_ip setting. This might reduce the overall amount of data being transmitted from HA to each of your Echos. By setting target_ip for both emulated_hue instances to the same single Echo IP address the Alexa discover devices might finish sooner and be a little more reliable.

Remember that without target_ip each Echo is getting your full list of configured devices and all four are reporting that to your Alexa account. That is four copies of the data.

So, your config would like something like this:

emulated_hue:
  hue1:
    type: alexa
    listen_port: 8301
    target_ip: 192.168.1.100
    exposed_domains:
      - switch
      - script
      - light
  hue2:
    type: alexa
    listen_port: 8302
    target_ip: 192.168.1.100
    exposed_domains:
      - scene
      - group

Where 192.168.1.100 would be substituted for the IP address of one of your Echos.

If you are using DHCP for your Echo this could be a little problematic because it might pick up a new IP address in the future.

Yes understand.

But like this the commands will work only for that particular echo?

No. The Alexa account is what you are updating. Your Alexa account is overlaid on top of you four Echos. From what I’ve experienced any Echo can learn something and update the account. Then any Echo can be used to trigger the service to control the device.

I see, so is definitely a good idea to do that.

Will do today

But then I would launch the command of DISCOVER DEVICES" from that Echo only, or it doesn’t matter?

Mmhh back to my 87 devices…

EDIT

It works, was my usual problem of Virtual Mac Address caused by my EX7000 (sxxx) extender that when a device connects to it it changes the firdt 6 digit of the MAC address, which makes the assignment of the static IP address wrong by the central router which has DHCP.

And since the Echo do not show which IP are connected (neither has the option to apply static ip address) it make all a bit more complicated

Great great code.

Now I can make any group/scene I like and command it from Alexa

Yep. It solves some problems.

Yesterday I entered a PR to submit these changes to the baseline code but I received response from the core developer team that this seemed like it was adding too much complexity to what is already a hack (emulated_hue). They suggested I offer it as a custom_component.

So, I’ll keep the separate repository: https://github.com/shenning00/emulated_hue as the hosting spot for this component.

Hi,

Tonigh, back home, all the scenes are offline. Any explanation of what could be?

Re-running discoverr devices fixes it

Not sure. I’ll do some searches.