Training App - Learn how to program

Okay, first, I’m by no means an expert here, but I’ve learned how to do some things by looking at the code of other programs and from help from posters here. I’ve like to give back a little and I’d encourage anyone else to do this as well. What I did with my latest program was to document the heck out of it. I commented on virtually every line in the program to explain what each line does and why. If you have any programs where you’ve done massive documentation to help others, please post them here.

My program is called Nightlight.

Here are some apps I’ve coded. You’re free to take a look at them.

Cheers

Where is the code?

It’s available with the shared apps if you go into the IDE and start a new app you can browse shared apps and find it there.

If you’re never built an app or are unfamiliar with the process, here’s a quick getting started document I wrote:

Just finished my second “Extreme Documentation” effort. It’s called Wireless 3-way. A very simply little program that I’ve found very useful. I have a “dead” switch in my house that did nothing (it was wired up to control lights in an odd place to I re-wired a switch close to that setup a long time ago and this became a dead switch that did nothing.

Recently I installed a on/off switch here where the load isn’t hooked up to anything. The just line and neutral are running to it. The switch turns on and off, but it doesn’t turn anything else on or off. Except, now it does. With this program is binds this switch with a switch by by back door that turns on an outside light. It makes is a wireless three-way. :slight_smile:

Quick question about your Dropcam Motion Capture app @speteor. I’m assuming this requires both a Motion Sensor and a Dropcam. Is there any way to have the Dropcam itself detect motion and take a picture?

@csader - Our current dropcam functionality is based around taking pictures. I’m not sure if it currently registers a motion capability, or if it would even be effective, given that our motion sensors communicate through z-wave (very little lag) and Dropcam is going through dropcam --> API --> SmartThings (a lot of potential for lag)

So what should I expect out of the simulator with the wireless 3-way demo program? I’m trying to build a SmartApp that will change modes (from Home to Night, and vice-versa) when an upstairs switch is flipped. This gets to the rearing-its-head-again smart-button discussion. It’s the same concept as the wireless 3-way but a different action. I haven’t bought or installed the physical switch yet but wanted to make sure this would work first.

When I run the simulation my console just remains empty - no messages at all. I even tried just copying the exact wireless 3-way program and still nothing. Also, when installing the demo program and choosing multiple switches, I would expect turning a switch on and hitting play would turn the other on, but nothing happens. And yes, I made sure the console screen was expanded…

Does anyone else see this behavior in the simulator?

@chrisb

That’s how I’ve learned what I’ve learned programming-wise also so I’m glad to see I’m not the only one here.

I’ve been struggling a bit getting the device types working. I’m trying to get create a ThingShield device type going to control a couple relays, operate an LED strip light (coupled with the strobe command) and a piezo speaker (coupled with the siren command), and eventually read a couple sensors. As this is a big undertaking, I am taking it one piece at a time. I’ve already written Arduino code that should do the job, but I’m struggling to do anything with the device types except the basic switch.

Does anyone have any example device code for the thingshield they’d be willing to share? Or, could someone break done what all is happening in the parse section of the code? I think that’s where my version is breaking.

Code is here.

@tcn : The lack of documentation on how to create new device types, and in particular, device types for the Arduino shield, is the #1 reason I had to stop my experimentation with SmartThings. They need to provide detailed examples and documentation on what the code in the example device types does and why. Otherwise, we’re just doing trial and error, mostly error.

Sadly, I must agree. I’m not making much headway and have begun looking for easier options. Sorry, but SmartThings were designed originally to make things easier and I haven’t found that option yet. Maybe one day…hopefully! Sorli…

I am still very hopeful. Maybe I am just more patient, I don’t know. But the SmartThings company doesn’t even have one year of experience being open to the public yet and look at what we can do now. Imagine a few years in to it when more and more developers sink their skills in to this. That very reason is why I chose this route to go instead of one of the already existing companies. I like the possibilities of the open platform.

Oh sure, there is no GUI interface for point and click drag and drop programing, at least not now… but because of the open platform who is to say there wont be? To me the potential is wide open. And I mean wide open.

I equate this to the Google Android operating system, also open platform. A lot of people will buy the phone as is and are happy. Some of us will root the phone, and write/install custom ROMs. It may not be for everybody but its there if you want it. And I can speak first hand that a lot of the custom ROMs for the Android phones blow the socks off the stock stuff you get in the store.

Lets have this conversation again in a couple of years and see what we have to say then.

Good to hear someone is hopeful and yes I’m also and just a little stifled by my lack of understanding and progress with ST. I’m sure things will come around and yes an GUI interface would be helpful for those like me who simply don’t know enough. Either way, SmartThings…keep up the great work and I’m sure it will come together. Sorli…

I’m hopeful too… I already wrote the Arduino code and built the physical device; I’m just not successfully passing commands between the Arduino and the ThingShield. If anyone has some example code of custom device types based on the ThingShield they’d be willing to share, I’d be very grateful!

I have continued working on the device types and have the switch, push, and alarm capabilities working to various degrees. I’m going to keep cleaning up my code then I’ll share if there is interest.

Oh yes, I’m interested and would love to see what you’ve accomplished. Actually, between your breadboard efforts and similar work others have accomplished with interfacing with hardware I would never have tried (Foscam IPcam)…all of your efforts are getting me back into the grove and excited. Thanks for the help! Sorli…

@sorli

I’m glad to hear it. I’ll make a Build project for my new endeavor and post when it’s ready. I have a long ways to go until it’s done. I’m calling it SmartKitchen because it is designed to connect a bunch of things in my kitchen to ST at a relatively low cost. Jokingly, I could describe it as an attempt to use every single pin on the Arduino!

The main unit is composed of:
Arduino Uno
ThingShield
ProtoShield and full-size breadboard (to be replaced with a custom shield I am designing in Fritzing).
16 channel relay board
3 channel remote control AC relay remote
Fan/light remote control
Garage door opener
2 595 Shift Registers

When it’s done, it will monitor/control these devices:
3 AC Power Relays (similar to SmartPower)
RGB LED strip mounted under cabinets (colors based on events and time of day, strobe in response to alarms)
3 ceiling fans with lights
Open/close garage door
Piezo speaker for audible alarm
Wired motion sensor
Wired contact sensor on exterior door
Infrared sensor for taking commands from remote control
Temperature sensor
Light sensor
Moisture sensor

Here is the Device Type code. Here is the Arduino code. These are both a bit rough still and only control a fraction of the final product.

The project is up here. Let me know what you think.

@Chris Cooney

I’ve been having the exact same problem with my console on one of my computers. When I try to simulate the app the console remains blank and the virtual devices dont respond to any of the state changing. I’m wondering if this is a plug in issue? port blocking etc.

@ChrisCooney