Setting up office light timers with time of day

hey guys im trying to get the office lights working with a motion sensor and also time of day.
my current rule shown the following in the logs.

2019-01-02 10:28:16.387 [INFO ] [el.core.internal.ModelRepositoryImpl] - Validation issues found in configuration model 'Test.rules', using it anyway:
This expression is not allowed in this context, since it doesn't cause any side effects.
This expression is not allowed in this context, since it doesn't cause any side effects.
This expression is not allowed in this context, since it doesn't cause any side effects.
This expression is not allowed in this context, since it doesn't cause any side effects.
This expression is not allowed in this context, since it doesn't cause any side effects.
This expression is not allowed in this context, since it doesn't cause any side effects.
This expression is not allowed in this context, since it doesn't cause any side effects.
This expression is not allowed in this context, since it doesn't cause any side effects.
This expression is not allowed in this context, since it doesn't cause any side effects.
This expression is not allowed in this context, since it doesn't cause any side effects.
This expression is not allowed in this context, since it doesn't cause any side effects.
This expression is not allowed in this context, since it doesn't cause any side effects.
2019-01-02 10:28:16.662 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'Test.rules'

here’s the current rule file.

val int OfficeTimeoutMinutesMorning = 60
val int OfficeTimeoutMinutesDay = 60
val int OfficeTimeoutMinutesAfternoon = 60
val int OfficeTimeoutMinutesEvening = 60
val int OfficeTimeoutMinutesNight = 60
val int OfficeTimeoutMinutesBed = 5

val int EntryTimeoutMinutesBed = 2
val int EntryTimeoutMinutesOther = 30


var Timer OfficeLightsTimer = null
var Timer EntryLightsTimer = null



rule "Turn On Office Lights Auto Bypass"
when 
	Item Office_Lights changed or
	Item Office_Lamp_Left changed or
	Item Office_Lamp_Back changed or
	Item Office_Lamp_Right changed
then
	sendCommand(BYPASS_Office_LightsTimer, ON)
end







rule "Office Light Timer"

when
	Item Office_Motion received update ON
then

if	((OfficeLightsTimer === null) && (vTimeOfDay.state == "MORNING") && (BYPASS_Office_LightsTimer == "OFF")) {
		sendCommand(Office_Lights, "100")
		sendCommand(Office_Lamp_Left_Temp, "60")
		sendCommand(Office_Lamp_Back_Temp, "60")
		sendCommand(Office_Lamp_Right_Temp, "60")
		Thread::sleep(300)
		sendCommand(Office_Lamp_Left, "100")
		sendCommand(Office_Lamp_Back, "100")
		sendCommand(Office_Lamp_Right, "100")
		postUpdate(All_Lights, ON)
    		createTimer(now.plusSeconds(2),  [ |
			postUpdate(BYPASS_Office_LightsTimer, OFF)
			])
        	OfficeLightsTimer = createTimer(now.plusMinutes(OfficeTimeoutMinutesMorning ), [|
			sendCommand(Office_Lamp_Left, "OFF")
			sendCommand(Office_Lamp_Back, "OFF")
			sendCommand(Office_Lamp_Right, "OFF")
			sendCommand(Office_Lights, "OFF")
    			createTimer(now.plusSeconds(2),  [ |
				postUpdate(BYPASS_Office_LightsTimer, OFF)
				])
           		OfficeLightsTimer = null
        		])
    		}
else 		{
    		if((vTimeOfDay.state == "MORNING") && (BYPASS_Office_LightsTimer == "OFF")) {
		sendCommand(Office_Lights, "100")
		sendCommand(Office_Lamp_Left_Temp, "60")
		sendCommand(Office_Lamp_Back_Temp, "60")
		sendCommand(Office_Lamp_Right_Temp, "60")
		Thread::sleep(300)
		sendCommand(Office_Lamp_Left, "100")
		sendCommand(Office_Lamp_Back, "100")
		sendCommand(Office_Lamp_Right, "100")
		postUpdate(All_Lights, ON)
    		createTimer(now.plusSeconds(2),  [ |
			postUpdate(BYPASS_Office_LightsTimer, OFF)
			])
        		OfficeLightsTimer(now.plusMinutes(OfficeTimeoutMinutesMorning ))
   	 	}
		}

if	((OfficeLightsTimer === null) && (vTimeOfDay.state == "DAY") && (BYPASS_Office_LightsTimer == "OFF")) {
		sendCommand(Office_Lights, "100")
		sendCommand(Office_Lamp_Left_Temp, "30")
		sendCommand(Office_Lamp_Back_Temp, "30")
		sendCommand(Office_Lamp_Right_Temp, "30")
		Thread::sleep(300)
		sendCommand(Office_Lamp_Left, "100")
		sendCommand(Office_Lamp_Back, "100")
		sendCommand(Office_Lamp_Right, "100")
		postUpdate(All_Lights, ON)
	    		createTimer(now.plusSeconds(2),  [ |
			postUpdate(BYPASS_Office_LightsTimer, OFF)
			])
        	OfficeLightsTimer = createTimer(now.plusMinutes(OfficeTimeoutMinutesDay ), [|
			sendCommand(Office_Lamp_Left, "OFF")
			sendCommand(Office_Lamp_Back, "OFF")
			sendCommand(Office_Lamp_Right, "OFF")
			sendCommand(Office_Lights, "OFF")
    			createTimer(now.plusSeconds(2),  [ |
				postUpdate(BYPASS_Office_LightsTimer, OFF)
				])
           		OfficeLightsTimer = null
        		])
    		}
else 		{
   		if((vTimeOfDay.state == "DAY") && (BYPASS_Office_LightsTimer == "OFF")) {
		sendCommand(Office_Lights, "100")
		sendCommand(Office_Lamp_Left_Temp, "30")
		sendCommand(Office_Lamp_Back_Temp, "30")
		sendCommand(Office_Lamp_Right_Temp, "30")
		Thread::sleep(300)
		sendCommand(Office_Lamp_Left, "100")
		sendCommand(Office_Lamp_Back, "100")
		sendCommand(Office_Lamp_Right, "100")
		postUpdate(All_Lights, ON)
	    		createTimer(now.plusSeconds(2),  [ |
			postUpdate(BYPASS_Office_LightsTimer, OFF)
			])
        	OfficeLightsTimer(now.plusMinutes(OfficeTimeoutMinutesDay ))
   	 	}
		}

