I keep finding documentation for rules for openhab, these do not work for openhab2 as I am getting errors like “the use of wildcards is depreciated” and “validation issues found”.
for example …
import org.openhab,core.library.types.* throws an error.
I simply want when “FRONT_DOOR_STATE” changes to “OPEN” to write in the log that it opened. I can not get it to fire no matter how I try to trigger it.
I tried even adding
when
item FRONT_DOOR_STATE received update
then
and it still will not trigger even if I try to write to the log right after the then. I assume my thing named “FRONT_DOOR_STATE” is what I use there?
Is there a “openhab rules for really big dummies that need to be spoon fed” document anywhere? as I just can not wrap my head around where I call things from what angle and what expected response I should be looking for?
Thanks for that help, I found that document and it is really lacking in any details. I’m looking for something very detailed.
For example… I have the following rule
rule “FrontDoor”
when
item FRONT_DOOR_STATE received update
then
logDebug("door,“door state changed”)
end
It follows all conventions that the documents say are perfect for a rule. but it refuses to run. I get in the log file…
Configuration door.rules has errors : no viable alternative at input ‘item’
FRONT_DOOR_STATE is the name of my item as defined in paper under items. it shows up on the control panel and switches from OPEN to CLOSED as I move the door. so it is working. but the rule refuses to even run.
what does it mean my an alternative input? none of the documents for rules talk about adding alternative inputs to items.
Tried that and the error goes away, but still nothing happening. nothing is being written to openhab.log
Although the documentation does not say a capitol I is needed, Maybe that is required in OpenHab2?
try to recreate the *.rule file from scratch
create a new file, type up the rule, delete the old file
maybe there is some kind of strange character or new line feed in the existing file that is stopping the rule from being processed (not sure… worth a try)
by the way: Are you sure that this is the Item name (and not the label?). You need to use the name. Can you post a screenshot of PaperUI showing the Item?
Usually OH2 gives other kind of Item names when they are auto-created (was this one auto-created or you defined it manually in PaperUI?)
If you defined it manually: Did you link it to a channel of a Thing?
That means I have to use that obscure "DoorWindowSensor_BinarySensor? when I have 10 of them that will get very confusing as to what sensor is on what door.
I know
That’s why I use *.items files
You are right… the docs entry is not very clear regarding the Item name but this is what you need to use for the trigger condition. This is what gets status updates from OH2.
You can see the state of your items using either the console or the REST API (you need to have the REST Docs installed under Addons->Misc)
with console ssh openhab@localhost -p 8101 (with password: habopen)
Ok, so I am in the same boat. Why can’t the docs be clear on this?
Anyways, I am trying to get the syntax of an Item correctly.
The Item is either: omnilink:zone:4515ad84:3:contact OR omnilink_zone_4515ad84_3_contact . The item iself in PaperUI is: omnilink:zone:4515ad84:3 and under the channel for contact is: omnilink:zone:4515ad84:3:contact.
Neither work. The common label is: Zones_Den_Door_Current. Doesn’t work either.
Tried quotes around the 'omni…". Didn’t work either.
Why does this have to be #1 so difficult and #2 so poorly documented?
Here’s an example of the log of contact 1. Contact 3 works fine live in PaperUI, etc; state changes immediately when door open and closed. So its not the binding. Every error log has issues with the syntax of the WHEN argument. Specifically, it can’t figure out that the ‘item’ actually is because the syntax is wrong. Do I need quotes? Do I need blahblah_1_contact.state? Help!
2018-02-25 20:56:25.278 [ItemStateChangedEvent ] - omnilink_zone_4515ad84_1_current_condition changed from 0 to 1
2018-02-25 20:56:27.578 [ItemStateChangedEvent ] - omnilink_zone_4515ad84_1_contact changed from OPEN to CLOSED
2018-02-25 20:56:27.579 [ItemStateChangedEvent ] - omnilink_zone_4515ad84_1_current_condition changed from 1 to 0
2018-02-25 21:02:14.590 [ItemStateChangedEvent ] - omnilink_zone_4515ad84_1_contact changed from CLOSED to OPEN
2018-02-25 21:02:14.592 [ItemStateChangedEvent ] - omnilink_zone_4515ad84_1_current_condition changed from 0 to 1
2018-02-25 21:02:25.590 [ItemStateChangedEvent ] - omnilink_zone_4515ad84_1_contact changed from OPEN to CLOSED
2018-02-25 21:02:25.590 [ItemStateChangedEvent ] - omnilink_zone_4515ad84_1_current_condition changed from 1 to 0
2018-02-25 21:03:10.291 [ItemStateChangedEvent ] - omnilink_zone_4515ad84_1_contact changed from CLOSED to OPEN
2018-02-25 21:03:10.293 [ItemStateChangedEvent ] - omnilink_zone_4515ad84_1_current_condition changed from 0 to 1
2018-02-25 21:03:21.891 [ItemStateChangedEvent ] - omnilink_zone_4515ad84_1_contact changed from OPEN to CLOSED
2018-02-25 21:03:21.892 [ItemStateChangedEvent ] - omnilink_zone_4515ad84_1_current_condition changed from 1 to 0
2018-02-25 21:03:23.291 [ItemStateChangedEvent ] - omnilink_zone_4515ad84_1_contact changed from CLOSED to OPEN
2018-02-25 21:03:23.293 [ItemStateChangedEvent ] - omnilink_zone_4515ad84_1_current_condition changed from 0 to 1
2018-02-25 21:03:25.592 [ItemStateChangedEvent ] - omnilink_zone_4515ad84_1_contact changed from OPEN to CLOSED
import java.net.URLEncoder
import java.net.URI
rule "Den Door Contact Open"
when
Item omnilink_zone_4515ad84_3_current_condition changed from 0 TO 1
then
{
logDebug("DenDoorContact","CLOSED TO OPEN")
sendHttpGetRequest("http://172.16.1.136:3480/data_request?id=lu_action&output_format=json&DeviceNum=165&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=1")
}
end
rule "Den Door Contact Closed"
when
Item omnilink_zone_4515ad84_3_current_condition changed from 1 TO 0
then
{
logDebug("DenDoorContact","OPEN TO CLOSED")
sendHttpGetRequest("http://172.16.1.136:3480/data_request?id=lu_action&output_format=json&DeviceNum=165&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=0")
}
end
Ignore the syntax for the item above; it doesn’t work. If tried it with and without the quotes, and also as omnilink_zone_4515ad84_3_contact and OPEN TO CLOSE
Any help would be greatly appreciated. I’ve got 17 of these to do. Thanks!
2018-02-26 22:34:34.043 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'security.rules'
2018-02-26 22:34:44.486 [ERROR] [.script.engine.ScriptExecutionThread] - Rule 'Den Door Contact Open': An error occurred during the script execution: The name 'triggeringItem' cannot be resolved to an item $
2018-02-26 22:34:46.754 [ERROR] [.script.engine.ScriptExecutionThread] - Rule 'Den Door Contact Open': An error occurred during the script execution: The name 'triggeringItem' cannot be resolved to an item $
2018-02-26 22:34:48.039 [ERROR] [.script.engine.ScriptExecutionThread] - Rule 'Den Door Contact Open': An error occurred during the script execution: The name 'triggeringItem' cannot be resolved to an item $
2018-02-26 22:34:50.446 [ERROR] [.script.engine.ScriptExecutionThread] - Rule 'Den Door Contact Open': An error occurred during the script execution: The name 'triggeringItem' cannot be resolved to an item $
Didn’t work/ Copied exactly as stated.
This doesn’t work either, but don’t get an error…
rule "Den Door Contact Open"
when
Item omnilink_zone_4515ad84_3_current_condition changed
then
if (omnilink_zone_4515ad84_3_current_condition.state==OPEN) {
debugInfo ("Condition","open")
sendHttpGetRequest("http://172.16.1.136:3480/data_request?id=lu_action&output_format=json&DeviceNum=165&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=1")
debugInfo ("Condition","open sent commandd")
} else if (omnilink_zone_4515ad84_3_current_condition.state==CLOSED) {
sendHttpGetRequest("http://172.16.1.136:3480/data_request?id=lu_action&output_format=json&DeviceNum=165&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=0")
}
end
Any help? (if then examples taken from multiple openhab2 articles with examples on this site)…