Best practice for HTTP GET commands?

Hi, all,

I’m running a node-RED server to control my Harmony hubs. I’m actually using it mostly for controlling IR devices like fans, fake candles, etc. But I’m working on a super secret project that will in small part have a TV control screen via SharpTools.

The way node-RED works with this is, I create http endpoints for whatever Harmony command I want to send, such as http://(ip):1880/bedroomVolumeUp/

I’ve tested creating hyperlink tiles in SharpTools directly for these controls, and it works very well and quickly. My question is: is creating an individual http object PER control I want in SharpTools the most efficient way to go? Or is there some way I’m not thinking of to pass the last part of the url as a variable or something?
Like, just have one http with http;//(up):1880/() and pass it the “bedroomVolumeUp” dynamically? Through rule engine perhaps?

I just don’t want to create a ton of essentially duplicate http objects if there’s a more elegant/efficient way to do it. The thought is, if I could set up the backend once, then create a button layout with, say, variable buttons, then change the individual variable buttons in settings after the fact, that could be a little more flexible. As always, I hope I’ve made sense here and my possible use of not-exactly-perfect terminology hasn’t confused things

So, I found this topic now: How To: Call REST API from Hyperlink Tiles

… And I’m not sure how I missed it before. I’ll dive into that when I have a little more time. I’m definitely not doing this, but it looks like perhaps I should be.

That said, if there’s anything special about my use case above or anything I asked that is unanswered in that topic, I’m still all ears. I tend to want to learn everything and figure out “the best” way before I get in and just create a bunch of stuff.

Thanks!

Out of curiosity, how are the Hyperlink Tiles configured? Does it pop up a new page in order to run the command?

It’s a relatively new feature (early this year) that’s targeted toward Power Users so it isn’t something we’ve really widely marketed.

Unfortunately, browsers will block ‘Mixed Content’ requests where the main application is running on HTTPS, but the resource you are trying to call is HTTP.

I wonder if we could modify one of the existing Virtual HTTP Switch drivers to make it a bit easier for you to adjust just the ‘command’ part of the URL dynamically (eg. through SharpTools Rules).

It does, which–I apologize–I didn’t notice last night, and is obviously not ideal. My hours have been crazy lately, and basically last night, I just mind-planned my project while I waited until my kids turned in their devices at 11:30, grabbed the laptop to test, and once I created a button in SharpTools that turned on the ceiling fan, I literally closed the laptop thinking, “OK, yep, I’ll just do it all in Sharptools (bypassing Hubitat),” and went to bed. I didn’t even notice, since I was just testing a theory and not making anything that was supposed to be used or look good, that it opened a window saying “command successful”–which totally won’t work for a remote control (LOL).

Right. I read through that page a few times, because I’m exhausted and running low on (human) RAM, but it all made sense to me that the “proper” way of sending commands with SharpTools is both: (1) what I should be doing, and (2) way more complex than what I’ve tested. I’m sure there’s a way to get there from here…I have node-RED running in a container on my QNAP, so I have options.

Right. This is what I was wondering. I saw a few threads this morning in my underslept stupor that made me think maybe it’s possible, but like I said, I like to present use cases that perhaps are unique in some way, to find out if a solution for something else is a good fit, or if perhaps it’s a good new perspective to consider in development.

I’m trying to change my paradigm and consider doing “dashboard-only” things using only the dashboard, instead of using the dashboard to talk to Hubitat to tell it to do things and update the dashboard. I know in Hubitat, I could create a variable, and encode my GET request as http://(ip):1880/%myvariable%

That way, one rule can listen to the state of something and inject the right command, rather than creating a bunch of individual ones all over.

Thanks for the guidance and help. I’ll look into it more on my end when I get a little free time at home.

2 Likes

Alright, @josh, thanks for your help with this…

FYI, I got my node-RED running on HTTPS with a self-signed certificate, and my GET test tile works like a champ!

It would have been pretty easy, but I made a typo in my config file, which made my certificates be in non-existant folders in my docker container, which completely hosed the container where it wouldn’t start. Hours of fun. :expressionless: Once I got the docker cp command to work over SSH and edited/replaced the settings.js file in the dead docker, I’m good to go! Hope I never have to deal with that again, holy…

Now, if you can just consider that thing about adjusting the command part of the URL dynamically a “Feature request,” I’ll keep an eye out for any updates!

1 Like

Oof, so after all that, I went to bed and my fan wasn’t running-odd. Hit the pico remote by my bedside to turn it on… Nope.

“Oh, yeah, Hubitat is set up with http GET requests…I can fix that from my phone…”

–10 minutes later–

Hubitat can’t send GET requests to https servers with self signed certs. :neutral_face:

Guess I’m gonna learn nginx next…:expressionless: