Arlo|Smart Home Security|Wireless HD Security Cameras

Reply
Discussion stats
  • 18 Replies
  • 10968 Views
  • 6 Likes
  • 5 In Conversation
paulsmitz
Apprentice
Apprentice

OK I am sick of waiting for IFTTT so I have decided to roll my own...

 

Here is where I am up to:

 

Raspberry PI 2 running minibian on a 2gb sd card

 

Selenium recording of the login and mode change (This works perfectly!) Exported in Python see below:

 

# -*- coding: utf-8 -*-
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import NoSuchElementException
from selenium.common.exceptions import NoAlertPresentException
import unittest, time, re

class SetAllAlertsOn(unittest.TestCase):
    def setUp(self):
        self.driver = webdriver.Firefox()
        self.driver.implicitly_wait(30)
        self.base_url = "https://arlo.netgear.com/"
        self.verificationErrors = []
        self.accept_next_alert = True
    
    def test_set_all_alerts_on(self):
        driver = self.driver
        driver.get(self.base_url + "/#/login")
        driver.find_element_by_id("userId").clear()
        driver.find_element_by_id("userId").send_keys("***USERNAME***")
        driver.find_element_by_id("password").clear()
        driver.find_element_by_id("password").send_keys("***PASSWORD***")
        driver.find_element_by_id("loginButton").click()
        for i in range(60):
            try:
                if driver.find_element_by_xpath("//div[@id='footerButtonModes']/div").is_displayed(): break
            except: pass
            time.sleep(1)
        else: self.fail("time out")
        driver.find_element_by_xpath("//div[@id='footerButtonModes']/div").click()
        driver.find_element_by_xpath("//div[3]/div[2]/div").click()
        driver.find_element_by_xpath("//span").click()
    
    def is_element_present(self, how, what):
        try: self.driver.find_element(by=how, value=what)
        except NoSuchElementException, e: return False
        return True
    
    def is_alert_present(self):
        try: self.driver.switch_to_alert()
        except NoAlertPresentException, e: return False
        return True
    
    def close_alert_and_get_its_text(self):
        try:
            alert = self.driver.switch_to_alert()
            alert_text = alert.text
            if self.accept_next_alert:
                alert.accept()
            else:
                alert.dismiss()
            return alert_text
        finally: self.accept_next_alert = True
    
    def tearDown(self):
        self.driver.quit()
        self.assertEqual([], self.verificationErrors)

if __name__ == "__main__":
    unittest.main()

You may need to change this line:

 

        driver.find_element_by_xpath("//div[3]/div[2]/div").click()

 

But I guarantee it is easier to record your own on firefox: (download here)

http://release.seleniumhq.org/selenium-ide/2.9.0/

 

I then export using python webdriver and then add this bit in (waits for the mode button to appear)

 

        for i in range(60):
            try:
                if driver.find_element_by_xpath("//div[@id='footerButtonModes']/div").is_displayed(): break
            except: pass
            time.sleep(1)
        else: self.fail("time out")

 

I then saved this as ArloSetAllAlertsOn.py

 

Then on the raspberry Pi I logged in and ran:

apt-get install python-setuptools
pip install selenium
apt-get install xvfb
apt-get install iceweasel
Xvfb :99 -ac &
export DISPLAY=:99

I can now run:

 

python ArloCamerasAllOn.py and it will change the camera's mode! 🙂

 

now all I need to do is:

 

create a second script for my other mode

create a secured webserver in python which calls that test

setup dyndns account and setup the raspberry pi to report my IP to that

Forward the correct ports on my router

create an IFTTT maker channel which calls that webserver when my thermostat detects we are away

create an IFTTT maker channel which calls that webserver when my thermostat detects we are home

 

not much more left to do really... perhaps another evening or 2 and it will be working the way I hoped in the beginning with ***multi person*** Geofencing

 

1 ACCEPTED SOLUTION

Accepted Solutions
18 REPLIES 18
paulsmitz
Apprentice
Apprentice

so as before run this:

 

