Last active
July 17, 2019 15:41
-
-
Save drewB/7330b172d00364e067a91a95cf927695 to your computer and use it in GitHub Desktop.
headless chrome (puppeteer) script for arming Alarm.com panel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const puppeteer = require('puppeteer'); | |
var config; | |
config = { | |
username: 'username', | |
password: 'password' | |
}; | |
(async () => { | |
const browser = await puppeteer.launch({ | |
headless: true, | |
args: [ | |
'--remote-debugging-port=9222' | |
]}) | |
const page = await browser.newPage() | |
console.log('opening page...'); | |
await page.goto('https://www.alarm.com/login.aspx') | |
await page.type('input[name="ctl00$ContentPlaceHolder1$loginform$txtUserName"]', config.username) | |
await page.type('input[name="txtPassword"]', config.password) | |
await page.click('input[name="ctl00$ContentPlaceHolder1$loginform$signInButton"]') | |
console.log('filled form and clicked login'); | |
await page.waitForNavigation() | |
console.log("Signed in and ready to change arm state"); | |
await page.waitFor(10000) | |
await page.click('.disarmed.icon-circle') | |
console.log("Clicked Panel"); | |
await page.waitFor(10000) | |
console.log("Clicking silent arming checkbox"); | |
page.evaluate(function() {document.querySelectorAll('.disarmed [role="checkbox"] .binary-element')[1].click()}) | |
await page.click('.disarmed .armed-stay') | |
console.log("Arming...."); | |
await page.waitForFunction("document.querySelector('.card-info.armed-stay h4 span').textContent == 'Armed Stay'") | |
console.log("Alarm is now armed for stay.") | |
browser.close() | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment