Wake On Lan - Sleep Kodi?

I have a Kodi/OpenElec front-end client that I use here in the home. And I just enable the WOL binding to wake it up, following the docs.

OH2 is running on Ubuntu, and I am able to Wake up the device fine. But I’m uncertain what the commands/syntax should like to put the Kodi/OpenElec machine back in a sleep/suspend mode. There is no Username/Password needed I think? And some searching seems to say the command should be pm-suspend?

Switch OpenElecPC "OpenElecPC" (network) { wol="192.168.11.255#48-5B-39-92-D6-09", exec=">[OFF:net rpc pm-suspend -C MESSAGE -I 192.168.11.51 -f -t 120]" }

Is it just remove

Hi Paul, i have achieved this by using the kodi JSON-RPC API and created a rule like this

if (kodi_power.state == OFF) {
    		logInfo( "FILE", "Kodi powered off")
          	sendHttpPostRequest("http://192.168.205.94:8080/jsonrpc", "application/json", '{"jsonrpc":"2.0","method":"Application.Quit","params":{}},"id":1}')

as my system will be powered off by mythtv when kodi is not running this works like a charm for me.
in your case you may probably need to use System.OnSleep method.

@Oliverk

Thanks. I gave that a try, but ended up with an HTTP error in the log. What are your running Kodi on? I wonder if running it on OpenElec requires something extra?

2017-02-19 14:23:25.811 [INFO ] [.eclipse.smarthome.model.script.FILE] - Kodi powered off
2017-02-19 14:23:25.815 [ERROR] [.smarthome.model.script.actions.HTTP] - Fatal transport error: java.util.concurrent.ExecutionException: org.eclipse.jetty.client.HttpResponseException: HTTP protocol violation: Authentication challenge without WWW-Authenticate header

I think I may have an error in the rule. The log complains this is either empty or parsed incorrectly, yet the Designer shows nothing wrong with it.

rule "Kodi Basement Power Change"

when
    Item OpenElecPC received command
then
	if (OpenElecPC.state==OFF) {
    		logInfo( "FILE", "Kodi powered off")
          	sendHttpPostRequest("http://192.168.11.51:8088/jsonrpc", "application/json", '{"jsonrpc":"2.0","method":"System.Suspend","params":{}},"id":1}')
          	}
end

i’m running kodi on fedora 25 but json rpc is also available on openelec.

make sure you have enabled JSON RPC with Allow control of Kodi via HTTP in kodi settings without username/password authentication

http://kodi.wiki/?title=JSON-RPC_API#Enabling_JSON-RPC

i would recommend to test your http post/gets on a client computer first (e.g. using Postman Chrome App) before compiling openhab rules.

Thanks,

I already had provided allow control via HTTP, but it was the username/password causing the issue.

After I removed the user/pass, the rule fires correctly and put the machine in Suspend and works nicely.