Openhab Rules Not Triggering
In this tutorial, you'll learn about openhab rules not triggering. We cover key concepts, practical examples, and best practices.
Hook
You write an openHAB rule: when the motion sensor changes to ON, turn on the light. You test the motion sensor β it reports ON in the log. But the light stays off. The rule simply does not trigger.
The Wrong Way
Deleting and recreating the same rule with the same logic produces the same result β the issue is in the trigger configuration, not the rule's existence.
// BAD: Recreating the same rule
rule "Motion Light v2"
when
Item Motion_Sensor changed to ON
then
Light_Switch.sendCommand(ON)
end
Rule created: Motion Light v2
Motion sensor changed to ON β rule did not fire
Same logic, same result.
The Right Way
Check the rule's trigger conditions and logs to find why it does not fire.
# 1. Enable debug logging for rules
# In karaf console:
log:set DEBUG org.openhab.core.automation
# 2. Check openhab.log during a trigger event
tail -f /var/log/openhab/openhab.log | grep -i "rule\|motion\|trigger"
2026-06-24 10:00:00.000 [INFO ] [.core.automation] - Rule 'Motion Light' triggered by 'Motion_Sensor'
2026-06-24 10:00:00.000 [INFO ] [.core.automation] - Rule 'Motion Light': condition evaluation FAILED
The condition is failing, not the trigger.
// Check conditions in the rule
rule "Motion Light"
when
Item Motion_Sensor changed to ON
then
if (TimeOfDay.state == "NIGHT" || Hallway_Light.state != ON) {
Light_Switch.sendCommand(ON)
}
end
The condition TimeOfDay.state == "NIGHT" might be evaluating to NULL because the TimeOfDay item is not configured.
# 3. Fix: Add a null check or simplify the condition
rule "Motion Light"
when
Item Motion_Sensor changed to ON
then
Light_Switch.sendCommand(ON)
end
# 4. Test the trigger manually
# In Main UI β Rules β Select rule β Run Now
Rule executed: Light turned on
If "Run Now" works but the automatic trigger does not, the event bus is not delivering the update to the rule engine. Restart openHAB:
sudo systemctl restart openhab
Prevention
- Test rules with the "Run Now" button immediately after creation.
- Check rule condition logic for NULL states.
- Use simple rules first, add conditions incrementally.
- Enable debug logging for
org.openhab.core.automationduring development. - Use the Main UI rule editor's visual flow for complex logic.
Common Mistakes with rules not triggering
- Non-exhaustive pattern matches that compile with warnings then crash at runtime
- Misunderstanding that
Stringis[Char]with poor performance for large text operations - Using
foldlinstead offoldl'causing stack overflow on large lists
These mistakes appear frequently in real-world OPENHAB code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.
Practice Exercise
Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.
This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.
FAQ
DodaTech β rules that react the moment something happens.
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro