Smart Mailbox App

smartapp_alerts

(Edgar Santana) #1

Hi Folks - I am a novice at creating apps but I wanted to create a smartapp that would let me know when mail was delivered to my mailbox by just using a plain vanilla open and close sensor. So I added a Aeon Labs Aeotec Z-Wave Door/Window Sensor, 2nd Edition (DSB29-ZWUS) which I won on ebay for $20 in my mail box and created a simple smart app to do that. If you anyone wants to improve, please free free.

I’ve placed the code on github - https://github.com/ersantana3/Smart-Mail-Box/


(Jeff DeWolfe) #2

Is this any different than the SmartThings app called “Mail Arrived”? You can find it under the “Convenience” section in the ST app.


(Edgar Santana) #3

Similar concept but different way of arriving to the goal. The Mail Arrived smart app will send a text when mail arrives in your mailbox using SmartSense Multi on your mailbox door. To use this app you must have the SmartSense Multi which uses detected acceleration to only send you a text. This app allows you to use any door/window sensor using the opening of the mailbox to send you a push notification to you phone. I plan to add the text feature as soon as I learn how to do that.


(Edgar Santana) #4

Add SMS. You now have either/or both Push and SMS notifications. Also added minimum time between messages.


(Mike) #5

I won’t be home to try this for a few days but does it work with the ST multi sensor? I already have one of those on my mailbox. I hate how I get alerts from mystery motion on mine and like the minimum time feature you added so I don’t get another alert because I opened the mailbox 60 seconds after the mailman put the mail in there.


(Edgar Santana) #6

It does - ST Multi Sensor is a Contact Sensor plus all the other things it does. I also just checked the app w/ my ST Multi Sensor and you can select it as an option. You should be all set…


(Mike) #7

Cool, thanks! I figured it would work but thought I’d ask just in case the app was looking for a different device type. I’ve just installed it so let’s see if the post office actually honors my mail hold request this time (last time I traveled they ignored it).


(Mike) #8

So interestingly this actually doesn’t work for me. I can see in the mailbox activity log that the mailbox correctly registers as opening and closing but I don’t get a notification when it opens. I’ve tried both SMS and push notifications and there’s no change. And I know it’s associated with the correct device because I’m editing it from the device after I check that the open/close registered. It’s also not limited to any modes.


(Edgar Santana) #9

Who makes the device? Did you try uninstalling and reinstalling. Still working great for me. I am a newbie and just whipped this up learning to code on the fly. Can anyone provide possble solutions?


(Mike) #10

It’s the ST multi device: https://shop.smartthings.com/#!/products/smartsense-multi

I just uninstalled and reinstalled it, no change. I also tried associating it with the Aeon sensor I have on one of my doors and it didn’t fire with that either. When I switch back to the old mailbox app it works instantly, but looking through the code on that one it looks like it’s triggered by acceleration rather than open/close (which is also the reason I don’t like that one). Here’s the data logged when my mailbox is opened and I’m running the other app. Farther down is the log when I’m running your app and I’ve bolded the lines which might be relevant (I’m using SMS, not push notifications).

