Call DH method from another DH or SmartApp?


(Kevin) #1

Pollster still not working for me so trying to create my own SmartApp for various polling of DH poll() methods. So if I have “SmartWeather Station Tile 2.0” DH as my tile named “Weather”, do I code it:

Weather.poll()


(Tim Slagle) #2

So you’ll need to create a “input” for the device and then you can call any method on the DTH on the input.


(Kevin) #3

inputs are under the preferences, how does this relate to calling a method? Is Weather.poll() correct syntax? It doesn’t seem to execute, but it doesn’t generate any errors while saving either.


(Tim Slagle) #4

So, in a smartapp you need to tell it what you are controlling. If there aren’t any preferences the SmartApp has no idea what to do. It’s like asking someone to read a map without any streets on it.

So you need to define the input

input weather, blah, blah

then you can send commands to anything in the weather collection.

weather.poll()


(Kevin) #5

If all you’re trying to do is call the poll method of some devices, you could try other SmartApps that have this functionality rather than re-creating the wheel.

The SmartApp below was created as more of a monitoring tool, but it can also be used to poll devices at a specified interval. Another SmartApp to look at is CoRE because it can do practically anything you can imagine.

If you’re writing this SmartApp because you’re interested in programming and plan on using what you learn for other projects, then I highly recommend reviewing the SmartThings documentation.

Once you have a better understanding of how SmartApps and Device Type Handlers work, it will be a lot easier to create your own SmartApp.


(Brian) #6

Use CoRE. It does this and has some built in fail-safes. Nothing perfect, but it’s very good.