[Solved] Check if KODI is Online

Hi,

I want to check if KODI is online with this rule:

rule "Kodi check"
when
	Item Kodi_ARZ changed to ONLINE
then
	loginfo("kodi.rules", "Kodi ARZ is ONLINE")
end

I see this in the logs:

2018-01-07 12:34:20.583 [hingStatusInfoChangedEvent] - 'kodi:kodi:Kodi_ARZ' changed from OFFLINE to ONLINE

But the rule runs into error:

2018-01-07 12:47:29.069 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'test.rules' has errors, therefore ignoring it: [3,29]: no viable alternative at input 'OFFLINE'

[3,40]: no viable alternative at input 'ONLINE'```

Could someone give me a hint how the rules must be configured?

Regards
Michael

rule "Kodi check"
when
	Item kodi__ITEM__ changed
then
  var thingStatus_Kodi_ARZ = getThingStatusInfo("kodi:kodi:Kodi_ARZ")
    if ((thingStatus_Kodi_ARZ !== null) && (thingStatus_Kodi_ARZ.getStatus().toString() == "ONLINE")) {
	     loginfo("kodi.rules", "Kodi ARZ is ONLINE")
     }
end

Things can’t be used as trigger…

Ok,
I tried but no reaction.
what does kodi__ITEM__ means?

My items are here:

Switch Kodi_ARZ_Stop      "Stop"       { channel="kodi:kodi:Kodi_ARZ:stop"}
String Kodi_ARZ_Mediatype "Input [%s]" { channel="kodi:kodi:Kodi_ARZ:mediatype" }

Regards/GruĂź
Michael

Only a placeholder for an item you want to use as Trigger the Rule

Perhaps the Network Binding is the Better solution …

I’m on my phone but try maybe

when
    Thing your_kodi_thing changed to ONLINE
then
    // Do stuff
end
1 Like

Yes that works of course “Thing Based Trigger” … what did not work were only thing.state in the then part. My mistake :wink:

rule "Kodi check"
when
	Thing Kodi_ARZ changed to ONLINE or
	Thing Kodi_ARZ changed to OFFLINE
then
  var thingStatus_Kodi_ARZ = getThingStatusInfo("kodi:kodi:Kodi_ARZ")
    if ((thingStatus_Kodi_ARZ !== null) && (thingStatus_Kodi_ARZ.getStatus().toString() == "ONLINE")) {
	    	loginfo("kodi.rules", "Kodi ARZ is ONLINE")
     } else {
     		loginfo("kodi.rules", "Kodi ARZ is OFFLINE")
     }
end

This is working. Thank you both.

Whole definition of THING and quotes around are required.
http://docs.openhab.org/configuration/rules-dsl.html#thing-based-triggers

rule "Kodi check thing"
when
	Thing "kodi:kodi:Kodi_ARZ" changed to ONLINE
then
	logInfo("test.rules", "Kodi ARZ is ONLINE")
end

1 Like

Ups… yes… whole uuid of the thing