if	((OfficeLightsTimer === null) && (vTimeOfDay.state == "AFTERNOON") && (BYPASS_Office_LightsTimer == OFF)) {
		sendCommand(Office_Lights, "100")
		sendCommand(Office_Lamp_Left_Temp, "30")
		sendCommand(Office_Lamp_Back_Temp, "30")
		sendCommand(Office_Lamp_Right_Temp, "30")
		Thread::sleep(300)
		sendCommand(Office_Lamp_Left, "100")
		sendCommand(Office_Lamp_Back, "100")
		sendCommand(Office_Lamp_Right, "100")
		postUpdate(All_Lights, ON)
	    		createTimer(now.plusSeconds(2),  [ |
			postUpdate(BYPASS_Office_LightsTimer, OFF)
			])
        	OfficeLightsTimer = createTimer(now.plusMinutes(OfficeTimeoutMinutesAfternoon ), [|
			sendCommand(Office_Lamp_Left, "OFF")
			sendCommand(Office_Lamp_Back, "OFF")
			sendCommand(Office_Lamp_Right, "OFF")
			sendCommand(Office_Lights, "OFF")
    			createTimer(now.plusSeconds(2),  [ |
				postUpdate(BYPASS_Office_LightsTimer, OFF)
				])
           		OfficeLightsTimer = null
        		])
    		}
else 		{
    		if((vTimeOfDay.state == "AFTERNOON") && (BYPASS_Office_LightsTimer == OFF)) {
		sendCommand(Office_Lights, "100")
		sendCommand(Office_Lamp_Left_Temp, "30")
		sendCommand(Office_Lamp_Back_Temp, "30")
		sendCommand(Office_Lamp_Right_Temp, "30")
		Thread::sleep(300)
		sendCommand(Office_Lamp_Left, "100")
		sendCommand(Office_Lamp_Back, "100")
		sendCommand(Office_Lamp_Right, "100")
		postUpdate(All_Lights, ON)
    		createTimer(now.plusSeconds(2),  [ |
			postUpdate(BYPASS_Office_LightsTimer, OFF)
			])
        		OfficeLightsTimer(now.plusMinutes(OfficeTimeoutMinutesAfternoon ))
   	 	}
		}

if	((OfficeLightsTimer === null) && (vTimeOfDay.state == "EVENING") && (BYPASS_Office_LightsTimer == OFF)) {
		sendCommand(Office_Lights, "100")
		sendCommand(Office_Lamp_Left_Temp, "40")
		sendCommand(Office_Lamp_Back_Temp, "40")
		sendCommand(Office_Lamp_Right_Temp, "40")
		Thread::sleep(300)
		sendCommand(Office_Lamp_Left, "100")
		sendCommand(Office_Lamp_Back, "100")
		sendCommand(Office_Lamp_Right, "100")
		postUpdate(All_Lights, ON)
    			createTimer(now.plusSeconds(2),  [ |
			postUpdate(BYPASS_Office_LightsTimer, OFF)
			])
        	OfficeLightsTimer = createTimer(now.plusMinutes(OfficeTimeoutMinutesEvening ), [|
			sendCommand(Office_Lamp_Left, "OFF")
			sendCommand(Office_Lamp_Back, "OFF")
			sendCommand(Office_Lamp_Right, "OFF")
			sendCommand(Office_Lights, "OFF")
    			createTimer(now.plusSeconds(2),  [ |
				postUpdate(BYPASS_Office_LightsTimer, OFF)
				])
           		OfficeLightsTimer = null
        		])
    		}
else 		{
    		if((vTimeOfDay.state == "EVENING") && (BYPASS_Office_LightsTimer == OFF)) {
		sendCommand(Office_Lights, "100")
		sendCommand(Office_Lamp_Left_Temp, "40")
		sendCommand(Office_Lamp_Back_Temp, "40")
		sendCommand(Office_Lamp_Right_Temp, "40")
		Thread::sleep(300)
		sendCommand(Office_Lamp_Left, "100")
		sendCommand(Office_Lamp_Back, "100")
		sendCommand(Office_Lamp_Right, "100")
		postUpdate(All_Lights, ON)
    			createTimer(now.plusSeconds(2),  [ |
			postUpdate(BYPASS_Office_LightsTimer, OFF)
			])
        		OfficeLightsTimer(now.plusMinutes(OfficeTimeoutMinutesEvening ))
   	 	}
		}

if	((OfficeLightsTimer === null) && (vTimeOfDay.state == "NIGHT") && (BYPASS_Office_LightsTimer == OFF)) {
		sendCommand(Office_Lights, "100")
		sendCommand(Office_Lamp_Left_Temp, "60")
		sendCommand(Office_Lamp_Back_Temp, "60")
		sendCommand(Office_Lamp_Right_Temp, "60")
		Thread::sleep(300)
		sendCommand(Office_Lamp_Left, "100")
		sendCommand(Office_Lamp_Back, "100")
		sendCommand(Office_Lamp_Right, "100")
		postUpdate(All_Lights, ON)
    		createTimer(now.plusSeconds(2),  [ |
			postUpdate(BYPASS_Office_LightsTimer, OFF)
			])
        	OfficeLightsTimer = createTimer(now.plusMinutes(OfficeTimeoutMinutesNight ), [|
			sendCommand(Office_Lamp_Left, "OFF")
			sendCommand(Office_Lamp_Back, "OFF")
			sendCommand(Office_Lamp_Right, "OFF")
			sendCommand(Office_Lights, "OFF")
    			createTimer(now.plusSeconds(2),  [ |
				postUpdate(BYPASS_Office_LightsTimer, OFF)
				])
           		OfficeLightsTimer = null
        		])
    		}
