I've been looking for the holy grail for years that would allow proprietary alarm systems (like vivint, alarm.com etc) to send one way notifications on the state of the system (alarms, arming, contact sensors, door lock state etc) to a smart hub from email notifications from the alarm service (since the IFTTT ability was lost). There seems to be a number of solutions out there, most of which require one of a paid subscription service, or a raspberry pi or some other always on devices, or a dedicated phone/tablet receiving push notifications that can trigger a listening app. Inspired by an old Reddit post by /Godbeard who wrote a gmail script that can do this natively within gmail (for IFFT triggers in that case), I've modified the code (my first foray into google app coding!) and written a simple script that will search my (dedicated) inbox every minute for a particular notification from alarm.com, and from that trigger a webhook in maker api. It may not be the entirely local, instantaneous holy grail, but I think it will work for me, and should be easy for anyone else to implement following these instructions. Yes I use the great ADC integration for system alarm control, but this specifically allows me to track current state of locks, door sensors or any number of other alarm.com devices on a hubitat dashboard or in rules. I'm attaching a link to the simple script if anyone else wants to try it. I'm in the process of writing a more complex one that will poll for the current status (most recent notification) on all 5 of my door locks. Will share when it's done.
1- Setup gmail tags on incoming email notifications
• Copy the subject line of the notification message
• Click the settings gear- "see all settings"- "Filters and Blocked Addresses"
• Create a new filter
○ Paste the copied text into the subject line and press create
○ Select "apply label" and create the label name you want applied.
• Now this label will be automatically applied when matching subject emails arrive
2- Setup the webhook URLs of the device you want triggered in Hubitat.
• Using maker api, add the devices you want to control.
• Be sure to enable cloud URLs. These are the webhook addresses you will use in the google script.
3- Create a Google app script
• Again settings gear- See all settings
• Select "add-ons" and click on "Apps Script"
• Press "New Project"
• Copy the script from the sample app, and paste it (over-write what is there) in the new script window.
• Rename it if you wish, and press save.
4- Customize the script
• Enter the exact text of the filter label you created in gmail as the TriggerLabel variable text (between the parentheses).
• Copy and paste the exact webhook URL from maker api to be triggered as the CalledAPI variable text (between the parentheses).
• Comment or uncomment the last 2 lines ( // is the comment symbol) as per your preference. You must chose at least one of these, or the script will not distinguish between old and new messages. Only one is needed.
○ Label.removeFromThreads will remove the label from the message, but not delete it.
○ GmailApp.moveThreadsToTrash will delete the message entirely after the script runs. This keeps the inbox cleaner.
5- Set-up the script to run
• Save and press "Run." You will need to grant permission for this untrusted (i.e. not reviewed and approved by google) script to run in your account the first time. Once approved, run a second time to test
• Click the clock icon- triggers, then "create a new trigger."
• Here you will specify when the script runs. Most often you will select a time interval for when you want it to run.
• That's it- get creative!