home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
72.15k stars 30.19k forks source link

Emulate Hue not working #106937

Open ymurawski opened 9 months ago

ymurawski commented 9 months ago

The problem

Hi, i added the code below to my configuration.yaml but Alexa wont detect my devices. Any ideas ? Im using HAOS.

emulated_hue: listen_port: 80 host_ip: 192.168.1.118 expose_by_default: false entities: script.test_alexa: name: TEST hidden: false

When i test it with http://192.168.1.118/api/v2/lights i get

{"1":{"state":{"on":false,"reachable":true,"mode":"homeautomation"},"name":"TEST","uniqueid":"00:96:30:f2:e5:c7:03:bd-62","manufacturername":"Home Assistant","swversion":"123","type":"On/Off light","productname":"On/Off light","modelid":"HASS321"}}

What version of Home Assistant Core has the issue?

core-2024.1.0b1

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

emulate_hue

Link to integration documentation on our website

No response

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

home-assistant[bot] commented 9 months ago

Hey there @bdraco, @tho85, mind taking a look at this issue as it has been labeled with an integration (emulated_hue) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `emulated_hue` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign emulated_hue` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


emulated_hue documentation emulated_hue source (message by IssueLinks)

spralexx commented 8 months ago

I have a similar issue.

Version 2024.1.5 running in the cloud in Docker connected to the local network via IPSec. For auto discovery i have setup a local mDNS responder that serves the following:

mDNS:

+ phy0-sta0 IPv4 Hue Bridge - 255ACC                           _hue._tcp            local
+ phy0-sta0 IPv6 Hue Bridge - 255ACC                           _hue._tcp            local
= phy0-sta0 IPv4 Hue Bridge - 255ACC                           _hue._tcp            local
   hostname = [001788255acc.local]
   address = [172.16.238.13]
   port = [80]
   txt = ["modelid=BSB002" "bridgeid=001788fffe255acc"]
= phy0-sta0 IPv6 Hue Bridge - 255ACC                           _hue._tcp            local
   hostname = [001788255acc.local]
   address = [172.16.238.13]
   port = [80]
   txt = ["modelid=BSB002" "bridgeid=001788fffe255acc"]

HA config:

emulated_hue:
  listen_port: 80
  advertise_ip: 172.16.238.13
  host_ip: 172.16.238.13
  exposed_domains:
    - light
  entities:
    light.esstisch:
      name: "Esstisch"

My Philips TV does not even recognize the Bridge at all. When trying to integrate the bridge into the Philips Hue App on iOS it performs an API request to /api/config that is being served with the following but does not connect properly.

{"name":"HASS BRIDGE","mac":"00:00:00:00:00:00","swversion":"01003542","apiversion":"1.17.0","whitelist":{"nouser":{"name":"HASS BRIDGE"}},"ipaddress":"172.16.238.13:80","linkbutton":true}

Also /api/v2/lights serves:

{"19":{"state":{"on":false,"reachable":true,"mode":"homeautomation","bri":1,"hue":0,"sat":0,"ct":153,"effect":"none","colormode":"ct"},"name":"Esstisch","uniqueid":"00:d3:c3:49:d3:ff:64:42-11","manufacturername":"Home Assistant","swversion":"123","type":"Extended color light","modelid":"HASS231"}}

Currently debugging this with a friend that has an original bridge.

spralexx commented 8 months ago

Ok, I got the Hue App into discovering my emulated bridge with the following on /api/config I could also use oder software/API version but then the app wants to update the bridge during setup.

{
         "name": "Hue Bridge",
         "datastoreversion": "165",
         "swversion": "1962097030",
         "apiversion": "1.62.0",
         "mac": "00:17:88:25:5a:cc",
         "bridgeid": "001788fffe255acc",
         "factorynew": False,
         "replacesbridgeid": None,
         "modelid": "BSB002",
         "starterkitid": "",
         "whitelist": {HUE_API_USERNAME: {"name": "HASS BRIDGE"}},
         "ipaddress": f"{config.advertise_ip}:{config.advertise_port}",
         "portalservices": True,
         "linkbutton": True,
          "swupdate": {
            "updatestate": 0,
            "url": "",
            "text": "",
            "notify": False
          }
     }

But now the app is telling me to push a Button on the Bridge. My TV still does not recognize the bridge at all.

WarleyGabriel commented 8 months ago

I have the same issue, when I call http://192.168.15.13/api/v2/lights I get:

{
  "1": {
    "state": { "on": false, "reachable": true, "mode": "homeautomation" },
    "name": "Home Cinema",
    "uniqueid": "00:b9:28:45:19:3c:9a:7a-b6",
    "manufacturername": "Home Assistant",
    "swversion": "123",
    "type": "On/Off light",
    "productname": "On/Off light",
    "modelid": "HASS321"
  },
  "3": {
    "state": { "on": false, "reachable": true, "mode": "homeautomation" },
    "name": "Sanca",
    "uniqueid": "00:9c:62:66:4a:5a:c1:9c-e7",
    "manufacturername": "Home Assistant",
    "swversion": "123",
    "type": "On/Off light",
    "productname": "On/Off light",
    "modelid": "HASS321"
  }
}

Also I get the bellow response when I call http://192.168.15.13/description.xml:

This XML file does not appear to have any style information associated with it. The document tree is shown below.
<root xmlns="urn:schemas-upnp-org:device-1-0">
<specVersion>
<major>1</major>
<minor>0</minor>
</specVersion>
<URLBase>http://192.168.15.13:80/</URLBase>
<device>
<deviceType>urn:schemas-upnp-org:device:Basic:1</deviceType>
<friendlyName>Home Assistant Bridge (192.168.15.13)</friendlyName>
<manufacturer>Royal Philips Electronics</manufacturer>
<manufacturerURL>http://www.philips.com</manufacturerURL>
<modelDescription>Philips hue Personal Wireless Lighting</modelDescription>
<modelName>Philips hue bridge 2015</modelName>
<modelNumber>BSB002</modelNumber>
<modelURL>http://www.meethue.com</modelURL>
<serialNumber>001788FFFE23BFC2</serialNumber>
<UDN>uuid:2f402f80-da50-11e1-9b23-001788255acc</UDN>
</device>
</root>

But Alexa is not able to find any device.

I'm using HA Core version 2024.1.6. I don't have any echo device, I'm not sure if I need one to have this working. Do you guys have any idea how can I fix it?

spralexx commented 8 months ago

Seems like the API implemented here is lacking some functionality that is required by the Philips Hue app and some other components. eg. the linking and user creation process.

I just found out about diyHue yesterday:

With that I got the App working properly together with my Homeassistant. Regarding the docs it is easy to setup if you are running HA OS or are using HA Cloud. In my setup I just added the following to my docker-compose file:

  diyHue:
    image: diyhue/core:latest
    # This makes for more convienient naming, but only allows one instance of the image
    container_name: diyHue
    restart: always

    environment:
      # Uncomment to enable debug mode 
      DEBUG: 1
      # IP and MAC are only needed for running diyHue in the bridge network
      IP: 172.16.238.46
      MAC: 12:34:56:78:90:AB
    volumes:
      - /mnt/hue-emulator/export:/opt/hue-emulator/export
    expose:
      - '80'
      - '443'
      - '1900'
      - '2100'
      - '1982'

As mentioned earlier the docker network is connected to my home network via IPSec and I am running the following Scripts on a local device for auto discovery:

mDNS Discovery running as systemd service:

#!/bin/bash

function _term {
  pkill -P $$
}

trap _term SIGTERM

/usr/bin/avahi-publish-service "DiyHue" _hue._tcp 80 'bridgeid=1234567890ab' 'modelid=BSB002' -H DIYHue.local &
/usr/bin/avahi-publish-address DIYHue.local 172.16.238.46 -R &

while true; do sleep 10000; done

NodeJS script for UPNP discovery:

var ssdp = require("peer-ssdp");
var peer = ssdp.createPeer();
var interval;
/**
 * handle peer ready event. This event will be emitted after `peer.start()` is called.
 */
peer.on("ready",function(){
    // handle ready event
    // send ssdp:alive messages every 1s
    // {{networkInterfaceAddress}} will be replaced before
    // sending the SSDP message with the actual IP Address of the corresponding
    // Network interface. This is helpful for example in UPnP for LOCATION value
    interval = setInterval(function(){
        peer.alive({
"CACHE-CONTROL": "max-age=60",
"EXT": "",
"LOCATION": "http://172.16.238.46:80/description.xml",
"SERVER": "FreeRTOS/6.0.5, UPnP/1.0, IpBridge/1.20.0",
"hue-bridgeid": "1234567890ab",
"ST": "upnp:rootdevice",
"USN": "uuid:2f402f80-da50-11e1-9b23-1234567890ab::upnp:rootdevice"
        });
    }, 20000);
    // shutdown peer after 10 s and send a ssdp:byebye message before
//    setTimeout(function(){
//        clearInterval(interval);
//        // Close peer. Afer peer is closed the `close` event will be emitted.
//        peer.close();
//    }, 10000);
});

// handle SSDP NOTIFY messages. 
// param headers is JSON object containing the headers of the SSDP NOTIFY message as key-value-pair. 
// param address is the socket address of the sender
peer.on("notify",function(headers, address){
    // handle notify event
});

// handle SSDP M-SEARCH messages. 
// param headers is JSON object containing the headers of the SSDP M-SEARCH message as key-value-pair. 
// param address is the socket address of the sender
peer.on("search",function(headers, address){
    // handle search request
    // reply to search request
    // Also here the {{networkInterfaceAddress}} will be replaced before
  // sending the SSDP message with the actual IP Address of the corresponding
  // Network interface.
    peer.reply({
"CACHE-CONTROL": "max-age=60",
"EXT": "",
"LOCATION": "http://172.16.238.46:80/description.xml",
"SERVER": "FreeRTOS/6.0.5, UPnP/1.0, IpBridge/1.20.0",
"hue-bridgeid": "1234567890ab",
"ST": "urn:schemas-upnp-org:device:basic:1",
"USN": "uuid:2f402f80-da50-11e1-9b23-1234567890ab"
    },address);
    console.log("M-SEARCH EVENT FIRED with address: "+JSON.stringify(address));

});

// handle SSDP HTTP 200 OK messages. 
// param headers is JSON object containing the headers of the SSDP HTTP 200 OK  message as key-value-pair. 
// param address is the socket address of the sender
peer.on("found",function(headers, address){
    // handle found event
});

// handle peer close event. This event will be emitted after `peer.close()` is called.
peer.on("close",function(){
    // handle close event
});

// Start peer. Afer peer is ready the `ready` event will be emitted.
peer.start();
WarleyGabriel commented 8 months ago

Great, now I have the bridge running.

Question, how can I add home assistant entities to the bridge, like lights or sensors? I need to export an entity to be able to find it on Alexa app.

Thanks in advance!

spralexx commented 8 months ago

diyHue exposes a web GUI on port 80. There you can integrate your HA instance via an API token you can acquire in HA via your user settings page all the way to the bottom.

But that shall be enough for this issue as this is about the emulated_hue component of HA. So if you've got any further questions the diyHue docs will help you or you can open an issue there.

Regarding this issue I think it would be great to have a HA "native" implementation for emulating Hue bridges. Maybe that can be achieved via integrating parts of diyHue into this or a new HA component.

As I worked around the problem for now I won't put any more effort into this.

WarleyGabriel commented 8 months ago

Yeah, got it.

It’s just not clear for me if this integration supports home assistant to ditHue or just the opposite way?

spralexx commented 8 months ago

Both ways are possible. 

steveredden commented 8 months ago

i set this up within the last week:

https://github.com/home-assistant/core/issues/29554#issuecomment-1920477092

aer0xkh commented 8 months ago

any news?

yorb commented 7 months ago

I have the same issue as OP—Alexa is not discovering my Emulated Hue input boolean. Did Amazon change something that makes this not work anymore? Wondering if it still works for anyone.

millesm commented 7 months ago

I had this working 2 weeks ago but on the weekend it stopped. I did multiple updates to HA on Friday so guessing one of those broke this integration. Currently on Core 2024.2.2

Alexa thinks that the device has been turned on/off as she replies 'OK' to the command Alexa app does not show the lights in the list anymore (they were there last week) Alexa cannot find any new devices.

beatle1987 commented 7 months ago

I had this working 2 weeks ago but on the weekend it stopped. I did multiple updates to HA on Friday so guessing one of those broke this integration. Currently on Core 2024.2.2

Alexa thinks that the device has been turned on/off as she replies 'OK' to the command Alexa app does not show the lights in the list anymore (they were there last week) Alexa cannot find any new devices.

what version did you update from? I am trying to get this working and everything appears to be working on the Home Assistant side, but Alexa can't find it.

Are there any issues known using specific alexa devices? I am using an Original Echo.

millesm commented 7 months ago

Would have been Core 2024.2.0. Between updates on the Friday and finding lights not working a week later we also had a power outage for a day. Was the next day that I found issues with this integration. Alexa also lost connection to some lights around the house while others were fine.

The HA verification tests return the expected data - Alexa app finds nothing. Using original echo dot.

beatle1987 commented 7 months ago

Hopefully the following can help. The description.xml on home assistant reports the following information, but the Hue Essentials app seems to have different Model number and Serial Number. The app also brings up the error "Unexpected response from bridge. Please try again later. Expected BEGIN_OBJECT but was NUMBER at path $" but I think thats because it isnt a proper bridge.

HA description.xml:

`