else 		{
    		if((vTimeOfDay.state == "NIGHT") && (BYPASS_Office_LightsTimer == OFF)) {
		sendCommand(Office_Lights, "100")
		sendCommand(Office_Lamp_Left_Temp, "60")
		sendCommand(Office_Lamp_Back_Temp, "60")
		sendCommand(Office_Lamp_Right_Temp, "60")
		Thread::sleep(300)
		sendCommand(Office_Lamp_Left, "100")
		sendCommand(Office_Lamp_Back, "100")
		sendCommand(Office_Lamp_Right, "100")
		postUpdate(All_Lights, ON)
    		createTimer(now.plusSeconds(2),  [ |
			postUpdate(BYPASS_Office_LightsTimer, OFF)
			])
        		OfficeLightsTimer(now.plusMinutes(OfficeTimeoutMinutesNight ))
   	 	}
		}

if	((OfficeLightsTimer === null) && (vTimeOfDay.state == "BED") && (BYPASS_Office_LightsTimer == OFF)) {
		sendCommand(Office_Lights, "100")
		sendCommand(Office_Lamp_Left_Temp, "60")
		sendCommand(Office_Lamp_Back_Temp, "60")
		sendCommand(Office_Lamp_Right_Temp, "60")
		Thread::sleep(300)
		sendCommand(Office_Lamp_Left, "100")
		sendCommand(Office_Lamp_Back, "100")
		sendCommand(Office_Lamp_Right, "100")
		postUpdate(All_Lights, ON)
    		createTimer(now.plusSeconds(2),  [ |
			postUpdate(BYPASS_Office_LightsTimer, OFF)
			])
        	OfficeLightsTimer = createTimer(now.plusMinutes(OfficeTimeoutMinutesBed ), [|
			sendCommand(Office_Lamp_Left, "OFF")
			sendCommand(Office_Lamp_Back, "OFF")
			sendCommand(Office_Lamp_Right, "OFF")
			sendCommand(Office_Lights, "OFF")
    			createTimer(now.plusSeconds(2),  [ |
				postUpdate(BYPASS_Office_LightsTimer, OFF)
				])
           		OfficeLightsTimer = null
        		])
    		}
else 		{
    		if((vTimeOfDay.state == "BED") && (BYPASS_Office_LightsTimer == "OFF")) {
		sendCommand(Office_Lights, "100")
		sendCommand(Office_Lamp_Left_Temp, "60")
		sendCommand(Office_Lamp_Back_Temp, "60")
		sendCommand(Office_Lamp_Right_Temp, "60")
		Thread::sleep(300)
		sendCommand(Office_Lamp_Left, "100")
		sendCommand(Office_Lamp_Back, "100")
		sendCommand(Office_Lamp_Right, "100")
		postUpdate(All_Lights, ON)
    		createTimer(now.plusSeconds(2),  [ |
			postUpdate(BYPASS_Office_LightsTimer, OFF)
			])
        		OfficeLightsTimer(now.plusMinutes(OfficeTimeoutMinutesBed ))
   	 	}
}
end






rule "Back Yard Light Timer"
when
	Item Patio_Motion changed from OFF to ON 
then
if 	((Someones_Home.state == ON) && (vTimeOfDay.state == "MORNING")) 
		{
		sendCommand(HueBackYardColour, 100)
		sendCommand(HueBackYardTemp, 60)
			createTimer(now.plusMinutes(30),  [ |
				sendCommand(HueBackYardColour, OFF)
				])
		}
if 	((Someones_Home.state == ON) && (vTimeOfDay.state == "AFTERNOON")) 
		{
		sendCommand(HueBackYardColour, 100)
		sendCommand(HueBackYardTemp, 60)
			createTimer(now.plusMinutes(60),  [ |
				sendCommand(HueBackYardColour, OFF)
				])
		}
if 	((Someones_Home.state == ON) && (vTimeOfDay.state == "EVENING")) 
		{
		sendCommand(HueBackYardColour, 100)
		sendCommand(HueBackYardTemp, 60)
			createTimer(now.plusMinutes(60),  [ |
				sendCommand(HueBackYardColour, OFF)
				])
		}
if 	((Someones_Home.state == ON) && (vTimeOfDay.state == "NIGHT")) 
		{
		sendCommand(HueBackYardColour, 100)
		sendCommand(HueBackYardTemp, 60)
			createTimer(now.plusMinutes(60),  [ |
				sendCommand(HueBackYardColour, OFF)
				])
		}
if 	((Someones_Home.state == ON) && (vTimeOfDay.state == "BED")) 
		{
		sendCommand(HueBackYardColour, 100)
		sendCommand(HueBackYardTemp, 60)
			createTimer(now.plusMinutes(60),  [ |
				sendCommand(HueBackYardColour, OFF)
				])
		}
end


rule "Entry Lights"
when
	Item Entry_Motion received command ON
then
if	((EntryLightsTimer === null) && (vTimeOfDay.state == "MORNING")) {
		sendCommand(Entrance_Lights, ON)
        	EntryLightsTimer = createTimer(now.plusMinutes(EntryTimeoutMinutesOther ), [|
			sendCommand(Entrance_Lights, OFF)
           		EntryLightsTimer = null
        		])
    		}
else 		{
    		if(vTimeOfDay.state == "MORNING") {
			sendCommand(Entrance_Lights, ON)
        		OfficeLightsTimer(now.plusMinutes(EntryTimeoutMinutesOther ))
   	 	}
}

if	((EntryLightsTimer === null) && (vTimeOfDay.state == "DAY")) {
		sendCommand(Entrance_Lights, ON)
        	EntryLightsTimer = createTimer(now.plusMinutes(EntryTimeoutMinutesOther ), [|
			sendCommand(Entrance_Lights, OFF)
           		EntryLightsTimer = null
        		])
    		}
else 		{
    		if(vTimeOfDay.state == "DAY") {
			sendCommand(Entrance_Lights, ON)
        		OfficeLightsTimer(now.plusMinutes(EntryTimeoutMinutesOther ))
   	 	}
}

if	((EntryLightsTimer === null) && (vTimeOfDay.state == "AFTERNOON	")) {
		sendCommand(Entrance_Lights, ON)
        	EntryLightsTimer = createTimer(now.plusMinutes(EntryTimeoutMinutesOther ), [|
			sendCommand(Entrance_Lights, OFF)
           		EntryLightsTimer = null
        		])
    		}
