SmartThings Community

Can I create a new device and pull from a existing?


(Allan) #1

I tried searching for this but couldn’t find anything. Maybe I’m asking it wrong also. I have a couple Multi purpose sensors (motion, tilt, temp, open/close). They show up as Open/Closed in the Things listing. What I’d like to do is create a new “Thing” with only temperature and pull from the existing multi sensor. In essence I’d like the one physical thing listed twice. Reason being is I assign everything to rooms and then you could click on the room and have it say “Door Status: Open/Closed” and “Temperature: 67*” on two separate lines within the room view.

Is this possible and if so how do I go about doing it?

-Allan


#2

@vseven, yes it is very possible. I do exactly that using a virtual device and a SmartApp to update it every time the temp changes. Here’s what it looks like in the app:

The device “Temp Kitchen Area” is a virtual device that will use the average of as many temperature sensors as you like,or just 1 sensor. In my case, I have 4 sensors in the kitchen area. I also do this for the kitchen frig in the image above. I also do this for roughly 16 other temperature-capable devices. It’s easy!

Here’s how to do this:

1.) In the IDE, create a custom temperature device type using my code from here: (make sure to Save and Publish for yourself)

https://raw.githubusercontent.com/constjs/SmartThings-Devices/master/virtual_temperature_tile.device.groovy

2.) Create a virtual device in the IDE:

Name = Anything you want to categorize these types of devices.
Label = The name of the device you will see.
Device Network Id = VERY IMPORTANT. Do not use something that already exists. I came up with a unique pattern to make sure that never happens.
Type = Select the device type you created from step #1 above.
Hub = select your hub.
Group = This is now really suppose to be Room, and you can’t change anything here. Later, in the ST phone app, go to the room where you want this, and edit the room to add this to it.

When you’re all done, click on the blue Create button (not pictured)

3.) In the IDE, create a SmartApp under “My SmartApps” using my code from here: (make sure to Save and Publish for yourself)

https://raw.githubusercontent.com/constjs/SmartThings-Apps/master/virtual_temperature_tile.app.groovy

Now you have all the components needed to make this work, and it’s time to link all this together. It’s super simple, so let’s get started:

1.) Go to the “Marketplace” in the phone app, and tap on the tab that says “SmartApps”.

2.) Scroll all the way down to “+ My Apps”. Find the app you created from step #3 above in the list and tap on it.

3.) Configure the app:
Tile - Select the virtual temperature device you created in step # 2 up above.
Sensors - Pick the physical sensors you want to use, 1 or many.
(The remaining settings for the name and mode can be left empty)

4.) Click on Done! As soon as a sensor reports temperature, the virtual device will update. Until that happens, it will have no value.

A few things to note:

  • The virtual device has the correct capabilities that will allow it to be used in any SmartApp/automation/Routine.
  • You still need to add this to the Room you want via the phone app. Remember, sorting devices within a Room is still broke (on Android at least), but there is a workaround if you can get your hands on version 1.7.6 of the app.

Credit due to @notoriousbdg for developing most of the code, if not all of it.

If you need help on how to create your own device types and SmartApps, here’s a great FAQ:


Poh' Boy's Ecobee?
Android 2.1.0 - Release Notes - Commentary
(Allan) #3

I followed it and it does work although I kept getting a “Sorry, but there was an unexpected error” repeatedly while viewing the virtual tile. I had the SmartApp and the virtual tile named the same “Temp From Multipurpose Sensor 1”. I left the SmartApp named that and changed the tile to “Temp From MP Sensor 1” and the errors went away. Assuming the android app doesn’t like having different things named the same.

Thanks for posting this!

-Allan