apt-get install python-setuptools
pip install selenium
apt-get install xvfb
apt-get install iceweasel
Xvfb :99 -ac &
export DISPLAY=:99

 

I now have a webserver! and I am using Bottle for that which you can install with the command below 🙂

 

 

pip install bottle

 

 

 

Code: (Replace *** USERNAME *** and *** Password ***)

 

 

# -*- coding: utf-8 -*-
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import NoSuchElementException
from selenium.common.exceptions import NoAlertPresentException
from bottle import route, run, template
import unittest, time, re, os

@route('/<name>')
def index(name):
    os.environ["DISPLAY"] = ":99"
    driver = webdriver.Firefox()
    driver.implicitly_wait(5)
    base_url = "https://arlo.netgear.com/"
    accept_next_alert = True
    driver.get(base_url + "/#/login")
    driver.find_element_by_id("userId").clear()
    driver.find_element_by_id("userId").send_keys("*** USERNAME ***")
    driver.find_element_by_id("password").clear()
    driver.find_element_by_id("password").send_keys("***PASSWORD***")
    driver.find_element_by_id("loginButton").click()
    
    for i in range(10):
        try:
            if driver.find_element_by_xpath("//div[@id='footerButtonModes']").is_displayed():
                break
        except: pass
        time.sleep(1)
    else:
        return template('<b>Sorry {{name}}</b>!', name=name)
    driver.find_element_by_xpath("//div[@id='footerButtonModes']").click()

    for i in range(3):
        time.sleep(1)

    if name == 'mode0':
        driver.find_element_by_xpath("//div[3]/div[2]/div").click()
        driver.find_element_by_xpath("//span").click()
        driver.quit()
        return template('<b>Hello {{name}}</b>!', name=name)
    elif name == 'mode1':
        driver.find_element_by_xpath("//div[3]/div[2]/div[2]").click()
        driver.find_element_by_xpath("//span").click()
        driver.quit()
        return template('<b>Hello {{name}}</b>!', name=name)
    elif name == 'mode2':
        driver.find_element_by_xpath("//div[2]/div[3]").click()
        driver.find_element_by_xpath("//span").click()
        driver.quit()
        return template('<b>Hello {{name}}</b>!', name=name)
    elif name == 'mode3':
        driver.find_element_by_xpath("//div[4]").click()
        driver.find_element_by_xpath("//span").click()
        driver.quit()
        return template('<b>Hello {{name}}</b>!', name=name)
    elif name == 'mode4':
        driver.find_element_by_xpath("//div[5]").click()
        driver.find_element_by_xpath("//span").click()
        driver.quit()
        return template('<b>Hello {{name}}</b>!', name=name)
    elif name == 'mode5':
        driver.find_element_by_xpath("//div[6]").click()
        driver.find_element_by_xpath("//span").click()
        driver.quit()
        return template('<b>Hello {{name}}</b>!', name=name)
    elif name == 'mode6':
        driver.find_element_by_xpath("//div[7]").click()
        driver.find_element_by_xpath("//span").click()
        driver.quit()
        return template('<b>Hello {{name}}</b>!', name=name)
    elif name == 'mode7':
        driver.find_element_by_xpath("//div[8]").click()
        driver.find_element_by_xpath("//span").click()
        driver.quit()
        return template('<b>Hello {{name}}</b>!', name=name)
    elif name == 'mode8':
        driver.find_element_by_xpath("//div[9]").click()
        driver.find_element_by_xpath("//span").click()
        driver.quit()
        return template('<b>Hello {{name}}</b>!', name=name)
    else:
        driver.find_element_by_xpath("//span").click()
        driver.quit()
        return template('<b>Sorry {{name}}</b>!', name=name)


run(host='0.0.0.0', port=8080)

 

 

 

ok so... with this script you can change to any of the modes except schedule!

 

 

http://ipaddress:8080/mode0

will select the first cell under schedule

 

 

http://ipaddress:8080/mode1

will select the second mode etc...

 

http://ipaddress:8080/mode8

