Need some help with my first rule

The fact that you don’t see the logging implies the rule isn’t firing.

I’d also say that your motion sensor has an ON and OFF value rather than a OPEN or CLOSED value. Contact is more for window or door sensors. In fact, your log shows it is receiving ON or OFF, so you should probably use a switch then instead of a contact?

You could also try the rule as:

rule "Test motion sensor in spare room"
when
        Item SpareRoom_Motion_Sensor changed
then
       logInfo("_rule_","SpareRoom_Motion_Sensor")  
      // You have to see the above in the log, otherwise it means the 
      // rule was never triggered with the described condition.
       if (SpareRoom_Motion_Sensor.state == ON)
       {
               SpareRoom_Dimmer.sendCommand(0)
       }       
end

@boconnor may i ask on which system (windows/linux) you’re running your openHab and which editor you’re using.
I had thge same behavior when i was initially using notepad in windows for the job, not the best idea.
you can use the “Eclipse smarthome designer” (https://www.eclipse.org/smarthome/documentation/community/downloads.html) or the “openHAB VS Code Extension” (https://docs.openhab.org/configuration/editors.html#openhab-vscode) for editing roles, items, …

@Matt77
https://www.eclipse.org/smarthome/documentation/community/downloads.html#releases
Please note that the Designer has been deprecated is not part of the release anymore.

Yes

Than the rule doesn’t run.

For searching the problem you can define the items in a sitemap and changing the switch manually.

We know only that part of your configuration you have posted. Your z-wave definition und your items don’t match. If is’t a item you can use for example

    Item zwave_device_46feb3ec_node11_sensor_binary changed to ON

Just to check,
Did you save you items in a *.items file?

You have already created the items through the paper UI.
Remove the SpareRoom_Motion_Sensor from you items file.
and try:

rule "Test motion sensor in spare room"
when
        Item zwave_device_46feb3ec_node11_sensor_binary changed
then
       logInfo("_rule_","SpareRoom_Motion_Sensor")  
      // You have to see the above in the log, otherwise it means the 
      // rule was never triggered with the described condition.
       if (SpareRoom_Motion_Sensor.state == ON)
       {
               SpareRoom_Dimmer.sendCommand(0)
       }       
end

removed

removed

@vzorglub

It looks like a item-file.

Yes but are they saved in a *.items file like spareroom.items for example

Thanks everyone for so many helpful replies.
Changing the item from a contact to a switch solved it. Thanks @SkyyStorm. It is great to finally see my system spring to life, even if it’s just a toy example.

This gives me a working demonstration to further develop from. Hopefully I’ll be able to be independent for a little while at least now. I’m sure I’ll be back though.

1 Like

@hr3

Does this really work. If I use it I get an error in log.

I want to get a rule triggered if the thing gets an update but this rule is never triggered. Only difference is, that I use the thing not the item.

when
  Thing zwave_device_15a7a49f3a6_node3 received update
then
...
2018-03-14 10:08:23.011 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'einstellungen.rules' has errors, therefore ign
oring it: [20,3]: no viable alternative at input 'zwave_device_15a7a49f3a6_node3'

This one will work, but never triggered:

when
  Thing 'zwave_device_15a7a49f3a6_node3' received update
then
...

even if a log message indicates this:

2018-03-14 10:06:42.146 [me.event.ThingUpdatedEvent] - Thing 'zwave:device:15a7a49f3a6:node3' has been updated.

The triggers for rules are things channels and items not the things themselves, I don’t think that’s possible.
Define an item for a channel of the thing and use the item to trigger the rule.

@hr3
Thanks for teh reply. Can you guide me what I should do:

Should I do this? Without any channel? Because I cannot use a channel because this channel is not triggered only the thing itself. and if yes w hich item type should I user?

Contact DummyForTrigger "DummyForTrigger"	{channel="zwave:device:15a7a49f3a6:node3" }

This one which triggers the event of the channel when it happen, is not useful because if the door is not open for a long time no update.

Contact DummyForTrigger "DummyForTrigger" {channel="zwave:device:15a7a49f3a6:node3:sensor_door" }

The second one

Thanks, but the second one will not be triggered. This is why I need to get an trigger to the thing itself. Maybe it is not solvable.

See this post:

What sensor is it? A door sensor?
What channels for this thing get updated when you open/close the door?

My problem is, that I want to detect z-wave devices which are no longer sending datas.

For all of them I check battery item update event date. I get this configured for mostly all of my devices that they send this latest every 6h. Only for devices from aeon this is not relyable. They report battery item update randomly.
To detect item update on door open/close event does not fix it too because some doors are opened only some times a year. And event then I will notice or not, that the sensor does not report any more.

Hopefully it is clear what I want to reach.

In habmin I can see the last wakeon time, but don’t know how to get this into a rule.

So you want to see which things are online…
According the thread you have posted above:

This works for me (for online/offline state):

when 
	Thing "zwave:device:15ca6a108b9:node26" changed
then

Notice the double quotes…
Try that

yes, this will work for me too. But the thing is not changed, it is only updated :wink:

Changed is only from online to offline. And the device stays online even if it does not report any longer.

Only relyable from my point of view is to catch this message in a rule: But my rule does not get fired

2018-03-14 10:06:42.146 [me.event.ThingUpdatedEvent] - Thing 'zwave:device:15a7a49f3a6:node3' has been updated.

none of this works:

when
  Thing 'zwave_device_15a7a49f3a6_node3' received update or // from habmin
  Thing "zwave_device_15a7a49f3a6_node3" received update or // from habmin
  Thing 'zwave:device:15a7a49f3a6:node3' received update or // from log
  Thing "zwave:device:15a7a49f3a6:node3" received update // from log
then
...

I have read the previous thread regarding this.
There appear that there is no direct solution to you problem.

Reading the log file and catching the lines seems to be a way to go

See: