Ejemplo n.º 1
0
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))
Ejemplo n.º 2
0
 def disarmarlo(message):
     """disarm arlo
        Disable 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: {}Disarming Arlo.".format(debug))
     arlo = Arlo(settings.servers.arlo.username,
                 settings.servers.arlo.password)
     basestations = arlo.GetDevices('basestation')
     arlo.Disarm(basestations[0])
     message.send(":rotating_light: {}Arlo is disarmed.".format(debug))
     post.unack()
Ejemplo n.º 3
0
        'command',
        choices=['aktiviert', 'deaktiviert', 'garten', 'garten_hinten'])
    args = parser.parse_args()
    command = args.command

    # 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 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)
Ejemplo n.º 4
0
if args.verbose:
    print(sys.argv[0] + ": We are going to", args.mode.title(), "the Arlo")

try:
    if args.verbose:
        print(sys.argv[0] + ": Logging in with", settings.USERNAME)
    arlo = Arlo(settings.USERNAME, settings.PASSWORD)

    if args.verbose:
        print(sys.argv[0] + ": Fetching basestations")
    basestations = arlo.GetDevices('basestation')

    if args.verbose:
        print(sys.argv[0] + ":", args.mode.title() + "ing the Arlo")
    if args.mode.lower() == "arm":
        arlo.Arm(basestations[0])
    elif args.mode.lower() == "disarm":
        arlo.Disarm(basestations[0])

    if args.verbose:
        print(sys.argv[0] + ":", args.mode.title() + "ed!")

    arlo.Logout()
    if args.verbose:
        print(sys.argv[0] + ": Logged out")

except Exception as e:
    print(e)

exit(0)