Generic driver to send HTTP POST Json requests?

Hello - I want to get my hubitat to be able to control functions of my vehicle through Hyundai's bluelink service. I found a node.js app someone created as an API for bluelink, and I've got it running on a raspberry pi. I can send HTTP Post requests containing JSON formatted data to trigger bluelink actions such as locking the doors or starting the engine.

Is there a generic driver or driver/app combination available which would let me just fill in whatever API URL and content are needed and make those available as actions for rules?

There is this HTTP Momentary Switch community driver in this thread: Harmony Hub Integration. It was technically written as a way to control Harmony, but it's really a pretty generic driver that can send send a POST (or GET or PUT) to whatever URI you want, so it should still work for this purpose.

1 Like

Athough I use @ogiewon's HTTP Momentary Switch driver indicated by @bertabcd1234 quite a bit, I think that Rule Machine is a better fit for your needs because you need to send JSON formatted data as HTTP POST requests. Maybe HTTP Momentary Switch can do that as well - I don't remember seeing the choice. [Edit: see below - I'm incorrect; it can send JSON formatted data as indicated by @stephack. That's what happens when you choose a platform with so much enthusiasm around it. I was using an out-of-date version of @ogiewon's driver].

One of the actions offered by Rule Machine is to "Send HTTP Request". The request can be sent as an HTTP GET or an HTTP POST (HTTP PUT is not supported). You can choose JSON for the content-type as indicated in the screen shot below.

33%20PM

1 Like

I learned something else. This is awesome.

Added a few weeks back to @ogiewon's driver....but RM still has more options. The best choice really depends on the use case.

2 Likes

Thanks, I had no idea Rule manager could do this. It seems that I don't even necessarily need a driver in this case!

I tried setting it up last night, but while the logs show that it did send the request, it didn't have the desired effect. I haven't had time to dig in to it yet. I'll have to check the logs on the other side to see what exactly it received from the hubitat, it probably just needs a slight change to the formatting of the request.

1 Like

Sure enough, windows (or the browser?) was entering the quotation marks as fancy quotes (distinct open and close quotes) rather than the standard straight quotes. Once I replaced those, the command works beautifully.

With this plus the addition of my new ST Arrival sensor in my vehicle, I now have a rule which triggers when the vehicle arrives home, waits 10 minutes, and sends a command to lock the car doors. My wife is notorious for not locking doors, despite having had things stolen from parked vehicles in our driveway twice in the past ~3 years. All attempts to retrain her have been unsuccessful. Now at least when the vehicle is at home, the doors will be locked.

Hmm... I know bluelink remembers where you park and has a find vehicle function, I wonder if it has an option to send a notification or email with that location when you shut the car off?

@NeighborGeek, Can you share your rule in this post or a new one that documents how you got this up and running for Blue Link? I would bet there is some interest in the community for this

@NeighborGeek, I would be interested in seeing what you have as well if you're willing to share. I just bought a new Hyundai and was curious what all could be done with Bluelink.

Sorry, I hadn't seen these comments. I had Bluelinky running on a raspberry pi, and interacted with it a few different ways. Something in my setup stopped working earlier this year, and I was in the process of buying a house and moving when I noticed it had stopped working, so I'm only now getting to work on it. I have a new hub in the new house, so I'm re-building the whole thing now.

I had a rule trigger based on a presence sensor in the vehicle. When it arrived at the house, the rule would wait 10 minutes, and if the vehicle was still present after the 10 minutes it would send an api request to bluelinky to lock the vehicle. The delay allowed for times when we sat in the car for a couple minutes before getting out, or had to carry stuff in from the car. The check for presence after 10 minutes was for the occasional case where we would return home briefly to get something and immediately leave again. No sense sending a lock command if we're back out on the road already...

I had another rule locked the vehicle when a virtual switch turned on, and the virtual switch was exposed to google and homekit.

I had a siri shortcut on my phone which, whenever the phone disconnected from carplay would wait 90 seconds and turn on the virtual switch through homekit. That covered locking the vehicle when I got out, no matter where it was. If I got out of the car at work or the grocery store and forgot to lock it myself, I had some asurance that it would be automatically locked in less than 2 minutes. If it happened to be at home and we were unloading, the lock request would fail because the vehicle doors were open, but the other rule would try after the 10 minute delay, acting as a sort of backup.

I hadn't touched the bluelinky setup on my RPi since I got everything working, so the version I had on there was quite outdated. I am working on getting the current version running now, but I have to stumble through and re-learn how to do it all again because I don't work with this stuff very often. :slight_smile:

If you need more specifics, details on how to set up bluelinky running on the Pi or configuring the rules to talk to it, I can probably share some on that once I get mine up and working again, while it's still fresh in my mind.

It would be great if one of the skilled developers in the hubitat community would consider looking at bluelinky and writing a native hubitat driver to make the api calls directly to hyundai instead. Maybe I should start a new thread asking if anyone would be willing to try taking on such a project, but in the meantime this works.