else 		{
    		if(vTimeOfDay.state == "AFTERNOON") {
			sendCommand(Entrance_Lights, ON)
        		OfficeLightsTimer(now.plusMinutes(EntryTimeoutMinutesOther ))
   	 	}
}

if	((EntryLightsTimer === null) && (vTimeOfDay.state == "EVENING")) {
		sendCommand(Entrance_Lights, ON)
        	EntryLightsTimer = createTimer(now.plusMinutes(EntryTimeoutMinutesOther ), [|
			sendCommand(Entrance_Lights, OFF)
           		EntryLightsTimer = null
        		])
    		}
else 		{
    		if(vTimeOfDay.state == "EVENING") {
			sendCommand(Entrance_Lights, ON)
        		OfficeLightsTimer(now.plusMinutes(EntryTimeoutMinutesOther ))
   	 	}
}

if	((EntryLightsTimer === null) && (vTimeOfDay.state == "NIGHT")) {
		sendCommand(Entrance_Lights, ON)
        	EntryLightsTimer = createTimer(now.plusMinutes(EntryTimeoutMinutesOther ), [|
			sendCommand(Entrance_Lights, OFF)
           		EntryLightsTimer = null
        		])
    		}
else 		{
    		if(vTimeOfDay.state == "NIGHT") {
			sendCommand(Entrance_Lights, ON)
        		OfficeLightsTimer(now.plusMinutes(EntryTimeoutMinutesOther ))
   	 	}
}

if	((EntryLightsTimer === null) && (vTimeOfDay.state == "BED")) {
		sendCommand(Entrance_Lights, ON)
        	EntryLightsTimer = createTimer(now.plusMinutes(EntryTimeoutMinutesBed ), [|
			sendCommand(Entrance_Lights, OFF)
           		EntryLightsTimer = null
        		])
    		}
else 		{
    		if(vTimeOfDay.state == "BED") {
			sendCommand(Entrance_Lights, ON)
        		OfficeLightsTimer(now.plusMinutes(EntryTimeoutMinutesBed ))
   	 	}
}

end

the rule isn’t firing at all even all of the conditions are met eg vTimeOfDay.state is currently DAY\ & BYPASS_Office_LightsTimer is currently OFF
can anyone help?

Replace ’ BYPASS_Office_LightsTimer == “OFF”’ and BYPASS_Office_LightsTimer == OFF’ with ‘BYPASS_Office_LightsTimer.state == “OFF”’ on all if clauses.

You have forgotten sometimes the " and always the .state

It should be

BYPASS_Office_LightsTimer.state == OFF

No "" are needed if the item is a switch because OFF is recognized by the rule engine as an OnOffType

thanks guys ive done that and now in the logs ive got the following on top of the errors in the first post

2019-01-02 11:08:01.121 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'Test.rules'
2019-01-02 11:09:39.972 [ERROR] [ersey.server.ServerRuntime$Responder] - An I/O error has occurred while writing a response message entity to the container output stream.
org.glassfish.jersey.server.internal.process.MappableException: org.eclipse.jetty.io.EofException
	at org.glassfish.jersey.server.internal.MappableExceptionWrapperInterceptor.aroundWriteTo(MappableExceptionWrapperInterceptor.java:92) ~[?:?]
	at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:162) ~[171:org.glassfish.jersey.core.jersey-common:2.22.2]
	at org.glassfish.jersey.message.internal.MessageBodyFactory.writeTo(MessageBodyFactory.java:1130) ~[171:org.glassfish.jersey.core.jersey-common:2.22.2]
	at org.glassfish.jersey.server.ServerRuntime$Responder.writeResponse(ServerRuntime.java:711) [172:org.glassfish.jersey.core.jersey-server:2.22.2]
	at org.glassfish.jersey.server.ServerRuntime$Responder.processResponse(ServerRuntime.java:444) [172:org.glassfish.jersey.core.jersey-server:2.22.2]
	at org.glassfish.jersey.server.ServerRuntime$Responder.process(ServerRuntime.java:434) [172:org.glassfish.jersey.core.jersey-server:2.22.2]
	at org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:329) [172:org.glassfish.jersey.core.jersey-server:2.22.2]
	at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271) [171:org.glassfish.jersey.core.jersey-common:2.22.2]
	at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267) [171:org.glassfish.jersey.core.jersey-common:2.22.2]
	at org.glassfish.jersey.internal.Errors.process(Errors.java:315) [171:org.glassfish.jersey.core.jersey-common:2.22.2]
	at org.glassfish.jersey.internal.Errors.process(Errors.java:297) [171:org.glassfish.jersey.core.jersey-common:2.22.2]
	at org.glassfish.jersey.internal.Errors.process(Errors.java:267) [171:org.glassfish.jersey.core.jersey-common:2.22.2]
	at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317) [171:org.glassfish.jersey.core.jersey-common:2.22.2]
	at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:305) [172:org.glassfish.jersey.core.jersey-server:2.22.2]
	at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1154) [172:org.glassfish.jersey.core.jersey-server:2.22.2]
	at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:473) [169:org.glassfish.jersey.containers.jersey-container-servlet-core:2.22.2]
	at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:427) [169:org.glassfish.jersey.containers.jersey-container-servlet-core:2.22.2]
	at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:388) [169:org.glassfish.jersey.containers.jersey-container-servlet-core:2.22.2]
	at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:341) [169:org.glassfish.jersey.containers.jersey-container-servlet-core:2.22.2]
	at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:228) [169:org.glassfish.jersey.containers.jersey-container-servlet-core:2.22.2]
	at com.eclipsesource.jaxrs.publisher.internal.ServletContainerBridge.service(ServletContainerBridge.java:76) [20:com.eclipsesource.jaxrs.publisher:5.3.1.201602281253]
	at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:865) [85:org.eclipse.jetty.servlet:9.4.11.v20180605]
	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:535) [85:org.eclipse.jetty.servlet:9.4.11.v20180605]
	at org.ops4j.pax.web.service.jetty.internal.HttpServiceServletHandler.doHandle(HttpServiceServletHandler.java:71) [186:org.ops4j.pax.web.pax-web-jetty:7.2.3]
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:146) [84:org.eclipse.jetty.server:9.4.11.v20180605]
	at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548) [82:org.eclipse.jetty.security:9.4.11.v20180605]
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132) [84:org.eclipse.jetty.server:9.4.11.v20180605]
	at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:257) [84:org.eclipse.jetty.server:9.4.11.v20180605]
	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1595) [84:org.eclipse.jetty.server:9.4.11.v20180605]
	at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:255) [84:org.eclipse.jetty.server:9.4.11.v20180605]
	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1317) [84:org.eclipse.jetty.server:9.4.11.v20180605]
	at org.ops4j.pax.web.service.jetty.internal.HttpServiceContext.doHandle(HttpServiceContext.java:293) [186:org.ops4j.pax.web.pax-web-jetty:7.2.3]
	at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:203) [84:org.eclipse.jetty.server:9.4.11.v20180605]
	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:473) [85:org.eclipse.jetty.servlet:9.4.11.v20180605]
	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1564) [84:org.eclipse.jetty.server:9.4.11.v20180605]
	at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:201) [84:org.eclipse.jetty.server:9.4.11.v20180605]
	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1219) [84:org.eclipse.jetty.server:9.4.11.v20180605]
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:144) [84:org.eclipse.jetty.server:9.4.11.v20180605]
	at org.ops4j.pax.web.service.jetty.internal.JettyServerHandlerCollection.handle(JettyServerHandlerCollection.java:80) [186:org.ops4j.pax.web.pax-web-jetty:7.2.3]
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132) [84:org.eclipse.jetty.server:9.4.11.v20180605]
	at org.eclipse.jetty.server.Server.handle(Server.java:531) [84:org.eclipse.jetty.server:9.4.11.v20180605]
	at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:352) [84:org.eclipse.jetty.server:9.4.11.v20180605]
	at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:260) [84:org.eclipse.jetty.server:9.4.11.v20180605]
	at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:281) [75:org.eclipse.jetty.io:9.4.11.v20180605]
	at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:102) [75:org.eclipse.jetty.io:9.4.11.v20180605]
	at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:118) [75:org.eclipse.jetty.io:9.4.11.v20180605]
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:333) [87:org.eclipse.jetty.util:9.4.11.v20180605]
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:310) [87:org.eclipse.jetty.util:9.4.11.v20180605]
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:168) [87:org.eclipse.jetty.util:9.4.11.v20180605]
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:126) [87:org.eclipse.jetty.util:9.4.11.v20180605]
	at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:366) [87:org.eclipse.jetty.util:9.4.11.v20180605]
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:762) [87:org.eclipse.jetty.util:9.4.11.v20180605]
	at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:680) [87:org.eclipse.jetty.util:9.4.11.v20180605]
	at java.lang.Thread.run(Thread.java:748) [?:?]
