4 HTTP (does not work in v18 Leia)
To add new content to the library (Update):
http://<User>:<Password>@<hostname>:<port>/jsonrpc?request={"jsonrpc":"2.0","method":"VideoLibrary.Scan"}
I have entered it into my browser it does update my kodi libary how do i get openhab too send the request ?
Configure a Switch Item with the HTTP binding configured to issue a GET to that URL on an ON command. See the HTTP binding for details.
Or you can use the sendHttpGetRequest from a Rule. Since it is a GET instead of a PUT or a POST with a required body, this is pretty easy.
However, because the request contains { and : you may need to escape or even double escape those special characters. E.g.: request=\\{"jsonrpc"\\:... which is double escaping the characters. Without the escapes the HTTP binding config parser will treat those special characters as part of the config instead of as part of the binding.
Thanks rich I’m not sure I fully understand that but I will give it a try
Quick question it says that updating the libary using http will not be supported after v18 and that’s the next stable release should I just look at using one of the other methods they said
I would. They are definitely saying it won’t work after that point so I wouldn’t waist your time. I don’t use Kodi so I couldn’t tell which of their other approaches are reasonable. But I can say using curl is just making HTTP calls so that won’t be an option.
Maby standard HTTP is no longer supported because the user and password are before the host name of the kodi machine I read that this is pretty much a dead thing in the http world and maby the team have stopped this from working but using a command line curl is still possible?
If I understood how this would work better I would post on the kodi Fourom
I read that to mean in version 18 the HTTP interface will no longer work. The following two examples ARE HTTP so it is telling you that these two examples will no longer work when you get to v18.
Nope. There is no difference (from Kodi’s perspective) between a browser or curl hitting that URL. It’s all an HTTP GET call and both have the user and password as part of the URL (it’s called Basic Auth).
Please follow the last link in the HOW-TO: JSON-RPC API. Kodi supports two different interfaces. A HTTP API and the newer JSON-RPC API. First one will be deprecated in v18. Second one is a HTTP- and/or raw TCP socket-based interface. Meaning curl request are possible but with a different syntax than before. If you read carefully through the examples you can see the difference.
Using HTTP Basic Authentication is IMHO a bad idea. But using curl should be the way to go. Please try something like this:
I also agree with this and don’t like it myself as credentials are sent over an unencrypted connection and could easily be stolen, I’m also not much for the way kodi internally stores credentials in a plain text file called passwords it’s pretty studid
Thanks for the clarification on that
I will have a look into using a curl request but this is the first time I have tried this so…
@cweitkamp sending that from openhabian command line worked perfectly thanks for that
can you point me in the right direction for how too add that into a rule so it can be triggered by a switch as i don’t want too type it into the command line everytime i want too run it
do i need too create a script and have openhab run that ?
or use the exec binding
I ran the commands you recomended it says this opperation is not permitted i stored the kodi script in /home/openhabian/kodi_rescan.sh not in the scripts folder
[15:39:29] openhabian@openHABianPi:~$ chown openhab kodi_rescan.sh
chown: changing ownership of 'kodi_rescan.sh': Operation not permitted
[15:45:27] openhabian@openHABianPi:~$ chmod +x kodi_rescan.sh
Moving the script too the scripts folder and running the first command returns error
chown: cannot access 'kodi_rescan.sh': No such file or directory
As @rlkoshak already mentioned, use “sudo”. “sudo” is nothing more than executing another command with elevated permissions. It’s exactly the same as “Run as Administrator” in the windows environment.