1 0 http://192.168.0.11:80/ urn:schemas-upnp-org:device:Basic:1 Home Assistant Bridge (192.168.0.11) Royal Philips Electronics http://www.philips.com Philips hue Personal Wireless Lighting Philips hue bridge 2015 BSB002 http://www.meethue.com 001788FFFE23BFC2 uuid:2f402f80-da50-11e1-9b23-001788255acc ` Hue Essentials: MAC address 00:00:00:00:00:00 Identifier 000000FFFE000000 Model ID BSB001 API Version 1.17.0 Software version 01003542
pixel74 commented 6 months ago

Have same issue! Adding type: alexa to config will make it work again. The problem is, Alexa type is deprecated and will be removed in a future version.

Core: 2024.3.1 Supervisor: 2024.03.0 Operating System: 12.1

FS1961 commented 6 months ago

I have a similar problem. I have Echo tied to Amazon.de and another to Amazon.com. The emulated hue Boolean.toggle is discovered by the US device but not the German device. German device is Echo v1, US device is Echo show 5.

Is there something different required? Core 2024.3.1 Supervisor 2024.03.0 Operating System 12.1 Frontend 20240307.0

sudo-su-root commented 6 months ago

First time setup, added a single device and seemed to work but decided to rename it and my echo dot still recognised the old device name and would not find a new one, neither showing in the alexa app.

