Using "And" in a Rule

Rules trigger on events. Technically only one event can occur at all times. Every further logic goes inside the rule. Example:

rule "Garage Lights"
when
  Item Daylight changed to OFF
then
  if (Night.state == ON) {
		sendCommand(Garage_Left, HSBType::GREEN)
		sendCommand(Garage_Right, HSBType::RED)
  } 
end

For Night and more logic examples have a look Sun (raised / set) indicator - #7 by ThomDietrich

1 Like