Rule does not trigger?

Hi,

I’m playing around with my small z-wave setup and can’t get my first test rule to work. For hardware I use Aeotec z-stick gen5 and a aeotec multisensor 6. The simple rule I’m trying to achieve is to get openHab to send me a mail when motion is detected. When the sensor changes from closed to open the mail never gets sent.

What am I doing wrong and how can I troublshoot to see if a rule has been triggerd?

default.rules:
import org.openhab.core.library.types.*
import org.openhab.core.persistence.*
import org.openhab.model.script.actions.*

rule "notify"
when
Item Motion_Sensor1 changed from CLOSED to OPEN
then
sendMail(“xxx@yyy.zzz”, “Motion detected!”, “OpenHAB has detected motion.”)
end

default.items:
Contact Motion_Sensor1 “Motion [MAP(motion.map):%s]” (gG1) { zwave=“3:command=sensor_binary,respond_to_basic=true” }

Edit: removed my mail address. from the code…

Hi,
Suggestion:
Create a imaginary item in the items file:
Number Help "Help [%s]"
Create a text in sitemaps:
Text "Help"
In rules send command instead of mail:
sendCommand(Help, “Works!”)
If you see “Works” in you UI then the rule works and problem is with the sendMail.
In later case you have to check here.
Cheers
Björn

exactly. break apart your issue into its core bindings.

since you have zwave and mail going on, make sure the zwave sensor triggers, and that the mail works. do like Bjorn suggests above and test the zwave working by sending the help. if that works its the mail. if it doesnt work, its either your rule, or your zwave. can you see the status of the multisensor on your sitemap, or do you just know its triggered from the LED?

Thanks, I added the following line in my default.items -file:
Number Help “Help [%s]” (gG1)

And edited the default.rules with this:

import org.openhab.core.library.types.*
import org.openhab.core.persistence.*
import org.openhab.model.script.actions.*
rule “notify”
when
Item Motion_Sensor1 changed from CLOSED to OPEN
then
sendCommand(Help, “Motion detected”)
sendMail(“xxx@yyy.zzz”, “Motion detected!”, “OpenHAB has detected motion”)
end

rule "notify2"
when
	Item Motion_Sensor1 changed from OPEN to CLOSED
then
	sendCommand(Help, "Motion gone...")
end

When looking at the group gG1 with the sesor not detecting motion I get the following output:

When the sesor detects motion this is what openHab outputs:

The green LED on the sensor does light up when it detects motion.

Is there an easy way to verify that sending mail works?

Just to try something I changed the default.rules to the following:

import org.openhab.core.library.types.*
import org.openhab.core.persistence.*
import org.openhab.model.script.actions.*

rule "notify"
when
Item Motion_Sensor1 received update
then
sendCommand(Help, “Motion detected”)
sendMail(“xxx@yyy.zzz”, “Motion detected!”, “OpenHAB has detected motion”)
end

rule "startup"
when
System started
then
sendMail(“xxx@yyy.zzz”, “System started”, “OpenHAB has started”)
end

rule "shutdown"
when
System shuts down
then
sendMail(“xxx@yyy.zzz”, “System shutting down”, “OpenHAB has started shut down”)
end

In my book that should trigger whenever the motion sensor is changed to closed or open and the other rules to trigger when openhab start up and shuts down. Still no mails :frowning: What am I missing? Do I have the correct includes? I just copied them from the demo-file.

(and how do I format the code nicely in the forum instead of plain text? :slight_smile: )

Before shuting down my lab to go to bed I noticed this in the command window:
2016-02-15 21:38:15.267 [ERROR] [o.o.c.s.ScriptExecutionThread ] - Error during the execution of rule ‘notify’: The name ‘sendMail(,,)’ cannot be resolved to an item or type.

Maybe a clue?

Hi Martin,
To help you, the following suggestion:
Cut down you code to

import org.openhab.core.library.types.*
import org.openhab.core.persistence.*
import org.openhab.model.script.actions.*

rule "notify"
when
Item Motion_Sensor1 received update
then
sendCommand(Help, “Motion detected”)
end

You see then in your text item the text “Motion detected”.
If you see only “-” then maybe something is not working in your item definition “Motion_Sensor1” or somewhere else.

Pls advise what addons you have implemented?

If this part works replace
"sendCommand(Help, “Motion detected”)" with
"sendMail(“xxx@yyy.zzz”, “Motion detected!”, “OpenHAB has detected motion”)".
If you then see the error[quote=“z-wave, post:6, topic:7501”]
Before shuting down my lab to go to bed I noticed this in the command window:2016-02-15 21:38:15.267 [ERROR] [o.o.c.s.ScriptExecutionThread ] - Error during the execution of rule ‘notify’: The name ‘sendMail(,)’ cannot be resolved to an item or type.
[/quote]
write again.
Cheers
Björn