Smartapp Updating (simulated) Device Parameters


I have an Accurite Weather station which is not supported by ST, IFTTT. In fact only one of the many sensors can be sent to Weather Underground and then only once every 15 minutes. The good news is that getting all the data from each sensor is not a difficult task (using Python) nor is it a dificult task passing the same to a ST Smartapp… What I would like to do with this is create a “device” I’ll call “Backyard Weather”. then via this Smartapp update the “device” parameters such as Sensor 1-Temperature, Sensor 1-RH, Sensor 2-Temp, etc…Is this possible and if so, where do I begin

(Tim Slagle) #2

Hey man, this is totally possible.

You’ll need to create a “child device” as part of the app then you can send data to and from the smartapp to the DTH.

First you’l’ need to create the child device:

Then once you create the child device you can send data to the device. Like the data you get back from the API to a method and parse/generate events from that data.

It would work something like this

Service Manager code:

def child = getChildDeviceByName([name of device you create here])
child.generateEvent([event data])

DTH Code:

def generateEvent(Map results) {
  results.each { name, value ->
    sendEvent(name: name, value: value)
  return null

The docs do a pretty good job of describing this process. I’d recommend you start there :slightly_smiling:


You lost me right here:blush: What Device type? Do I just pick one and modify it or do I actually have to write an entire new handler?? My goal is to develop an Weather device similar to existing WX devices already in ST which use the Device Type SmartWeather Station Tile except my device will display data I provide.

(Tim Slagle) #4

You’ll need to write a new handler. Or modify the existing one to accept events from the SA.


Woooohooo. Actually got a working skeleton :slight_smile:
Getting Accurite weather data to the Smartapp and subsequently to the child device seems pretty straightforward. To avoid making duplicate devices how can I test if the child already exists before I attempt the Addchilddevice call?


Could not get this to work. Appears as if the getChildDeviceByName no longer exists. Ended up using getChildDevice(DevID)

(Tim Slagle) #7

Nice!!! Glad you got something working :slight_smile:

getChildDeviceByName() should work. I use it in an app of mine currently.

Unless you didn’t give the device a name when it was created. Then it doesn’t have a name :slightly_smiling:

(Tim Slagle) #8

Also for testing you can do this…

def devices = getChildDevices()

This will return a list of devices that you can check against.

This is where getChildDeviceByName comes in handy


Oh I had a name alright. I search the docs for this function and it came up blank. Anyway/… getChildDevice(DevID) works fine :slightly_smiling:


Pretty sure there is no getChildAppByName but there is findChildAppByName :grinning:

(Tim Slagle) #11

doh, yeah you’re right. I should RTFM more often. :sweat: