{ "cells": [ { "cell_type": "markdown", "id": "d4582341", "metadata": {}, "source": [ "# EagleEyev3 Playground\n", "\n", "To make this playground work, it is easier to read the `access_token` off the filesystem but you can always run the example server `python server.py` to go thorugh the Oauth2 flow. By default it will save the `access_token` into a file named `.lazy_login`. The module looks for that file and tries reading t" ] }, { "cell_type": "markdown", "id": "8355d241", "metadata": {}, "source": [ "## Import Module" ] }, { "cell_type": "code", "execution_count": 1, "id": "1394471a", "metadata": {}, "outputs": [], "source": [ "from EagleEyev3 import EagleEyev3" ] }, { "cell_type": "code", "execution_count": 2, "id": "486a2537", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "INFO:root:200 in get_base_url\n", "INFO:root:200 in get_current_user\n" ] } ], "source": [ "een = EagleEyev3()" ] }, { "cell_type": "markdown", "id": "51b8b66e", "metadata": {}, "source": [ "## Adjust Log Level" ] }, { "cell_type": "code", "execution_count": 3, "id": "06d91db2", "metadata": {}, "outputs": [], "source": [ "import logging\n", "logger = logging.getLogger()\n", "#logger.setLevel('DEBUG')\n", "#logger.setLevel('INFO')\n", "logger.setLevel('WARN')\n", "#logger.setLevel('ERROR')\n", "#logger.setLevel('CRITICAL')" ] }, { "cell_type": "markdown", "id": "0311109c-869c-4190-97c1-a6e717a8eeba", "metadata": {}, "source": [ "## Who am I" ] }, { "cell_type": "code", "execution_count": 4, "id": "e14e2be5-a5f9-4b8c-ae60-76c61cb61b8b", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'Mark Cotton - mcotton@mcottondesign.com'" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "f\"{een.current_user['firstName']} {een.current_user['lastName']} - {een.current_user['email']}\"" ] }, { "cell_type": "code", "execution_count": 5, "id": "4ef47ae2-a010-4b7e-87f6-3dbf0a047e16", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'eyJraWQiOiI2ODYxYjBjYS0wZjI2LTExZWQtODYxZC0wMjQyYWMxMjAwMDIiLCJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJzdWIiOiJjYWZlZGVmMiIsImF1ZCI6InZtcy5hcGkiLCJpc3MiOiJ2bXMuYXV0aC52MSIsInZtc19hY2NvdW50IjoiMDAwMjgyMDEiLCJleHAiOjE2ODkzNzA1MTIsImlhdCI6MTY4ODc2NTcxMiwianRpIjoiYTM1Nzk3MmRmNzdiNTAwYTQ3NjBlNGY1MGYwNjNhMjUiLCJjbGllbnRfaWQiOiIzMmRhYzMzMDY0OWI0ODI3OWY5Y2FjYzJiNmY1N2FlNSIsInZtc19jbHVzdGVyIjoiYzAxMiJ9.EEmCaFqduOV5_cQ-VejeBXGbKLj1yHrxGkcMgqPUN1jYY0wR9bO7rkEwQh59Dj-1fr8pKsbrUr6DPDLfkaSIRlxpjdlsEBdzAmoZUpzPUfL9QzJu0C04OJU0gcBh7fwur7L2fMVthaZ6OKfThdM29qzRH5RR9gSAJGeNe08n4IvFVvuL80yvczgOiQwSzkg4PuHpbImDa44U7-qC8CrRvQ_TqsX6ziNzw-XmxZxXEwtZxkAOFDFaIsA8V4ezbQ_TSY6EElCnyyKLLI46-KIsGevx8dxa2NrhPFvC725dMhg-OPaCEF62sOlTrlHVBcv_e9MBk1VZLoDLStkSvU7Dxg'" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "een.access_token" ] }, { "cell_type": "markdown", "id": "a22ff6c2", "metadata": {}, "source": [ "## Get Cameras" ] }, { "cell_type": "code", "execution_count": 6, "id": "bb457850", "metadata": {}, "outputs": [], "source": [ "ret = een.get_list_of_cameras()" ] }, { "cell_type": "code", "execution_count": 7, "id": "c43f1db1", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[✅ [1001423e] - ATM & Wine,\n", " ✅ [100d8666] - Cash Register,\n", " ✅ [10012735] - Fuel Dock,\n", " ✅ [1002584c] - Safe]" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "[i for i in een.cameras if i.is_online()]" ] }, { "cell_type": "code", "execution_count": 8, "id": "f4c6fe67", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[? [10090759] - Benny Camera,\n", " ? [1003e10b] - Driveway,\n", " ? [100ba388] - Front Door,\n", " ? [100b7b3b] - Max Camera,\n", " ? [1009ae55] - Office]" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "[i for i in een.cameras if not i.is_online()]" ] }, { "cell_type": "markdown", "id": "8c140aaf-766f-4255-94ef-199d17cbc7a6", "metadata": {}, "source": [ "## Getting list of Events" ] }, { "cell_type": "code", "execution_count": 9, "id": "74e78ee1-33b8-4a88-9d23-cd6281603a5b", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "2023-07-07T16:41:31.990-05:00 2023-07-07T10:41:31.990-05:00\n" ] } ], "source": [ "print(een.time_now(), een.time_before())" ] }, { "cell_type": "code", "execution_count": 11, "id": "c84c30dd-4b7c-415b-8e6f-e77de70d1924", "metadata": { "scrolled": true }, "outputs": [], "source": [ "for i in range(0,4):\n", " ts = een.time_now()\n", "\n", " for cam in een.cameras:\n", " blah = cam.get_list_of_events(end_timestamp=een.time_before(ts=ts, hours=(6*i)), \\\n", " start_timestamp=een.time_before(ts=ts, hours=(6*(i+1))) )" ] }, { "cell_type": "code", "execution_count": 12, "id": "13809cc7-9ec2-4e15-9495-e64feaecca6d", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "18" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "len(een.cameras[2].events['status'])" ] }, { "cell_type": "code", "execution_count": 13, "id": "67d4f79b-2b43-4bdb-9068-28ac9d8d921c", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "len(een.cameras[0].events['motion'])" ] }, { "cell_type": "code", "execution_count": 14, "id": "8be8d503-b46d-4ba7-884e-2c21c3987129", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "ATM & Wine - 2023-07-07T18:49:29.664+00:00 - deviceOffline \n", "ATM & Wine - 2023-07-07T18:48:51.444+00:00 - error \n", "ATM & Wine - 2023-07-07T16:22:04.146+00:00 - online \n", "ATM & Wine - 2023-07-07T16:21:41.960+00:00 - deviceOffline \n", "ATM & Wine - 2023-07-07T16:18:16.383+00:00 - error \n", "ATM & Wine - 2023-07-07T16:16:31.511+00:00 - deviceOffline \n", "ATM & Wine - 2023-07-07T16:15:57.174+00:00 - error \n", "ATM & Wine - 2023-07-07T15:44:21.759+00:00 - online \n", "ATM & Wine - 2023-07-07T15:41:31.997+00:00 - online \n", "ATM & Wine - 2023-07-07T12:46:47.672+00:00 - bridgeOffline \n", "ATM & Wine - 2023-07-07T11:24:46.454+00:00 - online \n", "ATM & Wine - 2023-07-07T11:22:37.461+00:00 - deviceOffline \n", "ATM & Wine - 2023-07-07T11:21:59.127+00:00 - error \n", "ATM & Wine - 2023-07-07T09:44:24.462+00:00 - online \n", "ATM & Wine - 2023-07-07T09:41:33.395+00:00 - online \n", "ATM & Wine - 2023-07-07T06:00:38.322+00:00 - deviceOffline \n", "ATM & Wine - 2023-07-07T06:00:00.175+00:00 - error \n", "ATM & Wine - 2023-07-07T04:07:20.003+00:00 - online \n", "ATM & Wine - 2023-07-07T04:05:21.238+00:00 - deviceOffline \n", "ATM & Wine - 2023-07-07T04:04:42.160+00:00 - error \n", "ATM & Wine - 2023-07-07T03:44:26.904+00:00 - online \n", "ATM & Wine - 2023-07-07T03:41:56.630+00:00 - online \n", "ATM & Wine - 2023-07-07T01:48:05.792+00:00 - deviceOffline \n", "ATM & Wine - 2023-07-07T01:47:35.155+00:00 - error \n", "ATM & Wine - 2023-07-06T23:19:05.335+00:00 - online \n", "ATM & Wine - 2023-07-06T23:16:58.926+00:00 - deviceOffline \n", "ATM & Wine - 2023-07-06T23:16:28.421+00:00 - error \n", "ATM & Wine - 2023-07-06T23:10:32.790+00:00 - deviceOffline \n", "ATM & Wine - 2023-07-06T21:44:28.864+00:00 - online \n", "ATM & Wine - 2023-07-06T21:41:57.860+00:00 - online \n", "ATM & Wine - 2023-07-06T20:08:47.208+00:00 - deviceOffline \n", "ATM & Wine - 2023-07-06T20:08:16.933+00:00 - error \n", "ATM & Wine - 2023-07-06T20:03:05.801+00:00 - online \n", "ATM & Wine - 2023-07-06T20:02:43.659+00:00 - deviceOffline \n", "ATM & Wine - 2023-07-06T20:01:41.457+00:00 - error \n", "ATM & Wine - 2023-07-06T19:59:57.405+00:00 - deviceOffline \n", "ATM & Wine - 2023-07-06T19:59:24.184+00:00 - error \n", "ATM & Wine - 2023-07-06T19:31:55.867+00:00 - online \n", "ATM & Wine - 2023-07-06T19:29:46.708+00:00 - deviceOffline \n", "ATM & Wine - 2023-07-06T19:29:16.013+00:00 - error \n", "ATM & Wine - 2023-07-06T18:24:27.389+00:00 - online \n", "ATM & Wine - 2023-07-06T18:22:22.328+00:00 - deviceOffline \n", "ATM & Wine - 2023-07-06T18:21:52.102+00:00 - error \n", "ATM & Wine - 2023-07-06T15:52:12.759+00:00 - online \n", "ATM & Wine - 2023-07-06T15:50:09.509+00:00 - deviceOffline \n", "ATM & Wine - 2023-07-06T15:49:39.152+00:00 - error \n", "ATM & Wine - 2023-07-06T15:41:58.888+00:00 - online \n", "ATM & Wine - 2023-07-06T15:11:05.317+00:00 - deviceOffline \n", "ATM & Wine - 2023-07-06T15:10:35.056+00:00 - error \n", "ATM & Wine - 2023-07-06T14:59:51.787+00:00 - online \n", "ATM & Wine - 2023-07-06T14:58:55.970+00:00 - bridgeOffline \n", "ATM & Wine - 2023-07-06T14:58:40.967+00:00 - deviceOffline \n", "ATM & Wine - 2023-07-06T12:58:36.884+00:00 - online \n", "ATM & Wine - 2023-07-06T12:56:38.478+00:00 - deviceOffline \n", "ATM & Wine - 2023-07-06T12:56:07.792+00:00 - error \n", "ATM & Wine - 2023-07-06T12:49:42.742+00:00 - online \n", "ATM & Wine - 2023-07-06T12:47:32.312+00:00 - deviceOffline \n", "ATM & Wine - 2023-07-06T12:47:01.925+00:00 - error \n", "ATM & Wine - 2023-07-06T11:40:03.505+00:00 - online \n", "ATM & Wine - 2023-07-06T11:38:03.703+00:00 - deviceOffline \n", "ATM & Wine - 2023-07-06T11:37:23.038+00:00 - error \n", "ATM & Wine - 2023-07-06T11:31:52.611+00:00 - online \n", "ATM & Wine - 2023-07-06T11:29:42.541+00:00 - deviceOffline \n", "ATM & Wine - 2023-07-06T11:29:08.199+00:00 - error \n", "ATM & Wine - 2023-07-06T09:42:01.013+00:00 - online \n", "ATM & Wine - 2023-07-06T09:38:38.302+00:00 - deviceOffline \n", "ATM & Wine - 2023-07-06T09:38:07.937+00:00 - error \n", "ATM & Wine - 2023-07-06T08:31:02.432+00:00 - online \n", "ATM & Wine - 2023-07-06T08:28:53.086+00:00 - deviceOffline \n", "ATM & Wine - 2023-07-06T08:28:22.667+00:00 - error \n", "ATM & Wine - 2023-07-06T04:07:10.931+00:00 - online \n", "ATM & Wine - 2023-07-06T04:05:11.397+00:00 - deviceOffline \n", "ATM & Wine - 2023-07-06T04:04:38.124+00:00 - error \n", "ATM & Wine - 2023-07-06T03:43:19.799+00:00 - online \n", "ATM & Wine - 2023-07-06T02:15:51.335+00:00 - deviceOffline \n", "ATM & Wine - 2023-07-06T02:15:19.584+00:00 - error \n", "ATM & Wine - 2023-07-05T21:43:39.111+00:00 - online \n", "ATM & Wine - 2023-07-05T18:35:23.024+00:00 - deviceOffline \n", "ATM & Wine - 2023-07-05T18:34:44.881+00:00 - error \n", "ATM & Wine - 2023-07-05T17:13:14.356+00:00 - online \n", "ATM & Wine - 2023-07-05T17:11:09.341+00:00 - deviceOffline \n", "ATM & Wine - 2023-07-05T17:10:29.222+00:00 - error \n", "ATM & Wine - 2023-07-05T15:43:44.544+00:00 - online \n", "ATM & Wine - 2023-07-05T15:33:04.629+00:00 - deviceOffline \n", "ATM & Wine - 2023-07-05T15:32:34.148+00:00 - error \n", "ATM & Wine - 2023-07-05T15:13:36.151+00:00 - online \n", "ATM & Wine - 2023-07-05T15:11:33.954+00:00 - deviceOffline \n", "ATM & Wine - 2023-07-05T15:10:54.632+00:00 - error \n", "ATM & Wine - 2023-07-05T14:24:50.082+00:00 - online \n", "ATM & Wine - 2023-07-05T14:22:50.393+00:00 - deviceOffline \n", "ATM & Wine - 2023-07-05T14:22:12.040+00:00 - error \n", "ATM & Wine - 2023-07-05T14:02:42.746+00:00 - online \n", "ATM & Wine - 2023-07-05T14:00:34.085+00:00 - deviceOffline \n", "ATM & Wine - 2023-07-05T13:59:55.709+00:00 - error \n", "ATM & Wine - 2023-07-05T10:43:54.157+00:00 - online \n", "ATM & Wine - 2023-07-05T10:41:56.025+00:00 - deviceOffline \n", "ATM & Wine - 2023-07-05T10:41:23.556+00:00 - error \n", "ATM & Wine - 2023-07-05T10:10:27.404+00:00 - online \n", "ATM & Wine - 2023-07-05T10:08:19.943+00:00 - deviceOffline \n", "ATM & Wine - 2023-07-05T10:07:50.455+00:00 - error \n", "ATM & Wine - 2023-07-05T09:44:11.782+00:00 - online \n", "Cash Register - 2023-07-07T20:02:49.237+00:00 - bridgeOffline \n", "Cash Register - 2023-07-07T20:02:31.354+00:00 - deviceOffline \n", "Cash Register - 2023-07-07T16:01:54.202+00:00 - online \n", "Cash Register - 2023-07-07T16:01:52.891+00:00 - bridgeOffline \n", "Cash Register - 2023-07-07T15:44:21.759+00:00 - online \n", "Cash Register - 2023-07-07T15:41:31.997+00:00 - online \n", "Cash Register - 2023-07-06T23:01:59.550+00:00 - bridgeOffline \n", "Cash Register - 2023-07-06T21:44:28.864+00:00 - online \n", "Cash Register - 2023-07-06T21:41:57.860+00:00 - online \n", "Cash Register - 2023-07-06T14:58:55.385+00:00 - bridgeOffline \n", "Cash Register - 2023-07-06T14:58:40.382+00:00 - deviceOffline \n", "Cash Register - 2023-07-06T10:01:40.245+00:00 - online \n", "Cash Register - 2023-07-06T10:01:39.158+00:00 - bridgeOffline \n", "Cash Register - 2023-07-06T09:42:01.013+00:00 - online \n", "Cash Register - 2023-07-05T20:06:43.349+00:00 - bridgeOffline \n", "Cash Register - 2023-07-05T18:01:54.584+00:00 - online \n", "Cash Register - 2023-07-05T18:01:53.582+00:00 - bridgeOffline \n", "Cash Register - 2023-07-05T15:43:44.544+00:00 - online \n", "Safe - 2023-07-06T14:58:55.537+00:00 - bridgeOffline \n", "Safe - 2023-07-06T14:58:40.535+00:00 - deviceOffline \n", "Safe - 2023-07-06T09:42:01.013+00:00 - online \n", "Safe - 2023-07-06T07:27:05.695+00:00 - bridgeOffline \n", "Safe - 2023-07-06T03:43:19.799+00:00 - online \n", "Safe - 2023-07-06T02:05:12.252+00:00 - bridgeOffline \n", "Safe - 2023-07-05T21:43:39.111+00:00 - online \n" ] } ], "source": [ "for cam in een.cameras:\n", " for i in cam.events['status']:\n", " print(f\"{cam.name} - {i['startTimestamp']} - {i['data'][0]['newStatus']['connectionStatus']} \")" ] }, { "cell_type": "code", "execution_count": null, "id": "1cebbb4e-4c4e-4ab0-9627-251eb812b2f1", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "id": "d8a69185-54cc-4c74-9c9b-a807e601be83", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.3" } }, "nbformat": 4, "nbformat_minor": 5 }