|
Post by chrisinkc on Mar 9, 2016 3:34:15 GMT
I am having a hard time getting my notifications working for my garage doors. I am using reed switches to tell me that the doors are open or closed. I have tried using several different Items in my Rules to store the state change info, but I can't seem to get it to post the update. Here is my Rule (the last one that I have tried):
rule "Garage Door 1 Notification"
when
Item garagedoor1 changed
then
if (garagedoor1 == OPEN)
{
sendNotification("xxxxxx@gmail.com", "Garage Door 1 has been Opened")
}
if (garagedoor1 == CLOSED)
{
sendNotification("xxxxxx@gmail.com", "Garage Door 1 is now Closed")
}
end
Here is the relevant info from my Items file:
// reed switch for garage door 1
Contact garagedoor1 "Garage Door 1 Status [%s]" <garagedoor> {mqtt="<[mosquitto:home/rfm_gw/nb/node02/dev42:state:OPEN:ON],<[mosquitto:home/rfm_gw/nb/node02/dev42:state:CLOSED:OFF]"}
// reed switch for garage door 2
Contact garagedoor2 "Garage Door 2 Status [%s]" <garagedoor> {mqtt="<[mosquitto:home/rfm_gw/nb/node02/dev41:state:OPEN:ON],<[mosquitto:home/rfm_gw/nb/node02/dev41:state:CLOSED:OFF]"}
Does anybody see any issues with this or see why it isn't working?
|
|
|
Post by computourist on Mar 9, 2016 10:46:22 GMT
Hi @chrisinc,
I use sendBroadcastNotification for my notifications to the openhab app. Works fine !
rule "notify OUT2" // send notification node 2 when Item STAT2 changed then var SimpleDateFormat df = new SimpleDateFormat( "dd-MM-YYYY HH:mm:ss" ) var String state = "Node 2 changed: " + df.format( new Date() ) sendBroadcastNotification(state ) end
|
|
|
Post by greginkansas on Mar 9, 2016 14:10:57 GMT
It might be your item. OPEN CLOSED - ON OFF
mqtt=">[mosquitto:home/rfm_gw/sb/node06/dev16:command:ON:ON],>[mosquitto:home/rfm_gw/sb/node06/dev16:command:OFF:OFF]" }
|
|
|
Post by papa on Mar 9, 2016 14:59:56 GMT
Presupposing that a check of both garage door reed switches is on node 2 & that those use devices 41 & 42, it looks to me like chrisinkc's items could be ok. Those items are mapping (translating) the ON/OFF states to OPEN/CLOSED AND are asking the node to send the reed states nb, northbound, via the Gateway. Similar contact items work for me.
This item mqtt clause ... mqtt=">[mosquitto:home/rfm_gw/sb/node06/dev16:command:ON:ON],>[mosquitto:home/rfm_gw/sb/node06/dev16:command:OFF:OFF]" } would send a command sb, southbound, to node 6 to change it's device 16's state.
Chris, try writing your rule's "if" clauses like if (garagedoor1.state == OPEN) if (garagedoor1.state == CLOSED) That form has worked for me in other regards
Another possibility ... If both reed switches are connected to node 2, you might disconnect one switch & see what happens (especially if you're trying to do anything else with node 2, esp trip a relay). If a relay is connected to node 2, try disconnecting it & see if one or two relay switches will work reliably. Sometimes the Arduino compatibles get tapped out on power & then glitches happen. I ended up putting my garage door opening relay & the reed switch on separate nodes.
|
|
|
Post by greginkansas on Mar 9, 2016 19:31:55 GMT
Yes I just grabbed one of my items it was a outbound one. This part :state:CLOSED:OFF]"} I think openhab is looking to get CLOSED from the msg, and changing it to OFF. And it never gets CLOSED it gets OFF from the node-gateway Try this :state:OFF:CLOSED]"} If not watch the log to see what it gets from the node.
|
|
|
Post by computourist on Mar 9, 2016 20:09:06 GMT
I use this code for sending notification on state changes:
rule "notify OUT6on" // send notification when Item STAT6 changed from CLOSED to OPEN then sendBroadcastNotification("Lights on" ) end
rule "notify OUT6off" // send notification when Item STAT6 changed from OPEN to CLOSED then sendBroadcastNotification("Lights off" ) end works fine...
|
|
|
Post by papa on Mar 9, 2016 20:14:26 GMT
My contact item is written like Chris' & my log shows the items' result as OPEN or CLOSED.
Another way to check greg's theory is change the rules to if (garagedoor1 == ON) ... if (garagedoor1 == OFF) ...
|
|
|
Post by greginkansas on Mar 9, 2016 22:04:02 GMT
Ah, Chris is using a Contact not a switch. I did not see any difference when starting and made all of mine switches.
|
|
|
Post by chrisinkc on Mar 10, 2016 3:44:47 GMT
I did what papa suggested and it worked! Adding the .state to garagedoor1 was what I was missing.
Thanks everyone for helping.
BTW papa, you asked what else I had running on this node. I had read your posts on your garage door node so I made sure not to overload mine. I have 3 nodes in the garage. 1 node has all of the sensors plus 2 reed switches. The other 2 nodes each have one SSR to open and close the 2 garage doors. There are no sensors on these 2 nodes; just the SSRs.
|
|
|
Post by papa on Mar 10, 2016 11:46:29 GMT
Thanks for your follow up report, Chris. I'm glad adding .state made it work so I assume that now your email notification is now also working, right?
Good to know that a node can handle 2 reed switches & more.
If I may ask, what sensors are on the node with the 2 reed switches?
|
|
|
Post by chrisinkc on Mar 10, 2016 20:32:42 GMT
My node with the 2 reed switches also has a DHT11, gas sensor, flame sensor, and a light sensor. Everything works well, except my flame sensor goes off once or twice a week. I have about decided the flame sensors are worthless as the smoke sensor would go off way before a flame actually reached the flame sensor...
The flame sensor would probably be better for an appliance, like a water heater, that has a pilot light, so you could be notified when the pilot light goes out.
|
|
kmac
New Member
Posts: 30
|
Post by kmac on Mar 10, 2016 21:26:58 GMT
I tried a flame sensor for that exact application (pilot light) but it didn't want to recognize the natural gas flame. Worked well with a butane lighter or anything burning like wood. I had to go with a heat sensor instead.
|
|