def switch(command, i=0): try: arlo = Arlo(ArloLogin, ArloPassword) base = arlo.GetDevices('basestation')[ 0] # get base station info, assuming only 1 is available camera = arlo.GetDevices('camera')[ 0] # get camera info, assuming only 1 is available print("Command: " + command) if command == "status": print("ARLO -- Camera current mode: " + get_current_state(arlo)) elif command == "armed": #print("ARLO -- Camera old mode: " + get_current_state(arlo)) arlo.Arm(base) print("ARLO -- Camera new mode: " + get_current_state(arlo)) else: #print("ARLO -- Camera old mode: " + get_current_state(arlo)) arlo.Disarm(base) print("ARLO -- Camera new mode: " + get_current_state(arlo)) # On tente d'exécuter la commande 8 fois maximum except Exception as e: print(e) if i < 8: print("ARLO -- Connexion Error - new try ... (" + str(i + 1) + "/8)") switch(command, i + 1) return else: print("ARLO -- Connexion Errors -- command failed " + str(i) + " times. Exit") raise SystemExit(1) # Return failure # Enregistre l'état de la batterie (pour lecture dans Domoticz) time.sleep(1) cam_battery_level = arlo.GetCameraState( base)["properties"][0]["batteryLevel"] print("ARLO -- Camera Battery: " + str(cam_battery_level) + " % -> into file /tmp/arlo_cam1.txt") with open('/tmp/arlo_cam1.txt', 'w') as f: f.write(str(cam_battery_level))
def armarlo(message): """arm arlo Enable motion detection for the Arlo system. """ if (os.environ['TARGET_DEVICE'] != 'all' and os.environ['TARGET_DEVICE'] != device_name): return post = slackmq(os.environ['API_TOKEN'], message.body['channel'], message.body['ts']) if not post.ack(): return if eval(os.environ['DEBUG']): debug = "[{}] ".format(device_name) else: debug = "" message.send(":rotating_light: {}Arming Arlo.".format(debug)) arlo = Arlo(settings.servers.arlo.username, settings.servers.arlo.password) basestations = arlo.GetDevices('basestation') arlo.Arm(basestations[0]) # Perform any post arming actions via a screenplay chat.post("custom arlo") message.send(":rotating_light: {}Arlo is armed.".format(debug)) post.unack()
# At this point you're logged into Arlo. # Get all devices devices = arlo.GetDevices('') if command == 'deaktiviert': device = getDeviceFromName("Home", devices) arlo.Disarm(device) device = getDeviceFromName("Bridge_AZMichael", devices) arlo.Disarm(device) device = getDeviceFromName("Bridge_AZSabine", devices) arlo.Disarm(device) elif command == 'aktiviert': device = getDeviceFromName("Home", devices) arlo.Arm(device) device = getDeviceFromName("Bridge_AZMichael", devices) arlo.Arm(device) device = getDeviceFromName("Bridge_AZSabine", devices) arlo.Arm(device) elif command == 'garten': device = getDeviceFromName("Home", devices) arlo.CustomMode(device, "mode5") # Garten_Alle device = getDeviceFromName("Bridge_AZMichael", devices) arlo.CustomMode(device, "mode4") # Garten device = getDeviceFromName("Bridge_AZSabine", devices) arlo.Arm(device) elif command == 'garten_hinten': device = getDeviceFromName("Home", devices)
from arlo import Arlo USERNAME = '******' PASSWORD = '******' try: # Instantiating the Arlo object automatically calls Login(), which returns an oAuth token that gets cached. # Subsequent successful calls to login will update the oAuth token. arlo = Arlo(USERNAME, PASSWORD) # At this point you're logged into Arlo. # Get the list of devices and filter on device type to only get the basestation. # This will return an array which includes all of the basestation's associated metadata. basestations = arlo.GetDevices('basestation') # Arm Arlo. arlo.Arm(basestations[0]) # Or # Disarm Arlo. # arlo.Disarm(basestations[0]) # Or # Change Mode to some custom mode you created. # arlo.CustomMode(basestations[0], "mode3") # 'mode3' is the id of a custom mode you created. # Or # Change Mode to Schedule. # arlo.CustomMode(basestations[0], mode=None, schedules=['schedules.1']) # 'schedules.1' is the id of my default schedule." except Exception as e: print(e)