Binding Request: JVC Projector

I have it working finally. Here is my code:

Items:

String JVC_Projector “JVC Projector [%s]” {tcp=“>[192.168.1.105:20554:‘REGEX(*)’]”}
Switch JVC_Update “Force JVC Update” (Prog)
Switch JVC_Power “Projector” (Prog)
Number JVC_Projector_State “JVC State [%d]” (Proj)
Number jvc_power_check_running (Proj)

Rules:
Checks and updates toggle switch…

rule “JVC Power State Check”
when
Item JVC_Update changed
or Time cron “0 0/5 * * * ?” // check every 5 minutes
then
jvc_power_check_running.sendCommand(1)
createTimer(now.plusSeconds(8))[|
JVC_Projector.sendCommand(“PJREQ”)
createTimer(now.plusMillis(800))[|
JVC_Projector.sendCommand(‘\u003F\u0089\u0001\u0050\u0057\u000A’) //request power state
createTimer(now.plusMillis(800))[|
if (JVC_Projector.state.toString() == “\u0006\u0089\u0001\u0050\u0057\u000A\u0040\u0089\u0001\u0050\u0057\u0030\u000A”){ //30 means off
JVC_Projector_State.postUpdate(0)
JVC_Power.postUpdate(OFF)
} else if (JVC_Projector.state.toString() == “\u0006\u0089\u0001\u0050\u0057\u000A\u0040\u0089\u0001\u0050\u0057\u0031\u000A”){ //31 means on
JVC_Projector_State.postUpdate(1)
JVC_Power.postUpdate(ON)
} else if (JVC_Projector.state.toString() == “\u0006\u0089\u0001\u0050\u0057\u000A\u0040\u0089\u0001\u0050\u0057\u0032\u000A”){ //32 means cooling
JVC_Projector_State.postUpdate(2)
JVC_Power.postUpdate(OFF)
}else if (JVC_Projector.state.toString() == “\u0006\u0089\u0001\u0050\u0057\u000A\u0040\u0089\u0001\u0050\u0057\u0034\u000A”){ //34 means emergency
JVC_Projector_State.postUpdate(4)
JVC_Power.postUpdate(OFF)
}
createTimer(now.plusSeconds(5)) [|
jvc_power_check_running.sendCommand(0)
]//jvc_power_check_running
] //waitJVC3
] //waitJVC2
] //waitJVC
end

Turns off and on…

rule “JVC Power”
//http://support.jvc.com/consumer/support/documents/DILAremoteControlGuide.pdf
when
Item JVC_Power changed
then
while (jvc_power_check_running.state == 1){
Thread::sleep(5000)
}
if (JVC_Power.state == OFF){
JVC_Projector.sendCommand(“PJREQ”)
createTimer(now.plusMillis(800))[|
JVC_Projector.sendCommand(‘\u0021\u0089\u0001\u0050\u0057\u0030\u000A’) //Power off
JVC_Projector_State.postUpdate(0)
]
} else if (JVC_Power.state == ON){//power off
JVC_Projector.sendCommand(“PJREQ”)
createTimer(now.plusMillis(800))[|
JVC_Projector.sendCommand(‘\u0021\u0089\u0001\u0050\u0057\u0031\u000A’) //Power on
JVC_Projector_State.postUpdate(1)
]
}//power on off
end