I have defined all up to mode 8 as i only have 9 modes (we start from 0 don't forget, Programmer in me)

 

If you get 

 

Hello mode6! etc then you have successfully changed the mode... 

 

if you get

Failed mode6! etc then something broke....

 

Now just to do the easy stuff like port forwarding and setting up the maker channel! 🙂

paulsmitz
Apprentice
Apprentice

one thing to note is it takes about 15 seconds or so to action... because it has to load firefox, go to arlo.netgear.com, wait for the modes button to appeear, wait for the arlo spinner to disappear, wait for the modes to appear, and then click the mode you want! 😞  But hey its better than nothing!

paulsmitz
Apprentice
Apprentice

Done! looks to even work too! 🙂

paulsmitz
Apprentice
Apprentice

For those who don't want to buy and host a raspberry pi... you should be able to run a free tier Amazon AWS instance and get the whole shebang for free! anyone want to set up a vm image that is easy to spin up?

paulsmitz
Apprentice
Apprentice
elToro_
Aspirant
Aspirant

Nice solution. Thank you for sharing your work with us!

 

Using your code one can also implement a button on the RasperryPi and manually switch between two modes (like all cameras on, all cameras off).

 

 

paulsmitz
Apprentice
Apprentice

yep button on the raspberry pi or by IFTTT compatible buttons 😉

Hdg
Apprentice
Apprentice
Does your thermostat use geofencing or motion detection? Seems like using thermostat motion detection to disable camera motion detection would be counterproductive. Just curious. I have ecobees and was excited to try this but I don't have geofencing set up
paulsmitz
Apprentice
Apprentice
So I have ifttt set up when it changes mode... It currently is geofenced but I also have a smartthings setup (hoping for proper support eventually so the cameras can do the motion detection for the lights...) which has proximity sensors so thinking I might move to that eventually... Just need to code the smartthings to do the integration between my tado and Arlo.

The great thing about ifttt is that you can use anything that can create a trigger... So your supported devices and your imagination are key
Hdg
Apprentice
Apprentice

ah.. my ecobees have IR motion detection and I figured if they detect motion, it might actually be an intruder, so i absolutely do NOT want to toggle arlo motion detection based on thermostat motion detection.  True geofencing makes sense and I read that tado has multi-user geofencing so now i understand your setup.  

 

Thanks for the excellent contribution.  I wish Netgear/Arlo would get their act together on the app.. it def could be better in a few specific ways.  

paulsmitz
Apprentice
Apprentice
I agree being an iOS developer myself it would only take a week to add all the features people are wanting apart from ifttt which looking at their api (I sniffed the apps comms) it looks like it is actually really good and ifttt would just talk to it directly! They would just need the oauth stuff which takes no time at all to add! I don't understand how it is taking them months to sort!
Hdg
Apprentice
Apprentice

Im attempting this myself tonight.. I am intrigued by the AWS option.. but I'm leaning toward using my desktop machine and a hyper-v VM/Internet Explorer/iis.. I see slenium has an IE driver.  am I wasting my time with that route?

Hdg
Apprentice
Apprentice

or should I just spin up a debian VM instead?

Hdg
Apprentice
Apprentice

now that I am reading more.. I see that arlo has mentioned geofencig and IFTTT support in a techhive review.. and I just got an email from arlo about an upcoming upgrade... 

 

maybe i shoult hold off

paulsmitz
Apprentice
Apprentice
Yes you can use an was micro vm for this... (Free tier) you just use the amazon vm and copy the commands. I haven't tried it on Windows but I guess it would work so long as you can get Python and pip working it is cross platform after all!
paulsmitz
Apprentice
Apprentice

The update broke this and I haven't been able to fix it... seems that the project is dead!

platron
Star
Star

Pretty gonzo.  I guess it's not a shock that that the update broke it, given dependence on their exact DOM, but hats off!

JamesC
Community Manager
Community Manager

We are excited to let the community know that IFTTT integration has been announced! For more information, take a look here: Introducing IFTTT Integration
 
JamesC