Getting notifications in case of an event is not really a big deal these days. Most people have smartphones and use them to get messages. There are also several ways you can have your Raspberry Pi send a message to your smartphone. This works very well via Python (Pushover / Apprise), Slack but also email. But it is also possible to send messages to Kodi using curl. If your Raspberry Pi is responsible for an automatic process and you definitely want to be informed about important things, you could also have a notification sent to you when you watch a movie, for example.
It’s really send to Kodi and therefore it doesn’t matter if you use the multimedia center on an Android box or even a Raspberry Pi via LibreELEC.
Note: All other methods that allow you to send parameters to Kodi via POST also work. Under Linux curl is very handy because in most cases it is preinstalled. As far as I know it is also preinstalled on the Raspberry Pi, more precisely Raspbian. If not this command helps:
sudo apt install curl
Now the problem is solved.
Allow remote control via HTTP – then curl works
However, there is one requirement for sending a message from your Raspberry Pi to Kodi. You must Allow remote control via HTTP in the settings. This is not difficult. The path looks like this:
Settings > Services > Control > Allow remote control over HTTP
Here a screenshot as a reference:
Tip: To create a screenshot in Kodi use the keyboard shortcut ctrl + S.
That’s all and you can now send messages from a Raspberry Pi or any other Linux distribution to the Raspberry Pi using curl. The command itself works like this (you have to change IP address and port accordingly):
curl -v -H "Accept: application/json" -H "Content-type: application/json" -d '{"id":1,"jsonrpc":"2.0","method":"GUI.ShowNotification","params":{"title":"My Title!","message":"My Message","displaytime":'"5000"'}}' http://<IP address Kodi>:<Port>/jsonrpc
But as you may have noticed in my screenshot of the settings, you can only control my Kodi installation via username and password. If you set it up that way, you have to pass both parameters to curl. The addition -u username:password does that. The command now looks like this:
curl -v -u username:password -H "Accept: application/json" -H "Content-type: application/json" -d '{"id":1,"jsonrpc":"2.0","method":"GUI.ShowNotification","params":{"title":"My Title!","message":"My Message","displaytime":'"5000"'}}' http://<IP address Kodi>:<Port>/jsonrpc
The parameters title and message are clear. They just send title and message. The displaytime shows the duration of the message on the screen in milliseconds. So in my case it would be 5 seconds. A parameter image would also be possible, as you can read in the wiki of Kodi.
The result in a movie would look like this:
Even if you don’t have your smartphone near you in the evening or set it to quiet so you’re not disturbed while watching your movie, you can have important messages sent directly to Kodi.