How do I connect my own thing? (SNMP)


(Boris) #1

Hi,

I have a built a Thing that i’d like to connect to your plateform. The Thing detects events and attributes sent are class of event detected, time and IP adresse of the Thing.

My thing is connected with ethernet cable and sends SNMP traps on the network. What would be the best way to connect (direct ethernet? or by adding The SmartThings ThingModule to my motherboard?) and to notify alarms to the smartthings plateform? I guess SNMP is nor supported so what protocol(s) could I implement?

thanks

best

boris


(Smart Things) #2

@Boris - Awesome! We are rolling out a set of developer tools soon that will walk you through these questions and more. Stay tuned for updates and be sure to join the Contest Series group. Thanks.

Cheers,

The SmartThings Team


(Nick Looper) #3

Sorry for the reply to an old thread, but I wondered what progress there has been on the SNMP front. I have various APC / Schneider Electric devices which provide temp and humidity readings and the status of closed or open relays. Any way to talk to these with ST?


(Matthew) #4

Did you ever find a solution? I’m surprised I haven’t found more info/an easy way to read SNMP into smartthngs (some sort of virtual device.) I’m wondering if I’m missing something basic.


(Isaac) #5

Any progress on the SNMP front?


(Joel T) #6

There is no easy way. If you can run an agent on a local server/raspberry pi/etc. you have a chance. I wrote an SNMP->REST agent that runs on a Beaglebone to collect SNMP information from a small UPS and send it to a custom application and device type in SmartThings. If you are savvy with Python and Groovy, I can point you to the code, but I’m sure you will need to make significant adjustments for your application…


(Isaac) #7

Please share what you have. I know just enough Python to be dangerous and was thinking of doing the same.


(Joel T) #8

It’s on github, here: https://github.com/joeltamkin/smartthings-ups

It’s been a couple of years since I touched it, and I’m sure there are some issues. I may be able to help if you have questions. I don’t code for a living!

Where to start:

The python code needs to run on something on your LAN can that access the SNMP device. Comms are one-way, from your LAN to Smartthings. I never completed mechanisms to go the other way, so this is strictly monitoring.

snmp_json.py is the entry point for the agent.

devicedefs.py will need to be extended to define your SNMP device type. There are some tricks in there for dealing with dynamic tables and other SNMP-isms you may encounter. Also includes the ability to define helper/conversion functions because SNMP uses pretty arcane methods for encoding data sometimes.

-The key here is that the names defined will end up matching the names of data defined in your smartthings Groovy device code

you will need to edit the “devices.py” file. This is essentially the configuration of SNMP devices to be monitored, and references device types you defined in devicedefs.py

Unless you make changes to snmp_json.py, you will also need to create a “constants.py” file defining some variables:

STBASEURL = 'https://graph.api.smartthings.com/api/smartapps/installations
STAPPGUID = '12345678-xxxx-xxxx-xxxx-xxxxxxxxxxxx’
STAPPTOKEN = ‘12341234-xxxx-xxxx-xxxx-xxxxxxxxxxxx’

DEFAULTPOLLDELAY = 30
DEFAULTALARMPOLLDELAY = 5

STBASEURL, STAPPGUID, STAPPTOKEN (you get these after creating the REST end point in smartthings by copying in the smart app code…there is a tutorial on this elsewhere in the forums. I think they changed the base url too…)

DEFAULTPOLLDELAY, DEFAULTALARMPOLLDELAY - these are the amount of time, in seconds, to wait between polls of the SNMP device for new data. When a point defined as an alarm is detected in the alarm state, you can speed up the polling to more aggressively collect data.

You will need to get the pysnmp package as well.

On the Smartthings side, there is a smartapp and a UPS device. The smartapp should work as-is, but you will need to modify the device code to match the attributes provided by your snmp-capable device.

Good luck, and let me know if you would like to contribute updates and additions.