Wiped the config completely on HA and restarted Wiped /usr/share/hassio/homeassistant/.storage/emulated_hue.ids < file might be somewhere else depending on install Re-added config and asked alexa to find device and nothing found but! that config file was repopulated so things are talking

Found an issue talking about cached devices lists so had an idea...

Wiped the config completely on HA and restarted Wiped /usr/share/hassio/homeassistant/.storage/emulated_hue.ids - the file might be somewhere else depending on install Wiped and setup new my echo dot using reset procedure - google it, varies a little for other devices Re-added config and asked alexa to find device

Device now showing under new name, sorted. May or may not relate to issues your having post update especially if the config is being regenerated HA side and no longer matching alexa side.

issue-triage-workflows[bot] commented 3 months ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

FS1961 commented 3 months ago

I got and a new echo and it works however I went a completely different way to fix what I was trying to automate.

abjwsm commented 1 month ago

I have been using this for a while now, with no issues. However I added 3 entities, Fan High Fan Medium and Fan Low. These 3 entities are not being broadcast by HA and as such are not detected by Alexa. I have looked for the config/.storage/emulated_hue.ids file with Terminal and it does not exist. Any help would be gratefully received.

Emulated Hue.

emulated_hue: type: alexa host_ip: 192.168.11.71 listen_port: 80 expose_by_default: false entities: switch.garden: name: "garden" hidden: false switch.kitchenlight_switch: name: "kitchen lights" hidden: false input_boolean.fan_medium: name: "Fan Medium" hidden: false input_boolean.fan_high: name: "Fan High" hidden: false input_boolean.alexabool: name: "trigger" hidden: false input_boolean.fan_low: name: "Fan Low" hidden: false input_boolean.lighten: name: "lighten" hidden: false input_boolean.kitchen_pause: name: "kitchen pause" hidden: false input_boolean.boost_heating: name: "Boost Heating" hidden: false input_boolean.boost_hot_water: name: "Boost Water" hidden: false