Need help finding hue bridge discovery example

I am trying to learn to code a hue app for hubitat. Does anyone have an example of code I can learn from for hue bridge discovery? I’ve interfaced with the hue api already, I just don’t understand how to code this.

1 Like

Among the two options there, UPnP or mDNS, I think only UPnP will work on Hubitat at the moment. To do that, the basics are needing to send the request:

sendHubCommand(
  new hubitat.device.HubAction(
    "lan discovery ssdpTerm.urn:schemas-upnp-org:device:basic:1",
    hubitat.device.Protocol.LAN
  )
)

then subscribe to the event:

subscribe(location, "ssdpTerm.urn:schemas-upnp-org:device:basic:1", "ssdpHandler")

and then code the handler method you specified:

void ssdpHandler(evt) {
   log.trace parseLanMessage(evt?.description)
}

That being said, I'm not sure what your goals are, but there are at least three open-source Hue Bridge API integrations for Hubitat, two of which are currently maintained, that I know of; and one of which is mine, GitHub - HubitatCommunity/CoCoHue: Open-source community-created Hue Bridge integration for Hubitat. So if you're looking to write your own, maybe see if something else meets your needs first. :slight_smile: I'm not sure about any others, but mine is also open source, subject to the license under which it is released, if you want to look at any specific examples.

1 Like

Thank you! I’m currently using Advanced hue bridge integration because I want to leave my hue motion devices connected to my hue bridge but use the sensors for certain events in hubitat. The only thing it’s missing is the ability to disable the hue motion sensor. There is an API that allows you you to disable a hue motion sensor I want to use.

Does the one you’ve linked use that API at all?

5.8. Change Sensor Config Api

No, though I do see that in the new v2 API (not sure if it's in v1; I don't plan on doing additional work with that), so it's possible it could be added at some point. Hubitat also lets you enable/disable devices via Rule Machine, which isn't exactly the same in that it won't stop events on the Hue side, just stop them from being generated on Hubitat, but that may also work for your particular needs.

It doesn’t suit my needs perfectly. See, I really want to leave all of my lighting automation in the hue app. My wife likes it better because she loves the hue app and can change things as she wants. ( I’ve tried to get her to use the hubitat rule engine, but she’s a graphical user type of Gal. )
The problem for me is I have some switches and buttons in hubitat I want to use to turn the motion sensors off.

There is a v1 api for this feature as well.

Rather than writing an entire integration, you might find it easier just to make an HTTP call to the Bridge to enable/disable the sensor--then keep using whatever integration you want. But this would certainly be possible to add to mine at some point. I'm not sure what the status is of any others, of course...

Yeah. I had a switch that does this, but it requires you to know how to get an API key from the hue bridge. I was hoping to make the app that was easier for others to use. There may be others that would find use in it.

I'll look into this at some point for mine.

For the API key, you can cheat and re-use one from the App Status page of an existing integration--all I'm aware of store one there, and it should be apparent. :slight_smile: (I know, I know, each app should technically have its own...but at least it's all on this hub? Ha.)

OMG! I never thought of telling people to do that. LOL
I just didn’t want to have to document how to get an API key

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.