Device type handler intergrate with service manager

Hi, this question might be the most stupidest but I couldn’t find any explanation so I decided to ask here.

I am trying to build a cloud-connected smartThings app, hence trying to write service manager (SM) and device type handler (DH), and I already have some ideas. However, when I try to design whole things (coding) I cannot image( cannot find any method) on integrating service manager and device handler. At first I looked up for some methods that can make SM and DH a package, but seemed like it does not exist. So, again I looked up a way to import SM into DH, but, I couldn’t find any.

According to the developer’s document: Building Cloud-Connected Device Type, building a device handler. The device type handler calls on the parent (refer ex1), to get or send data or commmand.
But it never explains, where I need to define device type handler’s parent. So, if anyone can explain that to me, I will be very applicated.

Thanks in advance!!

ex1 )
def on() {
parent.on(this)
}

Children devices are being created by the service manager, within this service manager you also find a “On” command, so the device “On” calls the service manager (parent.on())…

yes, but how my app know which child device handler to use to handle the child device? which means if I have like 5 different device type handlers and 4 different service managers and If I am using one of the service manager then how can I tell the service manager which device handler to use?vice versa.
So, my point is that how they, service manager and device type handler, know who need to call on who.

the device handler will pass the device info in the call to the parent, i am doing the same but with two device types.

What i do is i call a different “On” in the parent from the different device handlers.

SM:

def D1_On()

def D2_On()

in Device handler 1 def On() { parent.D1_On() }, in 2 Def On() { parent.D2_On()}

When you create the child device, you are specifying the device that will be created. For example, in my app, BeaconThings, I have this line:

def d = addChildDevice("com.obycode", "BeaconThing", beaconId,  null, [label:beacon.name, name:"BeaconThing", completedSetup: true])

That is creating a child device with the name “BeaconThing” from the namespace “com.obycode”. Is that what you were asking?

yeah, I did it. like you said. Now when I do this on my phone, it works! but there is one problem. When I install my service manager it get/add child device and install it on my phone smartthings application, but when I hit the thing tab and go into the child device and among 3 tabs (right now, recently, smartApps) if I go into the smartApps, I don’t see that my service manager installed. How can I install it on child device?

I’m not sure how you would do that, but I’m also not clear on why you need to. You can access the service manager SmartApp from the main SmartApps tab. Could you explain a but more about what you are trying to do?

Thanks for answering this, OK, so I am trying to build a cloud connect version and I need to get data from the cloud to service manager to device handler (So, I want to show the data gathered from service manager on device handler on every poll or by requesting service manager). According to my understanding on smartThings, if I click a device under things tab and clicking smartApps tab then I thought I should see the service manager but I don’t see any installed service manager.
When I install service manage on my phone, it use “getChildDevice(“dni”)” and “addChildDevice()” to detect the a device handler that I made and install it on my phone. So, I get my device handler installed under Things and when I go into the device handler and click smartApps to see the list of my smartApps, I thought I should see my service manager under smartApps, but I couldn’t find it.

May be I am understanding the system wrong… I am not sure. I may be need more clarity on Things -> device handler -> 3 tabs.

It sounds to me like you should have no reason to access that SmartApp after it’s installed. The service manager will create the child, then can continue to communicate with the child, either by using the device returned from addDhildDevice or by finding the device using getChildDevice. This SmartApp should then handle the interactions from the cloud device and pass on the information to the child device.

oh really? Then why there is smartApps tab? I thought at least I should see service manager there??? Can you explain a bit about smartApps tab? Thanks!! you are helping me alot!! I owe you so much!!

Other SmartApps that you install for that device will show up there, when you explicitly select this device in the SmartApp’s settings. For whatever reason, the service manager SmartApp does not show up here.

So, its like IFFFT? If I want to interact my device with other device? Then how can I install it there?
OH is it like If I have it under smartApps tab (not the tab inside things->device) then I can assgin some devices. Then it shows there?

Yes, if its one of the apps that you install from the Marketplace, it will show up there.