Caused by: org.eclipse.jetty.io.EofException
	at org.eclipse.jetty.io.ChannelEndPoint.flush(ChannelEndPoint.java:286) ~[75:org.eclipse.jetty.io:9.4.11.v20180605]
	at org.eclipse.jetty.io.WriteFlusher.flush(WriteFlusher.java:429) ~[75:org.eclipse.jetty.io:9.4.11.v20180605]
	at org.eclipse.jetty.io.WriteFlusher.write(WriteFlusher.java:323) ~[75:org.eclipse.jetty.io:9.4.11.v20180605]
	at org.eclipse.jetty.io.AbstractEndPoint.write(AbstractEndPoint.java:380) ~[75:org.eclipse.jetty.io:9.4.11.v20180605]
	at org.eclipse.jetty.server.HttpConnection$SendCallback.process(HttpConnection.java:798) ~[84:org.eclipse.jetty.server:9.4.11.v20180605]
	at org.eclipse.jetty.util.IteratingCallback.processing(IteratingCallback.java:241) ~[87:org.eclipse.jetty.util:9.4.11.v20180605]
	at org.eclipse.jetty.util.IteratingCallback.iterate(IteratingCallback.java:224) ~[87:org.eclipse.jetty.util:9.4.11.v20180605]
	at org.eclipse.jetty.server.HttpConnection.send(HttpConnection.java:538) ~[84:org.eclipse.jetty.server:9.4.11.v20180605]
	at org.eclipse.jetty.server.HttpChannel.sendResponse(HttpChannel.java:790) ~[84:org.eclipse.jetty.server:9.4.11.v20180605]
	at org.eclipse.jetty.server.HttpChannel.write(HttpChannel.java:846) ~[84:org.eclipse.jetty.server:9.4.11.v20180605]
	at org.eclipse.jetty.server.HttpOutput.write(HttpOutput.java:240) ~[84:org.eclipse.jetty.server:9.4.11.v20180605]
	at org.eclipse.jetty.server.HttpOutput.write(HttpOutput.java:216) ~[84:org.eclipse.jetty.server:9.4.11.v20180605]
	at org.eclipse.jetty.server.HttpOutput.write(HttpOutput.java:541) ~[84:org.eclipse.jetty.server:9.4.11.v20180605]
	at java.io.OutputStream.write(OutputStream.java:75) ~[?:?]
	at org.glassfish.jersey.servlet.internal.ResponseWriter$NonCloseableOutputStreamWrapper.write(ResponseWriter.java:320) ~[?:?]
	at org.glassfish.jersey.message.internal.CommittingOutputStream.write(CommittingOutputStream.java:218) ~[?:?]
	at org.glassfish.jersey.message.internal.WriterInterceptorExecutor$UnCloseableOutputStream.write(WriterInterceptorExecutor.java:294) ~[?:?]
	at org.eclipse.smarthome.io.rest.core.internal.GsonProvider.writeTo(GsonProvider.java:71) ~[?:?]
	at org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor.invokeWriteTo(WriterInterceptorExecutor.java:265) ~[?:?]
	at org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor.aroundWriteTo(WriterInterceptorExecutor.java:250) ~[?:?]
	at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:162) ~[?:?]
	at org.glassfish.jersey.server.internal.JsonWithPaddingInterceptor.aroundWriteTo(JsonWithPaddingInterceptor.java:106) ~[?:?]
	at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:162) ~[?:?]
	at org.glassfish.jersey.server.internal.MappableExceptionWrapperInterceptor.aroundWriteTo(MappableExceptionWrapperInterceptor.java:86) ~[?:?]
	... 53 more
