Newbie: write simple program that reads device temp, then raises tstat temp

Not sure what category to post this under, but here goes…

I have a temperature probe configured and working fine in ST. I also have a wifi thermostat working in ST. This temp probe is monitoring the suction line of my AC condenser. Sometimes, after AC runs several hours, the suction line temp will start dropping towards freezing. I want to write a simple piece of code that would only run if tstat is in cooling mode - and would check if probe temp falls below some threshold temp (maybe 40). If probe temp does drop to this threshold, then it would raise the tstat temp a degree or two higher than the current room temp (from tstat). That would effectively turn off the AC and give system enough time to warm up, avoiding a freeze up…

Can anyone point me to some docs and samples that would point me in the right direction?

As far as my HVAC problem, I will eventually diagnose and fix whatever is causing the freeze up. But for now, this seems like a convenient workaround - as well as a great way to learn more about programmatically interacting with my ST devices…

TIA,
-Mike

The SmartThings platform isn’t really designed for “programmatically interacting“. Most people will only use the built-in rules engine in the SmartThings app, which is very simple, or use one of several third-party options. The most popular is probably the third-party app, SharpTools, which has a really nice visual interface, but probably isn’t what you’re looking for either.

But if you want to really do your own programming, the official assumption is that you know how to write programs and you’re going to write in whatever language you want to write in and then you will subscribe to events on your SmartThings account and send requests using the regular published REST API. so those are called “endpoint Smartapps“ because they are connecting to endpoint in the SmartThings cloud.

That works OK, but it’s not really well documented, and it’s fairly fragile because it’s going through the cloud. It just hasn’t been very popular.

The main thing to understand is that we as customers are not allowed to run custom code on our own SmartThings hub, and there is no longer a free cloud service provided to customers like there was before 2023. So if you want to do your own programming, You have to also do your own hosting, either in a cloud or on your own server box. It’s not what most people are expecting if they come into SmartThings with a programming background, but it is what it is. The platform just isn’t designed to let you do your own programming within the confines of that platform.

Instead, most people with a strong programming background communicate either through MQTT (in which case it’s like any other MQTT project) or something like node red using a local server, they set up themselves.

I’m going to take a leap here and guess that you might be happiest with a node red set up. So here’s a project report from one community member on what they did. Take a look at that and see if it would be of interest.

Unleash the Power of SmartThings with Advanced Automations Using Node-Red

If you’d rather go to the MQTT route, here’s the discussion on that:

Integration Solutions using MQTT

Or you can write your own endpoint app anywhere you want to, host it yourself, and connect through the rest API.

Here’s the documentation on that, but it’s incomplete and some parts may be out of date. Like I said, it’s just not a very popular approach these days. :man_shrugging:t2:

1 Like

Thanks JD for all the good info!

I am quite surprised, and disappointed, that it’s not a trivial task to write some simple code under ST :frowning:

Before I delve into some of the options you kindly provided, I am going to post this same question to Hubitat - as I do have a Hubitat system at my other home. If this programming task is something that Hubitat can easily handle, I’ll replace my ST with Hubitat…

It just seems so counterintuitive that simple programming cannot be done within ST. Like some sort of “block” programming where you drag code elements…

Thanks again!!

2 Likes

The hubitat architecture Has a lot of similarities to the original pre-2023 SmartThings architecture and you can, indeed, write your own code there although it will be in groovy script, it’s not a matter of dragging code blocks around.

If you want to drag code blocks around, look into node red At the “automation box“ link I gave you in my previous post.

But again, you will have to set up your own server device to make that work.

IMG_9221

Thanks again! I think I’ll check out Hubitat and Groovy script. If I remember correctly, much of Hubitat is totally local (no cloud), so hopefully I’d just have to learn Groovy (no server) :thinking:

1 Like

Yes, that’s correct. Groovy Smartapps in the hubitat platform run on the hubitat hub.

1 Like