Send http post via Rule Machine

Trying to send the a http post via rule machine to activate the locking action on my 3rd party NUKI via their API. I am using the HTTP POST option in RM4 but not getting a response from NUKI.

What do I need to put/select in the the "Select content type" "Enter URL to send request to" and "Enter body for POST" sections to make this work.....

If I enter the following in my browser everything works fine.....

http://192.XXX.178.XX:8080/lock?nukiId=XXXXXX&deviceType=X&token=XXXXXX

Thanks,

Marcus

If you can enter the url in a browser and have it work then it is an http get not a post.

Andy

1 Like

Wow... thanks @Cobra

I'm in Germany so woke up to your message and of course it worked like a charm, although it doesn't make sense to me that I have to use a get and not a post when I am sending out a request but that's why I am a used and not a programmer I guess :slight_smile:

Anyway thanks for you quick response and aid!

Maybe you can help me with with my next related issue...

GOAL: After the lock has been opened/closed (out of Hubitat) using the get http command I would like to update the status of the virtual lock that I have created on the HA Dashboard to mirror the current status of the lock as reported via the NUKI API. I get the status of my lock via sending a the http command to the NUKI server that responded with the following json information

{"mode": 2, "state": 1, "stateName": "locked", "batteryCritical": false, "success": true}

MY IDEA: 1. Create a global variable (string) called Door Status (done that) 2. Write a RM rule that sends and received the above json information and then writes it in the global variable "Door Status" (can't figure out that part) 3. Write another rule that... IF the word "locked" is found in the variable "Door Status" sets the Virtual Lock to Locked and if word "unlocked" is found in the variable "Door Status" sets the Virtual Lock to Unlocked (that I could also figure out)

Any ideas how to accomplish Part 2? I tried a Rule using Set Variable "Door Status", Sting operation "Set from Get operation response" and entered the url in section "Enter URL to send request for response" Do not see any information in the variable "Door Status" Is this possible because it is being received in json format and not as plain text?

Any help would be highly appreciated!

Marcus

Marcus
I'm not sure that this is achievable in RM as the response is in JSON format
I don't have RM installed so am not that familiar with it.

It would be reasonably easy to do it in Groovy with a driver or app

@bravenel
Bruce, can RM parse the json response?

Andy

Do you have a link to the NUKI api ?

Thanks Andy,

I just found a different thread where the issue was the json and not plain text return. So I am assuming that RM is not a solution.

"It would be reasonably easy to do it in Groovy with a driver or app" LOL... Way beyond my capabilities.

This is a real shame because there are many Europeans here in the community with difficulties due to lack of locks that are supported and usable on EU doors and quite a few with NUKI locks. If someone could write a driver that would support the NUKI api all the user would have got do if enter the IP address and the token and he would have NUKI fully integrated into HA.

Marcus

https://developer.nuki.io/page/nuki-bridge-http-api-1-10/4

Lots of information here too, looks like they have a web.api too but for what we need I think the bridge http api is the way to go...

Do you have the bridge or just a lock?

I've been reading this a little and it seems the locks report their status to the bridge every time something changes.
If you poll the locks directly too often it will flatten the battery but you can probably poll the bridge for lock status and of course the bridge is mains powered

It looks like the bridge may even be able to 'tell' hubitat (via oauth) that something has changed.

I have both.... yeah I read that too.....

I can already open and close the lock with the /lock or /unlock commands from Hubitat. What I need is for have the door status be updated in HA when the door is opened or closed from outside Hubitat....

Much easier said than done! :slight_smile:

You would need an app with an endpoint, then a virtual device to send everything to.

Not the solution you're looking for, but I've done it using IFTTT.
A virtual lock on Hubitat (showing on dashboard) is being (un)locked when anyone (un)locks the Nuki.

I'm also locking my door via IFTTT because I couldn't get the API to work, but I will try this again, now that I've read this tread.

You lost me at endpoint :slight_smile:

Seriously all I need is to be able to read out the JSON response when I call the NUKI BRIDGE HTTP API ({"mode": 2, "state": 1, "stateName": "locked", "batteryCritical": false, "success": true} into a variable and them look for "unlocked" or "locked" in that variable within Hubitat.... Looks like I was close but Hubitat can only receive plain text and not JSON...

I have been using IFTTT to communicate with NUKI too. Works OK but not too reliable. I prefer to avoid IFTTT whenever possible.

I can help you with the implementation locking and unlocking of the NUKI Door Lock out of Hubitat if needed that part is pretty easy if you look look at the documentation the NUKI Bridge HTTP API (link posted above) You will need the NUKI bridge of course to implement this

Marcus

I'm reading MAKER API can do that, but that sounds like another beast to get to grips with

I forgot about Maker api
Yep, you might be able to do it with that. (it's basically an endpoint anyway)

Easiest way to try Maker api is create a virtual switch and have a play sending commands to that
Once you have done it a couple of times it's quite easy to work with

Installed a virtual switch and Maker API but I have no understanding of what I can or have to do in there to send a http command or force and answer from NUKI...

Okay, so I've tried locking and unlocking the door from Hubitat. It works, but it's working too wel! :smiley:
When I unlock the door it opens the door completely...

My intention is only to lock the door when Mode changes to Away or Sleeping and to unlock the door when Mode changes from Away or Sleeping. Not to open the door :expressionless:

IFTTT unlocks the door without opening it... I guess I have some Googeling to do...