Caused by: java.io.IOException: Broken pipe
	at sun.nio.ch.FileDispatcherImpl.writev0(Native Method) ~[?:?]
	at sun.nio.ch.SocketDispatcher.writev(SocketDispatcher.java:51) ~[?:?]
	at sun.nio.ch.IOUtil.write(IOUtil.java:148) ~[?:?]
	at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:504) ~[?:?]
	at org.eclipse.jetty.io.ChannelEndPoint.flush(ChannelEndPoint.java:266) ~[75:org.eclipse.jetty.io:9.4.11.v20180605]
	at org.eclipse.jetty.io.WriteFlusher.flush(WriteFlusher.java:429) ~[75:org.eclipse.jetty.io:9.4.11.v20180605]
	at org.eclipse.jetty.io.WriteFlusher.write(WriteFlusher.java:323) ~[75:org.eclipse.jetty.io:9.4.11.v20180605]
	at org.eclipse.jetty.io.AbstractEndPoint.write(AbstractEndPoint.java:380) ~[75:org.eclipse.jetty.io:9.4.11.v20180605]
	at org.eclipse.jetty.server.HttpConnection$SendCallback.process(HttpConnection.java:798) ~[84:org.eclipse.jetty.server:9.4.11.v20180605]
	at org.eclipse.jetty.util.IteratingCallback.processing(IteratingCallback.java:241) ~[87:org.eclipse.jetty.util:9.4.11.v20180605]
	at org.eclipse.jetty.util.IteratingCallback.iterate(IteratingCallback.java:224) ~[87:org.eclipse.jetty.util:9.4.11.v20180605]
	at org.eclipse.jetty.server.HttpConnection.send(HttpConnection.java:538) ~[84:org.eclipse.jetty.server:9.4.11.v20180605]
	at org.eclipse.jetty.server.HttpChannel.sendResponse(HttpChannel.java:790) ~[84:org.eclipse.jetty.server:9.4.11.v20180605]
	at org.eclipse.jetty.server.HttpChannel.write(HttpChannel.java:846) ~[84:org.eclipse.jetty.server:9.4.11.v20180605]
	at org.eclipse.jetty.server.HttpOutput.write(HttpOutput.java:240) ~[84:org.eclipse.jetty.server:9.4.11.v20180605]
	at org.eclipse.jetty.server.HttpOutput.write(HttpOutput.java:216) ~[84:org.eclipse.jetty.server:9.4.11.v20180605]
	at org.eclipse.jetty.server.HttpOutput.write(HttpOutput.java:541) ~[84:org.eclipse.jetty.server:9.4.11.v20180605]
	at java.io.OutputStream.write(OutputStream.java:75) ~[?:?]
	at org.glassfish.jersey.servlet.internal.ResponseWriter$NonCloseableOutputStreamWrapper.write(ResponseWriter.java:320) ~[?:?]
	at org.glassfish.jersey.message.internal.CommittingOutputStream.write(CommittingOutputStream.java:218) ~[?:?]
	at org.glassfish.jersey.message.internal.WriterInterceptorExecutor$UnCloseableOutputStream.write(WriterInterceptorExecutor.java:294) ~[?:?]
	at org.eclipse.smarthome.io.rest.core.internal.GsonProvider.writeTo(GsonProvider.java:71) ~[?:?]
	at org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor.invokeWriteTo(WriterInterceptorExecutor.java:265) ~[?:?]
	at org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor.aroundWriteTo(WriterInterceptorExecutor.java:250) ~[?:?]
	at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:162) ~[?:?]
	at org.glassfish.jersey.server.internal.JsonWithPaddingInterceptor.aroundWriteTo(JsonWithPaddingInterceptor.java:106) ~[?:?]
	at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:162) ~[?:?]
	at org.glassfish.jersey.server.internal.MappableExceptionWrapperInterceptor.aroundWriteTo(MappableExceptionWrapperInterceptor.java:86) ~[?:?]
	... 53 more

Are you using VS code?

As suggested, things like

BYPASS_Office_LightsTimer == "OFF"

should become

BYPASS_Office_LightsTimer.state == OFF

Furthermore it is strongly preferred to use

Office_Lights.sendCommand(100)

instead of

sendCommand(Office_Lights, "100")

(Also note I removed the quotation marks, I envision these are dimmer items, so they accept numbers, not strings.)

Furthermore this makes no sense:

OfficeLightsTimer(now.plusMinutes(OfficeTimeoutMinutesMorning ))

Not sure what you are trying to do there? You have many of such constructions in your rule.

not sure what vs code is sorry?

thanks guys .state has the rule kind of triggering, I can’t believe I missed that thats why you shouldn’t be trying to work on rules at 3am but in order to keep the way high nights is my only time to do it.

the rule is not setting the correct colour temperatures tho and I can’t work out why. and the lights are also dimming down to maybe 20% brightness and waiting maybe 30 seconds then turning off.

@RolfV
thanks for your help mate. I thought that the following would point to the values at the start on the rules file, I could be 100% wrong about this tho. Im still very very new to this.

OfficeLightsTimer(now.plusMinutes(OfficeTimeoutMinutesMorning ))

at the start of the rules file is

val int OfficeTimeoutMinutesMorning = 60
val int OfficeTimeoutMinutesDay = 60
val int OfficeTimeoutMinutesAfternoon = 60
val int OfficeTimeoutMinutesEvening = 60
val int OfficeTimeoutMinutesNight = 60
val int OfficeTimeoutMinutesBed = 5

my idea behind this is to make it easy to change the values later on and use this same rule for different rooms in the house too.

ohhhhh that looks pretty cool. no im just using textedit on the Mac

I tidied up a bit
Only the very first part of the rule:

rule "Office Light Timer"
when
    Item Office_Motion received update ON
