How to implement a edge driver for bridge device in lan?

I’m trying to implementing a edge driver for a third party Hub in the same lan. The Hub connects to and manages lots of end devices with ZigBee, similar to Hue’s hub.
From all the tutorial and docs I’ve read, I can’t find the correct device pattern for it. I can see there is a Bridges device profile definition, there how shoud I make use of it? All the other samples are based on a simple on/off device.

Welcome to the SmartThings Community, @rxwen !
Can you communicate with the third-party Hub through HTTP requests? Maybe that third party lets you enable a server in the Hub to get the device’s information…

Hi Nayely,

Thanks for the help.

Yes, the third party has complete http request to expose devices’ information.
The question I’m in doubt is, after I get all the devices from the hub, how can I return the correct data model to SmartThings platform?

Based on what we’ve learned from the documentation (Writing Your First Lua Driver | SmartThings Developers), I can’t find a suitable device profile for Hub device. The sub devices of a hub is dynamic and may change at runtime. Can you propose the suitable device model?

It depends on the information they can provide, here’s the capabilities supported reference. For example, if a device detects motion and temperature, you should create a device profile that uses the capabilities:

#Device profile

name: motionSensorDevice
components:
  - id: main
    capabilities:
      - id: motionSensor
        version: 1
      - id: temperatureMeasurement
        version: 1
    categories:
      - name: MotionSensor

If you want to show certain properties that don’t match with any stock capability, you can create custom ones.

It is necessary that there’s a device profile with the device configuration (capabilities, metadata, preferences) in the driver’s package.
Then, you can make a request to get the devices connected to the Hub and create their instance using the pre-existing profiles.
If it’s useful, you can change the profile assigned to a device using the function try_update_metadata.

You can take a look at this awesome project created by another Community member:

1 Like

Sounds like a fun project. One way to go is to start with something like my virtual device driver and simply add an HTTP interface to it to communicate with your other hub and get the device states. More device types can be added if needed.

Let me know if you want to confer on how to do all this. I’d be happy to help.

2 Likes

So, conceptually, I’m assuming I can return an “array” of devices in my driver, the number of the “device array” can change based on whatever I retrieved from the hub, correct?
I’ll read the post you recommend carefully.

And is this ZigBee driver for connecting a ZB device to Smartthings hub directly, not through the manufacturer’s own hub via IP protocol?

One more question, is does the edge driver support mdns discovery and websocket protocol, and json lib?

Thanks for jumping in to offer help.
It’s indeed an interesting pattern to implement, just to be able to connect lots of other hubs that communicating with different end devices. Let me try to understand your post first.

1 Like

The number of devices is not a problem, what you might see is that you need to have a pre-existent device profile to create their configuration.
I don’t know if @TAustin has found a workaround for that, but I’ll also check with the engineering team.

Yes, it is a connection directly to a Hub that supports the ST Edge feature, in this sample, the used protocol is still Zigbee.
In your use case, your devices will be Zigbee or Z-Wave only on your other Hub, for the SmartThings platform, they will be recognized as LAN devices.

Thank you so much for your contribution @TAustin!