I would like to use data from outside of the SmartThings world to trigger things to happen, or run routines and change modes.
My specific example is that I have an entirely off-grid home, and I have built an extensive energy logging system that tracks and logs a lot of parameters in order to draw a lot of pretty graphs and charts.
I want certain things to happen only when we’re having a sunny day, or only after my batteries are fully charged. I want actions to take place based on both 1) triggers or set points in my power system and 2) persistent state information about the power system. Examples as such:
When I have more solar power available then he current loads in the house
When the batteries are fully charged
When it’s sunny
When the generator is running (or not running).
I’ve been reading the developer documentation some, but to be honest i’m not a real full-time programmer, i just play one on TV. I seem to have some options. Here are the questions I have:
Do I need to make a device type which simulates a sensor to publish this data into the system?
Can I do it all with a single SmartApp?
Can I have my outside logging reach out and publish an event to the SmartApp to trigger things to happen?
Or do I need to have the SmartApp/DeviceType poll the outside data source on some sort of schedule?
Can I have persistent state stored somewhere for other actions to refer to?
I think that covers it for now. It’s really about the fact that I don’t really understand the overall structure/framework of how these sorts of things are supposed to work in the SmartThings world.
I have full control of the data. I have both a Raspberry Pi and an Arduino which are capable of capturing the data. I’m just unsure of what to do with the data to get it into the SmartThings ecosystem and be able to act upon it.
I guess what i’m trying to say is that I don’t understand the data model and structure of how the SmartThings system works. I need a diagram or something that shows how they all interoperate so that I can see how to attack this problem. I’m not bad at programming but I think since i’m not a trained computer scientist I can’t immediately see the forest through the trees so to speak.
So I looked at that other eGauge/Enlighten project and it confirmed my idea that I need to make a Device Type to poll the data from my system. That’s great, I can do that. I see that a service manager style device type like this will poll the data every 10 min automatically, and I bet I can force it to update on-demand in the app when I try to refresh of course.
I’m curious though, how do cloud-connected smart apps handle incoming triggers? Like when i press a button on my harmony remote, what happens to cause the SmartThings hub to react instantly to turn on some lights? Does my Harmony Hub communicate directly to the SmartThings hub, or does it go through the cloud, and thus, how is it accomplished such that it takes action immediately?
If you search the board for ST_anything, you can see a project that makes it easier to make an Arduino talk to ST. There are several examples. Some of them might be close to what you are looking to do.