Similar rules, only one checks item state correctly

OpenHAB 1.8.2. I have an issue where I have two rules that control my porch light - camera motion event which works, and door switch which doesn’t work. If I set status_night = true, then the camera motion event fires correctly (only turning on the porch light when night). If I open the front door, Contact01_FrontDoor_Basic changes to OPEN, but the porch light turns on whether status_night is true or false.

I’ve removed my .rules file and included only the below/tested. This still ignores Status_Night.state==ON in the “Front Door Opened, Porch light on” rule. Camera-motion rule still follows Status_Night.state.

I have Status_Night set to a switch in my sitemap, so I can test these easily. I have no idea why this basic rule file is causing me grief!

Other than trying to upgrade to v2 (again), is there some way I can resolve this? I don’t think I can narrow it down/troubleshoot further.

rules

import org.openhab.core.library.types.DateTimeType
import org.eclipse.xtext.xbase.lib.*

var Number intBulbBrightness = 100

rule "Sunrise" // Sets night-status to ON every morning
	when
	    Item Sunrise_Event received update ON
	then
		sendCommand(Status_Night, OFF)
end

rule "Sunset" // Sets night-status to ON every evening
	when
	    Item Sunset_Event received update ON
	then
		sendCommand(Status_Night, ON)
end

rule "Porch Motion" // Works at night only
	when
	    Item CamMotion_Porch received update ON
	then
		postUpdate(CamMotion_Porch, OFF)
		if (Status_Night.state==ON) {
			sendCommand(Dimmer_Porch, intBulbBrightness)
		}
end

rule "Front Door Opened, Porch light on" // Runs all day
	when
	    Item Contact01_FrontDoor_Basic received update OPEN
	then
		if (Status_Night.state==ON) {
			sendCommand(Dimmer_Porch, intBulbBrightness)
		} 
end

items

Switch CamMotion_Porch
Switch Sunrise_Event {astro="planet=sun, type=rise, property=start, offset=-5"}
Switch Sunset_Event {astro="planet=sun, type=set, property=end, offset=-30"}
Switch Status_Night
Dimmer Dimmer_Porch			{ zwave="5:command=SWITCH_MULTILEVEL,refresh_interval=30" }
Contact	Contact01_FrontDoor_Basic	{ zwave="22:command=basic,respond_to_basic=true" }

sitemap

sitemap default label="House"
{
	Frame {
		Switch item=Status_Night
		
	}
	
}

My camera-motion event:

curl --header "Content-Type: text/plain" --request PUT --data "ON" http://openhab:8080/rest/items/CamMotion_Porch/state

Try to use the method
Dimmer_Porch.sendCommand(intBulbBrightness)
instead of the action.
The same for your sunrise and sunset rules. The action is not always clear about the type of value you will send. The method knows directly wich format to prefer…

Is intBulbBrightness defined and within the correct value range?

Andreas

PS: just saw the intBulbBrightness definition… seems ok!

Using the dot-method is always good advice.

Try also adding logInfo to observe the progress of your rules when debugging e.g.

rule "Front Door Opened, Porch light on" // Runs all day
	when
	    Item Contact01_FrontDoor_Basic received update OPEN
	then
		logInfo("diag", "suspect rule triggered OK")
		if (Status_Night.state==ON) {
			logInfo("diag", "suspect rule thinks it is night")
			Dimmer_Porch.sendCommand(intBulbBrightness)
		} else {
			logInfo("diag", "suspect rule thinks it is day")
		}
end

I wonder if you have some other hidden rule at work too