OS: Raspbian with OpenHABian running as package on top
Java Runtime Environment: OpenJDK version 9.0.4+12-Raspbian-4
openHAB version: 2.4.0-1
Issue of the topic:
I am writing rules using the DSL language in OpenHAB, and have stored these rules in the location suggested by https://www.openhab.org/docs/configuration/rules-dsl.html . When I check Paper UI to see if they are present, they do not appear. When I perform the action my rules are looking for, my smart devices do not respond.
a) Is them not appearing in Paper UI expected if added manually?
b) How can I troubleshoot my rules?
Code below for sanity purposes:
(network_pingdevice_[id]_online) is the name of my phone as given by REST API, with [id] replaced by the respective ID.
rule "Sense My Presence"
when
Item network_pingdevice_[id]_online changed from OFF to ON
then
HueLightSwitch.sendCommand(ON)
LifxLightSwitch.sendCommand(ON)
end
rule "Sense My Absence"
when
Item network_pingdevice_[id]_online changed from ON to OFF
then
HueLightSwitch.sendCommand(OFF)
LifxLightSwitch.sendCommand(OFF)
end
Best thing to troubleshoot your rules it to put logging statements into the rule and observe the log.
PaperUI exposes only the Next gen rule engine - that’s why you do not see the rules in PaperUI.
rule "Sense My Presence"
when
Item network_pingdevice_[id]_online changed from OFF to ON
then
logInfo("my rule", "item changed to ON")
HueLightSwitch.sendCommand(ON)
LifxLightSwitch.sendCommand(ON)
end
rule "Sense My Absence"
when
Item network_pingdevice_[id]_online changed from ON to OFF
then
logInfo("my rule", "item changed to OFF")
HueLightSwitch.sendCommand(OFF)
LifxLightSwitch.sendCommand(OFF)
end
The rules that PaperUI talks about are NGRE rules - New Generation Rules Engine, aka Experimental. These are incompatible with, and different from, DSL rules in xxx.rules files.
PaperUI knows nothing about xxx.rules and provides no viewer or editor for them at all.
to expand on what was said, to debug your rules you could look at the log file or, you can can ssh into the console and “watch” whats happening. Remembering how I struggled in the begining…
Download and install putty
open it and ssh to port 8101
default username and password is openhab / habopen
you should now see the welcome banner
now type log:tail and hit enter. You should now see the current events scrolling past.