Where to start with Developing


(George) #1

Hi,

I am new to Smartthings and programming in general, if I was to learn a language that would be most beneficial to me would it be Java? I need to understand the basics of programming with Smartthings being the core of my programming use. I have been a Network Engineer (CCNA, CCNP) so I have some configuration experience so I am not completely un-technical (if that helps).

Thanks in advance


(Chuckles) #2

If programming smartapps (and/or device types) for SmartThings is your primary goal, then the language you need to learn is Groovy.

http://docs.smartthings.com/en/latest/introduction/groovy-the-smartthings-programming-language.html

Unfortunately, Groovy is nowhere near as widespread as many other languages, so documentation or tutorials written for newcomers to programming is nigh on non-existent for Groovy.

The good news, however, is that Groovy is built upon Java, so knowing the fundamentals of Java is a very good starting point.

Certainly learn the fundamentals of Java. There is lots of material out there specifically targetting novices which will allow you to learn the fundamentals of types, variables, arrays, strings, loops, conditionals, functions, parameters, classes, variable scope, etc., all of which will stand you in very good stead for the future.

Java is a big topic; whilst it is a useful tool to have in your belt, as a beginner it may be difficult for you to know which parts are relevant and which are not. The semantic differences between Groovy and Java may also trip you up occasionally if you’re trying to understand some SmartApps whilst also learning Java.

If you can learn the fundamental elements I listed above, such that you understand the concepts and are comfortable explaining them to somebody else, that would be an excellent start. This would then allow you to:

  1. Read existing SmartApps, make changes to them and have those changes
    do as you expect, or work out why they don’t.

  2. Ask informed questions of the more practiced here on the forums and
    understand the explanations which come back.

As you’re learning, don’t get too hung up on object oriented programming, inheritance or polymorphism for now. All quite useful techniques, but not that relevant when coming to grips with SmartApps.

The topic of standard Java libraries is also very large. Again, don’t get hung up on trying to learn them all - simply learn what they are, how you find their documentation and how you can access their functionality. You should pick this up as part of any course on Java programming - you shouldn’t need to specifically go out looking for it.

Anything about design patterns you should skip for now, along with Java EE, beans, etc.


(George) #3

Hi Chuckles,

Thanks so much for your in-depth reply! That really helps, I am at a crossroads with the ST eco-system as I live in the UK and I have just realised that Z-Wave will not work here (well it will but I would have to buy US based freq. devices which could be potentially interfered with here). This is a real shame as I thought the ST portfolio was going to be my way forward.

I am looking at Fibaro now but that doesn’t seem to have Zigbee support. Thanks again for your time and help.


(Chuckles) #4

I don’t know for sure, but recent posts on the SmartThings Dev twitter feed would seem to suggest that SmartThings may be officially coming to the UK sooner rather than later.

https://twitter.com/SmartThingsDev

I’ve not yet watched the UK Dev chat; there may well be more info in there.

There was a second UK Dev chat on 10/6 but it doesn’t appear to have been posted yet.


(Nora Hacker) #5

Hi, I would also like to start developing for the SmartThings community, after only using ST for a year now. I do have some developing experience (ksh, Perl) but I do not really know where to begin here.

I would like to merge @Dianoga’s “Whole House Fan” with “Keep me cozy II” but instead of the whole house fan I would like to run the A/C fan. If the temperature on the second level of my house reaches a certain point and the temp on the first floor is at least 2 degrees lower, turn on the A/C fan to mix the air. I would also like to implement the same functionality for humidity (if the humidity on the 2nd floor is higher than 65%, then circulate the air).

I’ve already looked at the code for both smart apps and the Nest device type (I have a Nest thermostat) but I couldn’t really figure out the commands and parameters I will need to use/pass. Is there a list somewhere?

And on a side note, I am totally unsure as to if or how I may use the source code from a legal point of view (copyright etc.)…

Thanks for any help, I really appreciate it.

Nora


(Brian Steere) #6

@campanella

Device types list their available commands and attributes in the metadata section (usually at the top). Many of them also reference capabilities which is a set of predefined commands/attributes. Here is the list of those.

To turn on the HVAC fan, you would use thermostatDevice.fanOn() (replace thermostatDevice with whatever name you chose in preferences.

To check temperature: temperatureDevice.currentTemperature
To check humidity: humidityDevice.currentHumidity

As far as using code goes, most SmartApps are under the Apache License (Version 2). You can read up on the specifics, but it’s pretty permissive.