Well, either way you’re going to have to learn how to do something. Either you have to learn how to write a Python program that accepts and uses command line arguments which you will have to find on some other website, or you will have to learn how to use the tools openHAB provides.
To be successful at this sort of low level stuff you have to have at least a little bit of understanding of how the technology you are using works. In this case a REST API and HTTP calls. It would be worth while looking for some tutorials and basic information on this before continuing. Just copying and pasting stuff from forums and the web without understanding how they work means you’ll be helpless when things don’t work as expected.
Beyond that, you have everything you need to make the HTTP request defined and clear in your Python script. You know the url, the payload, the headers, and the type of request.
Looking at the docs for the HTTP Binding we see places to enter:
baseURL: the URL that will be called when the Thing is triggered
password: the authentication credentials
commandMethod: you’ll use “POST” to indicate when the command channel is triggered with a command it will issue the POST to the configured URL
encoding: you’ll use “text/plain”
stateContent : you’ll use the “payload” contents from your Python script.
So you have all the information you need. You’ll create a new HTTP Thing and fill in all this information. Then you’ll have to create the Items and link them to the proper channels.
I don’t use this binding so read on in the binding docs and the many examples here on the forum for more details.
Or you can use
[sendHttpPostRequest](https://www.openhab.org/docs/configuration/actions.html#http-actions) which takes as arguments:
url: the URL from your python script
contentType: the Content-Type from your python script
content: the payload from your python script
headers: a Map (search the forum for “createHashMap” for hundreds of examples) containing one entry with “Authorization” as the key and the “Bearer …” as the value
timeout: how long to wait for the request to complete before declaring it an error.
You’ve only got the one URL. You put it in the field/argument named “url”.
As shown above, the HTTP binding has a username and password field. The rule action does it exactly the same way as your Python script.
You mean the payload? In the binding it’s called the “stateContent” and in the rule action it’s called the “content”.
I don’t use this binding but I strongly suspect that you have a Switch Item that when you send an ON command to it it will cause the binding to make the POST request. If not that, then you’ll have an Item linked to the stateContent and you’ll sendCommand the “payload” to that Item to trigger the POST request.
As with all Things in openHAB, you cause something to happen by sending a command to an Item linked to the Channel that causing something to happen.