then
    if ((OfficeLightsTimer === null) && (vTimeOfDay.state == "MORNING") && (BYPASS_Office_LightsTimer.state == OFF)) {
        Office_Lights.sendCommand(100)
        Office_Lamp_Left_Temp.sendCommand(60)
        Office_Lamp_Back_Temp.sendCommand(60)
        Office_Lamp_Right_Temp.sendCommand(60)
        Thread::sleep(300)
        Office_Lamp_Left.sendCommand(100)
        Office_Lamp_Back.sendCommand(100)
        Office_Lamp_Right.sendCommand(100)
        All_Lights.postUpdate(ON)
        createTimer(now.plusSeconds(2),  [ |
            postUpdate(BYPASS_Office_LightsTimer, OFF)
        ])
        OfficeLightsTimer = createTimer(now.plusMinutes(OfficeTimeoutMinutesMorning), [ |
            Office_Lamp_Left.sendCommand(OFF)
            Office_Lamp_Back.sendCommand(OFF)
            Office_Lamp_Right.sendCommand(OFF)
            Office_Lights.sendCommand(OFF)
            createTimer(now.plusSeconds(2),  [ |
                postUpdate(BYPASS_Office_LightsTimer, OFF)
            ])
            OfficeLightsTimer = null
        ])

But your rule code is very long
Consicer using groups where you always send commands to the same group of lights
For example you always use these 3 together:

        Office_Lamp_Left_Temp.sendCommand(60)
        Office_Lamp_Back_Temp.sendCommand(60)
       Office_Lamp_Right_Temp.sendCommand(60)

Put the 3 items in a group:
and then do:

    gOffice_Lamps.sendCommand(60)

Next Why do you do this?
Same items twice with a Thread::Sleep in the middle?

		sendCommand(Office_Lamp_Left_Temp, "30")
		sendCommand(Office_Lamp_Back_Temp, "30")
		sendCommand(Office_Lamp_Right_Temp, "30")
		Thread::sleep(300)
		sendCommand(Office_Lamp_Left, "100")
		sendCommand(Office_Lamp_Back, "100")
		sendCommand(Office_Lamp_Right, "100")

What is this supposed to do?

postUpdate(All_Lights, ON)

Your code repeats again and again
Consider putting ALL the ones that have the timer===null is ONE if statement
Then
Consider using some variables and do your commands at the end of the rule:

see:

For example:
Add these variables:

var Number officeLampValue1
var Number  officeLampValue2
var Number officeLampValue3

As global variables at the top of the file.

Go though you if statements and set the variables:
For example:

rule "Office Light Timer"
when
    Item Office_Motion received update ON
then
    if ((OfficeLightsTimer === null) && (vTimeOfDay.state == "MORNING") && (BYPASS_Office_LightsTimer.state == OFF)) {
        officeLightsValue1 = 60
        officeLightsValue2 = 100
        officeLightsValue3 = 0 //OFF
    } ....

At the BOTTOM of the rule execute the code:

        Office_Lights.sendCommand(100)
        Office_Lamp_Left_Temp.sendCommand(officeLampValue1)
        Office_Lamp_Back_Temp.sendCommand(officeLampValue1)
        Office_Lamp_Right_Temp.sendCommand(officeLampValue1)
        Thread::sleep(300)
        Office_Lamp_Left.sendCommand(officeLampValue2)
        Office_Lamp_Back.sendCommand(officeLampValue2)
        Office_Lamp_Right.sendCommand(officeLampValue2)
        //All_Lights.postUpdate(ON)
        createTimer(now.plusSeconds(2),  [ |
            postUpdate(BYPASS_Office_LightsTimer, OFF)
        ])
        OfficeLightsTimer = createTimer(now.plusMinutes(OfficeTimeoutMinutesMorning), [ |
            Office_Lamp_Left.sendCommand(officeLampValue1)
            Office_Lamp_Back.sendCommand(officeLampValue1)
            Office_Lamp_Right.sendCommand(officeLampValue1)
            Office_Lights.sendCommand(OFF)
            createTimer(now.plusSeconds(2),  [ |
                postUpdate(BYPASS_Office_LightsTimer, OFF)
            ])
            OfficeLightsTimer = null
        ])
1 Like

That part I understand. It is just that

OfficeLightsTimer(...)

Makes no sense. So what are you trying to do there? Set a timer? Reschedule a timer?

good catch. yes its meant to be rescheduling a timer so it should be the following, correct?

        		OfficeLightsTimer.reschedule(now.plusMinutes(OfficeTimeoutMinutesBed ))

Correct

@vzorglub
your awesome mate. this is the first rule that ive used variables in and I never thought to do it like that its very cleaver.

Next Why do you do this?
Same items twice with a Thread::Sleep in the middle?

		sendCommand(Office_Lamp_Left_Temp, "30")
		sendCommand(Office_Lamp_Back_Temp, "30")
		sendCommand(Office_Lamp_Right_Temp, "30")
		Thread::sleep(300)
		sendCommand(Office_Lamp_Left, "100")
		sendCommand(Office_Lamp_Back, "100")
		sendCommand(Office_Lamp_Right, "100")

the first value is setting the white point temperature and the 2nd is the brightness.

What is this supposed to do?

postUpdate(All_Lights, ON)

thats to do with other rules we have a goodnight rule that won’t fire If “all Lights” is on

Your code repeats again and again
Consider putting ALL the ones that have the timer===null is ONE if statement
Then
Consider using some variables and do your commands at the end of the rule:

tomorrow il go through it and redo the whole thing and hopefully have everything a lot better from what ive learnt here!

@vzorglub quick question. my line of thought is.

var Number Office_Desk_Lights_Temp 
var Number Office_Desk_Lights 
var Number Office_Main_Lights	
var Number officeLampValue3

val int Office_Timeout_Minutes_Morning = 60
val int Office_Timeout_Minutes_Day = 60
val int Office_Timeout_Minutes_Afternoon = 60
val int Office_Timeout_Minutes_Evening = 60
val int Office_Timeout_Minutes_Night = 60
val int Office_Timeout_Minutes_Bed = 5
val int Office_Timeout_Minutes_Use




rule "Office Light Timer"

when
	Item Office_Motion received update ON
then

if	(vTimeOfDay.state == "MORNING") {
		sendCommand(Office_Lights, 100)
		Office_Desk_Lights_Temp = 60)
		Office_Desk_Lights = 100)
		Office_Main_Lights = 100)
        	Office_Timeout_Minutes_Use = Office_Timeout_Minutes_Morning )
    		}