e0cf23f1-b20e-4788-b6e7-75cf1be4169f 10:50:00 AM: debug Parse returned [Mailbox was closed, Mailbox was inactive, Mailbox was 56°F, Mailbox Battery was 38%, Mailbox was -64 dBm, Mailbox Signal (LQI) was: 100%]
e0cf23f1-b20e-4788-b6e7-75cf1be4169f 10:49:57 AM: debug Parse returned [Mailbox was -61 dBm, Mailbox Signal (LQI) was: 100%, Mailbox was 832,604,16]
e0cf23f1-b20e-4788-b6e7-75cf1be4169f 10:49:54 AM: debug Parse returned [Mailbox was -61 dBm, Mailbox Signal (LQI) was: 100%, Mailbox was 832,605,18]
e42df423-e90e-44c3-b18c-bc0fd1681ad7 10:49:51 AM: debug event happened zw device: 0E, command: 2001, payload: 00
e42df423-e90e-44c3-b18c-bc0fd1681ad7 10:49:51 AM: debug preferences state null
240e2b3b-26c6-45e9-a180-d801b5d462f6 10:49:51 AM: trace contactHandler(contact: closed), notifyWhen: [Open]
a014fe17-310f-451b-91e9-6be594d22918 10:49:51 AM: trace contactHandler(contact: closed), notifyWhen: Open
e42df423-e90e-44c3-b18c-bc0fd1681ad7 10:49:51 AM: debug preferences state null
e0cf23f1-b20e-4788-b6e7-75cf1be4169f 10:49:51 AM: debug Parse returned [Mailbox was -60 dBm, Mailbox Signal (LQI) was: 100%, Mailbox was 831,603,16]
e81f7ded-e4f7-4133-8b25-cb4be297808f 10:49:49 AM: debug acceleration Event data successfully posted
e81f7ded-e4f7-4133-8b25-cb4be297808f 10:49:49 AM: debug contact Event data successfully posted
e42df423-e90e-44c3-b18c-bc0fd1681ad7 10:49:49 AM: debug event happened zone status 0x0030 – extended status 0x00
e42df423-e90e-44c3-b18c-bc0fd1681ad7 10:49:49 AM: debug preferences state null
e42df423-e90e-44c3-b18c-bc0fd1681ad7 10:49:49 AM: debug preferences state null
e0cf23f1-b20e-4788-b6e7-75cf1be4169f 10:49:48 AM: debug Parse returned Mailbox was closed
e0cf23f1-b20e-4788-b6e7-75cf1be4169f 10:49:48 AM: debug Parse results for Mailbox: [name:contact, value:closed, unit:null, linkText:Mailbox, descriptionText:Mailbox was closed, handlerName:closed, isStateChange:true, displayed:true]
46f01851-5faf-42cd-b693-05ee98e81b9f 10:49:48 AM: debug Mailbox has moved, texting ##phonenumberremoved##*
46f01851-5faf-42cd-b693-05ee98e81b9f 10:49:48 AM: trace Found 2 events in the last 5 seconds
46f01851-5faf-42cd-b693-05ee98e81b9f 10:49:48 AM: trace active: physicalgraph.app.EventWrapper@b80a4bf, [accelerationSensor:Mailbox, pushNotification:false, phone1:##phonenumberremoved##]
e0cf23f1-b20e-4788-b6e7-75cf1be4169f 10:49:48 AM: debug Parse returned [Mailbox was active, Mailbox was -63 dBm, Mailbox Signal (LQI) was: 100%]
e81f7ded-e4f7-4133-8b25-cb4be297808f 10:49:48 AM: debug contact Event data successfully posted
e42df423-e90e-44c3-b18c-bc0fd1681ad7 10:49:48 AM: debug event happened zone status 0x0031 – extended status 0x00
e42df423-e90e-44c3-b18c-bc0fd1681ad7 10:49:48 AM: debug preferences state null
e42df423-e90e-44c3-b18c-bc0fd1681ad7 10:49:48 AM: debug preferences state null
e0cf23f1-b20e-4788-b6e7-75cf1be4169f 10:49:47 AM: debug Parse returned Mailbox was opened
e0cf23f1-b20e-4788-b6e7-75cf1be4169f 10:49:47 AM: debug Parse results for Mailbox: [name:contact, value:open, unit:null, linkText:Mailbox, descriptionText:Mailbox was opened, handlerName:opened, isStateChange:true, displayed:true]
e42df423-e90e-44c3-b18c-bc0fd1681ad7 10:49:46 AM: debug event happened zw device: 06, command: 9881, payload: 00 71 05 16 01 00 FF 06 02 00
e42df423-e90e-44c3-b18c-bc0fd1681ad7 10:49:46 AM: debug preferences state null
e42df423-e90e-44c3-b18c-bc0fd1681ad7 10:49:46 AM: debug preferences state null
a014fe17-310f-451b-91e9-6be594d22918 10:49:46 AM: trace scheduled check in 93 msec
a014fe17-310f-451b-91e9-6be594d22918 10:49:46 AM: trace Scheduling ‘openCheck’ for InstalledSmartApp: a014fe17-310f-451b-91e9-6be594d22918
a014fe17-310f-451b-91e9-6be594d22918 10:49:45 AM: trace contactHandler(contact: open), notifyWhen: Open
e42df423-e90e-44c3-b18c-bc0fd1681ad7 10:49:46 AM: debug event happened zw device: 0E, command: 2001, payload: FF
e42df423-e90e-44c3-b18c-bc0fd1681ad7 10:49:45 AM: debug preferences state null
240e2b3b-26c6-45e9-a180-d801b5d462f6 10:49:45 AM: trace Not sending alert
240e2b3b-26c6-45e9-a180-d801b5d462f6 10:49:45 AM: trace modeOk = false
240e2b3b-26c6-45e9-a180-d801b5d462f6 10:49:45 AM: trace contactHandler(contact: open), notifyWhen: [Open]
e42df423-e90e-44c3-b18c-bc0fd1681ad7 10:49:45 AM: debug preferences state null
10:49:33 AM: info Waiting on events…

Here’s the log when I’m running your app:

e81f7ded-e4f7-4133-8b25-cb4be297808f 10:57:15 AM: debug acceleration Event data successfully posted
e0cf23f1-b20e-4788-b6e7-75cf1be4169f 10:57:12 AM: debug Parse returned [Mailbox was -63 dBm, Mailbox Signal (LQI) was: 100%, Mailbox was 831,603,18]
e0cf23f1-b20e-4788-b6e7-75cf1be4169f 10:57:09 AM: debug Parse returned [Mailbox was -62 dBm, Mailbox Signal (LQI) was: 100%, Mailbox was 832,604,17]
a014fe17-310f-451b-91e9-6be594d22918 10:57:07 AM: trace contactHandler(contact: closed), notifyWhen: Open
e42df423-e90e-44c3-b18c-bc0fd1681ad7 10:57:07 AM: debug event happened zw device: 0E, command: 2001, payload: 00
e42df423-e90e-44c3-b18c-bc0fd1681ad7 10:57:07 AM: debug preferences state null
240e2b3b-26c6-45e9-a180-d801b5d462f6 10:57:07 AM: trace contactHandler(contact: closed), notifyWhen: [Open]
e42df423-e90e-44c3-b18c-bc0fd1681ad7 10:57:07 AM: debug preferences state null
e0cf23f1-b20e-4788-b6e7-75cf1be4169f 10:57:06 AM: debug Parse returned [Mailbox was -60 dBm, Mailbox Signal (LQI) was: 100%, Mailbox was 832,602,16]
e81f7ded-e4f7-4133-8b25-cb4be297808f 10:57:04 AM: debug contact Event data successfully posted
e81f7ded-e4f7-4133-8b25-cb4be297808f 10:57:04 AM: debug acceleration Event data successfully posted
e42df423-e90e-44c3-b18c-bc0fd1681ad7 10:57:04 AM: debug event happened zone status 0x0030 – extended status 0x00
e42df423-e90e-44c3-b18c-bc0fd1681ad7 10:57:04 AM: debug preferences state null
e42df423-e90e-44c3-b18c-bc0fd1681ad7 10:57:04 AM: debug preferences state null
e0cf23f1-b20e-4788-b6e7-75cf1be4169f 10:57:04 AM: debug Parse returned Mailbox was closed
e0cf23f1-b20e-4788-b6e7-75cf1be4169f 10:57:04 AM: debug Parse results for Mailbox: [name:contact, value:closed, unit:null, linkText:Mailbox, descriptionText:Mailbox was closed, handlerName:closed, isStateChange:true, displayed:true]
e0cf23f1-b20e-4788-b6e7-75cf1be4169f 10:57:03 AM: debug Parse returned [Mailbox was active, Mailbox was -59 dBm, Mailbox Signal (LQI) was: 100%]
e81f7ded-e4f7-4133-8b25-cb4be297808f 10:57:03 AM: debug contact Event data successfully posted
4a6ad33b-f73d-4fb9-bb7c-39ac261a9836 10:57:03 AM: debug sending SMS
4a6ad33b-f73d-4fb9-bb7c-39ac261a9836 10:57:03 AM: debug contact:open, pushAndPhone:No, 'Mail Arrived…'
e42df423-e90e-44c3-b18c-bc0fd1681ad7 10:57:03 AM: debug event happened zone status 0x0031 – extended status 0x00
e42df423-e90e-44c3-b18c-bc0fd1681ad7 10:57:03 AM: debug preferences state null
e42df423-e90e-44c3-b18c-bc0fd1681ad7 10:57:03 AM: debug preferences state null
e0cf23f1-b20e-4788-b6e7-75cf1be4169f 10:57:03 AM: debug Parse returned Mailbox was opened
e0cf23f1-b20e-4788-b6e7-75cf1be4169f 10:57:03 AM: debug Parse results for Mailbox: [name:contact, value:open, unit:null, linkText:Mailbox, descriptionText:Mailbox was opened, handlerName:opened, isStateChange:true, displayed:true]
e81f7ded-e4f7-4133-8b25-cb4be297808f 10:57:00 AM: debug temperature Event data successfully posted
e81f7ded-e4f7-4133-8b25-cb4be297808f 10:57:00 AM: debug battery Event data successfully posted
e42df423-e90e-44c3-b18c-bc0fd1681ad7 10:57:00 AM: debug event happened contactState: 0, accelerationState: 0, temp: 173, battery: 1B, rssi: 59, lqi: 255
e42df423-e90e-44c3-b18c-bc0fd1681ad7 10:57:00 AM: debug preferences state null
e42df423-e90e-44c3-b18c-bc0fd1681ad7 10:57:00 AM: debug event happened contactState: 0, accelerationState: 0, temp: 173, battery: 1B, rssi: 59, lqi: 255
e42df423-e90e-44c3-b18c-bc0fd1681ad7 10:57:00 AM: debug preferences state null
db7046e8-df23-4a53-8866-cc2343050f25 10:57:00 AM: debug lowBatteryHandler: Dryer battery is 63
a014fe17-310f-451b-91e9-6be594d22918 10:57:00 AM: trace scheduled check in 122 msec
a014fe17-310f-451b-91e9-6be594d22918 10:57:00 AM: trace Scheduling ‘openCheck’ for InstalledSmartApp: a014fe17-310f-451b-91e9-6be594d22918
a014fe17-310f-451b-91e9-6be594d22918 10:57:00 AM: trace contactHandler(contact: open), notifyWhen: Open
e42df423-e90e-44c3-b18c-bc0fd1681ad7 10:57:00 AM: debug preferences state null
e42df423-e90e-44c3-b18c-bc0fd1681ad7 10:57:00 AM: debug preferences state null
b5d0ea28-8de7-45ef-8a53-1130f41b7dda 10:57:00 AM: debug Parse returned [Dryer was closed, Dryer was inactive, Dryer was 63°F, Dryer Battery was 63%, Dryer was -69 dBm, Dryer Signal (LQI) was: 100%]
e42df423-e90e-44c3-b18c-bc0fd1681ad7 10:57:00 AM: debug event happened zw device: 0E, command: 2001, payload: FF
e42df423-e90e-44c3-b18c-bc0fd1681ad7 10:57:00 AM: debug preferences state null
240e2b3b-26c6-45e9-a180-d801b5d462f6 10:57:00 AM: trace Not sending alert
240e2b3b-26c6-45e9-a180-d801b5d462f6 10:57:00 AM: trace modeOk = false
240e2b3b-26c6-45e9-a180-d801b5d462f6 10:57:00 AM: trace contactHandler(contact: open), notifyWhen: [Open]
e42df423-e90e-44c3-b18c-bc0fd1681ad7 10:57:00 AM: debug preferences state null
10:56:48 AM: info Waiting on events…


(Mike) #11

So this is inexplicably working now. I’m not sure what changed, I guess the 3rd time is a charm?


(Edgar Santana) #12

Glad it all worked out. FYI - we are getting hit with some really cold weather in
NY. I believe extreme cold weather can affect the door/window sensors. Mine hasnt had an issue yet but my neighbor is having issues with his mailbox, outside shed and fence gate sensors.


(Edgar Santana) #13

Thought it might be helpful to post photos of how it looks in smartthings app…


(Marc) #14

I’ve been using the Smart Mailbox app with my multi-sensor but here in the NorthEast, we’ve had very windy, cold days and it’s shaking my mailbox causing it to tell me Mail has Arrived inadvertently. I am wondering if you can read different levels of acceleration since it seems sensitive to the wind shaking the mailbox, or is it just a Yes or No option? If so, then I might need to use it as door/open sensor.


(Edgar Santana) #15

just a open close option.


(JimMay3) #16

That’s an expensive sensor to tell you when a tilt (hinged) door opens…

Try below for under $30, and very reliable in wind and cold:


(Edgar Santana) #17

I am constantly on ebay looking for deals, came across this door sensor: http://www.ebay.com/itm/Ecolink-Z-Wave-Door-Window-Sensor-White-Brown-Cases-OPEN-BOX-/111576870485


(Tom Steele) #18

http://www.ebay.com/itm/Ecolink-Z-Wave-Door-Window-Sensor-White-Brown-Case/111820930583?_trksid=p2047675.c100011.m1850&_trkparms=aid%3D222007%26algo%3DSIC.MBE%26ao%3D1%26asc%3D36467%26meid%3Df223b90e19cd4afa9dd7bbb572aaf52c%26pid%3D100011%26rk%3D1%26rkt%3D5%26sd%3D111576870485