Hi All
Not sure what’s changed by the kodi_control item used to control the media player has suddenly started to switch to PLAY or PAUSE for a reason I’m yet to work out.
When its play, it turns my light motion sensor off which means im in the dark at night!
The log is full of play/pause.
Any suggestions on how to troubleshoot? I have an Widget which has PLAY/PAUSE buttons but my Rules only react to it being on PLAY or PAUSE.
I cant work out why its doing this
Any suggestions??
Thanks!
The offending item is this:
myKodi_control
mber percent = 0
var Timer fade_timer = null
rule "Apply Scene and turn the TV to the correct input for FTA when TV OFF"
when
Item TVProxyFTA received command ON
then
if (TVStatusONOFF.state == OFF && Yamaha_Power.state == OFF) {
Zone_1_Scene.sendCommand("Scene 1")
Thread::sleep(3000)
TV.sendCommand("TVFreeToAir")
}
end
rule "Apply Scene and turn the TV to the correct input for FTA when TV ON"
when
Item TVProxyFTA received command ON
then
if (TVStatusONOFF.state == ON) {
Zone_1_Scene.sendCommand("Scene 1")
Thread::sleep(1000)
TV.sendCommand("TVFreeToAir")
}
end
rule "Watch a Vero Movie, Dim the Lights and Turn All AV Equipment on"
when
Item Scene_Watch_Vero received command ON
then
var String scene = "Vero Scene"
//Switch on TV
if (TVStatus.state == OFF) {
TV.sendCommand("TVOnOff")
logInfo(scene, "TV switched On")
}
//Switch On AVR
if (Main_Zone_Power.state == OFF) {
Main_Zone_Power.sendCommand(ON)
logInfo(scene, "AVR switched on")
}
//Change AVR Scene to Movie
if ((Zone_1_Scene.state != "Scene 1" || Zone_1_Scene.state != "Scene 2")) {
Zone_1_Scene.sendCommand("Scene 3")
logInfo(scene, "AVR Scene set to Vero")
}
end
rule "When Kodi Player changed to PLAY"
when
Item myKodi_control changed
then
if (myKodi_control.state == PLAY){
FibaroEye1Motion_Armed.sendCommand(OFF) // Disable the motion sensor from turning on
//Slowly Dim the Lights if they are on
if (LivingRoomSw1.state == ON) {
if (fade_timer === null) {
percent = LivingRoomDim1.state as Number
fade_timer = createTimer(now.plusMillis(100), [ |
if (percent > 0) {
percent = percent - 2
if (percent < 0) percent = 0
LivingRoomDim1.sendCommand(percent)
fade_timer.reschedule(now.plusMillis(100))
} else {
fade_timer = null
}
])
}
}
}
else {
FibaroEye1Motion_Armed.sendCommand(ON) // Enable the motion sensor for any other state of myKodi_control
}
end
rule "When Kodi Player changed to PAUSE"
when
Item myKodi_control changed to PAUSE
then
Thread::sleep(200)
if (FibaroEye1Lux.state < 20 && LivingRoomSw1.state == OFF && myKodi_stop.state == OFF)
LivingRoomDim1.sendCommand(5)
end
rule "When Kodi Player changed to ON"
when
Item myKodi_stop changed to ON
then
//Slowly Brighten the Lights at the end of the Movie
if (LivingRoomSw1.state == OFF && FibaroEye1Lux.state < 20) {
if (fade_timer === null) {
percent = LivingRoomDim1.state as Number
if (percent == 0) {
fade_timer = createTimer(now.plusMillis(100), [ |
percent = percent + 2 // increase slowly
if (percent <= 30) { // up to 30%
LivingRoomDim1.sendCommand(percent)
fade_timer.reschedule(now.plusMillis(100))
FibaroEye1Motion_Armed.sendCommand(ON)
} else {
fade_timer = null
}
])
}
}
}
end
rule "Kodi Video Library Scan"
when
Item myKodi_rescan received command
then
val result = executeCommandLine("/etc/openhab2/scripts/kodi_rescan.sh", 5000)
logInfo("Kodi Library Scan", result)
end
rule "Check Vero Presense"
when
Thing "kodi:kodi:d78d7398" changed to ONLINE or
Thing "kodi:kodi:d78d7398" changed to OFFLINE
then
var thingStatusInfo_Vero = getThingStatusInfo("kodi:kodi:d78d7398")
if ((thingStatusInfo_Vero !== null) && (thingStatusInfo_Vero.getStatus().toString() == "ONLINE")) {
logInfo("Vero Status", "Vero is online.")
} else {
logError("Vero Status", "Vero is offline")
}
end
rule "Turn Kodi Subtitle Off"
when
Item myKodi_subtitle_off received command OFF
then
val String URL = "http://192.168.0.12:8080/jsonrpc"
var String contenttype = "application/json"
var String jsondata = '{"jsonrpc":"2.0","id":1,"method":"Player.SetSubtitle","params":{"playerid":1,"subtitle":"off"}}'
logInfo("Kodi subtitle", "Sending Command " + myKodi_subtitle_off.state + " to myKodi_subtitle_off.")
sendHttpPostRequest(URL, contenttype, jsondata)
end
rule "Turn Kodi Subtitle On"
when
Item myKodi_subtitle_on received command ON
then
val String URL = "http://192.168.0.12:8080/jsonrpc"
var String contenttype = "application/json"
var String jsondata = '{"jsonrpc":"2.0","id":1,"method":"Player.SetSubtitle","params":{"playerid":1,"subtitle":"on"}}'
logInfo("Kodi subtitle", "Sending Command " + myKodi_subtitle_on.state + " to myKodi_subtitle_on.")
sendHttpPostRequest(URL, contenttype, jsondata)
end
rule "Mute and unmute the music in case of a Call"
when
Item Mute_Music received command
then
if (Main_Zone_Power.state == ON && (spotify_current_playing.state == ON || myKodi_control.state == PLAY )) {
Zone_1_Mute.sendCommand(receivedCommand)
logInfo("Mute",if(receivedCommand == ON) "Music muted due to Incoming Call" else "Music unmuted due to Call Hang Up")
}
end
rule "Pause Kodi if the Doorbell rings"
when
Item DoorBird_DoorBell received command ON
then
if (myKodi_control.state == PLAY){
myKodi_control.sendCommand(PAUSE)
logInfo("Kodi", "The movie has been paused as theres someone at the door")
}
end
rule "Mute and unmute the music in case of a Doorbird ring"
when
Item DoorBird_DoorBell received command
then
if (Main_Zone_Power.state == ON && (spotify_current_playing.state == ON || myKodi_control.state == PLAY )) {
Zone_1_Mute.sendCommand(ON)
logInfo("Mute",if(receivedCommand == ON) "Music muted due to Doorbird ring" else "Music unmuted due to Doorbird hangup")
}
if (DoorBird_SIP.state == OFF) {
Zone_1_Mute.sendCommand(OFF)
}
end