but will that work to copy the value of Office_Timeout_Minutes_Morning to Office_Timeout_Minutes_Use that way the new rule would tiny in comparison.

No, you need to declare Office_Timeout_Minutes_Use as a variable not a constant:

var int Office_Timeout_Minutes_Use

I couldn’t wait until tomorrow so here’s what ive got after 2 seconds of checking it seems to be working well.
thanks so much guys for your help ive learnt a lot with this rule and im amazed how much I was over complicating it as the new rule is heaps smaller than what I started with. tomorrow im going to create some more groups for the desk lights and that will save a few more lines of code!!.

var Number Office_Desk_Lights_Temp 
var Number Office_Desk_Lights 
var Number Office_Main_Lights	

var Number Office_Timeout_Minutes_Use

var Timer OfficeLightsTimer = null

val int Office_Timeout_Minutes_Morning = 60
val int Office_Timeout_Minutes_Day = 60
val int Office_Timeout_Minutes_Afternoon = 60
val int Office_Timeout_Minutes_Evening = 60
val int Office_Timeout_Minutes_Night = 60
val int Office_Timeout_Minutes_Bed = 5




rule "Auto Office Lights"

when
	Item Office_Motion received update ON
then

if	(vTimeOfDay.state == "MORNING") {
		Office_Desk_Lights_Temp = 60
		Office_Desk_Lights = 100
		Office_Main_Lights = 100
        	Office_Timeout_Minutes_Use = Office_Timeout_Minutes_Morning 
    		}

if	(vTimeOfDay.state == "DAY") {
		Office_Desk_Lights_Temp = 30
		Office_Desk_Lights = 100
		Office_Main_Lights = 100
        	Office_Timeout_Minutes_Use = Office_Timeout_Minutes_Day
    		}

if	(vTimeOfDay.state == "AFTERNOON") {
		Office_Desk_Lights_Temp = 30
		Office_Desk_Lights = 100
		Office_Main_Lights = 100
        	Office_Timeout_Minutes_Use = Office_Timeout_Minutes_Afternoon 
    		}

if	(vTimeOfDay.state == "EVENING") {
		Office_Desk_Lights_Temp = 40
		Office_Desk_Lights = 100
		Office_Main_Lights = 100
        	Office_Timeout_Minutes_Use = Office_Timeout_Minutes_Evening  
    		}

if	(vTimeOfDay.state == "NIGHT") {
		Office_Desk_Lights_Temp = 60
		Office_Desk_Lights = 100
		Office_Main_Lights = 100
        	Office_Timeout_Minutes_Use = Office_Timeout_Minutes_Night
    		}

if	(vTimeOfDay.state == "BED") {
		Office_Desk_Lights_Temp = 60
		Office_Desk_Lights = 60
		Office_Main_Lights = 60
        	Office_Timeout_Minutes_Use = Office_Timeout_Minutes_Bed 
    		}
if	((OfficeLightsTimer === null) && (BYPASS_Office_LightsTimer.state == OFF)) {
        	Office_Lights.sendCommand(Office_Main_Lights)
        	Office_Lamp_Left_Temp.sendCommand(Office_Desk_Lights_Temp)
       	 	Office_Lamp_Back_Temp.sendCommand(Office_Desk_Lights_Temp)
        	Office_Lamp_Right_Temp.sendCommand(Office_Desk_Lights_Temp)
		Thread::sleep(300)
        	Office_Lamp_Left.sendCommand(Office_Desk_Lights)
       	 	Office_Lamp_Back.sendCommand(Office_Desk_Lights)
        	Office_Lamp_Right.sendCommand(Office_Desk_Lights)
		postUpdate(All_Lights, ON)
    		createTimer(now.plusSeconds(2),  [ |
			postUpdate(BYPASS_Office_LightsTimer, OFF)
			])
        	OfficeLightsTimer = createTimer(now.plusMinutes(Office_Timeout_Minutes_Use ), [|
	        	Office_Lamp_Left.sendCommand(OFF)
 	      	 	Office_Lamp_Back.sendCommand(OFF)
        		Office_Lamp_Right.sendCommand(OFF)
        		Office_Lights.sendCommand(OFF)
    			createTimer(now.plusSeconds(2),  [ |
				postUpdate(BYPASS_Office_LightsTimer, OFF)
				])
           		OfficeLightsTimer = null
        		])
    		}
else 		{
    		(BYPASS_Office_LightsTimer.state == OFF) {
        	Office_Lights.sendCommand(Office_Main_Lights)
        	Office_Lamp_Left_Temp.sendCommand(Office_Desk_Lights_Temp)
       	 	Office_Lamp_Back_Temp.sendCommand(Office_Desk_Lights_Temp)
        	Office_Lamp_Right_Temp.sendCommand(Office_Desk_Lights_Temp)
		Thread::sleep(300)
        	Office_Lamp_Left.sendCommand(Office_Desk_Lights)
       	 	Office_Lamp_Back.sendCommand(Office_Desk_Lights)
        	Office_Lamp_Right.sendCommand(Office_Desk_Lights)
		postUpdate(All_Lights, ON)
    		createTimer(now.plusSeconds(2),  [ |
			postUpdate(BYPASS_Office_LightsTimer, OFF)
			])
        		OfficeLightsTimer.reschedule(now.plusMinutes(Office_Timeout_Minutes_Use ))
   	 	}
		}
end



rule "Bypass Auto Office Lights"
when 
	Item Office_Lights changed or
	Item Office_Lamp_Left changed or
	Item Office_Lamp_Back changed or
	Item Office_Lamp_Right changed
then
        BYPASS_Office_LightsTimer.sendCommand(ON)
    		createTimer(now.plusSeconds(5),  [ |
			if( BBYPASS_Office_LightsTimer.state == ON ) {
			OfficeLightsTimer = null
			}
			])
end

Looks much better
Next step, tidy up your indents.
I recommend using spaces (4) instead of tabs, so that is remains consistence across platform.
You code will be much easier to read

And use VSCode