SmartThings plugin



  • I'm new to the site so this information may be somewhere here but I didn't see it.

    I have a SmartThings v2 hub/controller and have been pretty happy with it so far but have mostly just used it with devices I've bought. Just recently decided to use my prewired security contact sensors as part a home security project and I'm using an Arduino Mega 2560. When I realized how easy it was to build some of my own devices I ran across this site and I want to build more.

    I'm a software engineer so was wondering if there are some examples of controller plugins that others have wrote for other controller or if that are specs so that one could be built for SmartThings. Anyone have some good examples that I could look at?


  • Admin

    Hi and welcome @eframe,

    There's a really simplistic controller implementation available on github that you can have a look at here:

    https://github.com/mysensors/MySensorsSampleController

    Also, most of the supported controllers is open source projects and their respective plugin is available as open source.

    Let us know if you need more pointers to get started.



  • Maybe I didn't ask the right question or don't understand the answer or possibly both 😊. I would like to figure out how to use MySenors with SmartThings. The link, if I understand what it is, is a link to a custom controller. Isn't that what SmartThings is, a controller? How do I get the gateway to talk to SmartThings? I was thinking some sort of plugin/integration would need to be written? So I might be confused and not asking the right thing.


  • Admin

    Yes, you would have to write a SmartThings plugin which talks to a MySensors gateway either over a serial or ethernet connection. The protocol is simple and described here.

    The example "controller" I posted above is an example of how to talk to the gateway.

    I have no idea if SmartThings allows you to create/install plugins. But you need to place the code somewhere that keeps the connection to the gateway open and interprets the MySensors messages.



  • Please bare with me I'm learning here.

    So if I understand the controller example you gave me from a hardware perspective there is a RPi that is acting as the controller running Raspian/MongoDB/MySensors/NodeJS. The gateway (eithernet or serial) is a separate device, ie. an Arduino. Then you have whatever sensors themselves. Communication is: Controller to/from Gateway to/from Sensors. All communication between the controller and sensors goes through the gateway. Can the senors communicate with each other through the gateway and not go through the controller? Just trying to get my head straight on the communication path. If I'm using a controller like SmartThings where does MySensors get installed? On the gateway?

    SmartThings provides a set of REST api's for the integration. Does the gateway handle REST api calls? I'm assuming yes since the example is an ESP8266 wifi. Again, sorry if I'm asking questions that are documented already, just trying to absorb all the info.


  • Admin

    @eframe said in SmartThings plugin:

    Communication is: Controller to/from Gateway to/from Sensors.

    All communication between the controller and sensors goes through the gateway.

    Not nessesarily. But when a sensor is joining the wireless network it communicates with the gateway (per se the controller). To fetch a unique id and present itself.

    Can the senors communicate with each other through the gateway and not go through the controller?

    Yes, this is also possible. If a node addresses some other node, the gateway/controller won't see this communication. But normally a sensor sends its data to the gateway/controller to have the home automation controller log or react on it.

    Just trying to get my head straight on the communication path. If I'm using a controller like SmartThings where does MySensors get installed? On the gateway?

    The MySensors library is installed on the gateway and all the nodes. When creating the gateway you can choose to have it communicating via serial line or ethernet if your ardiono has a ethernet controller. See build pages for more examples of gateway types.

    SmartThings provides a set of REST api's for the integration. Does the gateway handle REST api calls?

    No not directly. You would probably have to create some integration software which transforms the incoming data to rest-calls. But how would you solve outgoing data (I.e. if you want to control a relay from the SmartThings controller)?. Does SmartThings allow outgoing rest-calls to a service of choice?

    The best thing would be if SmartThings had some real plugin architecture... Most controllers allow running Lua scripts or some other way of writing native plugins running on the controller itself. Really unfortunate if they lock down the box from an integration perspective. That's why I usually prefer to run open source software myself [rant warning 😉 ].



  • @hek, thanks that helps a lot. I have more questions the gateway but I'll go over to that part of the forum and research first. 🙂

    Agreed about open platforms. I want to try and integrate with what I've got so I will have to try something with the REST api. Yes, it appears SmartThings can make an outgoing API call.



  • Hi there. Just wondering did you get anywhere with the smarthings controller ? Did you get anywhere with the smarthings rest calls ECT.



  • @vasarbob I have been able to make a rest call to the SmartThings API. I was using an esp8266 as the gateway but am in the middle of moving that to an Uno with Ethernet shield. The code is a little hacky right now and I am planning on refactoring and cleaning it up a bit. Would eventually like to write a transport layer but that's going to take some time.

    I also had to write the device handler code on SmartThings. That too is a little hacky and I need to refactor that as well. I'd be happy to share and collaborate if you want.

    I was trying to get a working prototype going and learn some things about MySensors as well as SmartThings and I think I understand it well enough now to be able to put it together.


Log in to reply
 

Suggested Topics

  • 2
  • 4
  • 75
  • 6
  • 17
  • 48

1
Online

11.4k
Users

11.1k
Topics

112.7k
Posts