411 lines
12 KiB
Plaintext
411 lines
12 KiB
Plaintext
{
|
||
"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": [
|
||
"'Demo User - demo@een.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.eyJzdWIiOiJjYTBmNjFhYiIsImF1ZCI6InZtcy5hcGkiLCJpc3MiOiJ2bXMuYXV0aC52MSIsInZtc19hY2NvdW50IjoiMDAwMDExMDYiLCJleHAiOjE2ODYyNTAzMTUsImlhdCI6MTY4NTY0NTUxNiwianRpIjoiMjBiMjZjNzc1MGU4YjQ0YTIzZTdhZWVmYWE5ZjlhZTUiLCJjbGllbnRfaWQiOiJQUkVWSUVXLU1BUkstV0VCIiwidm1zX2NsdXN0ZXIiOiJjMDAwIn0.MTBcdMhHfDMM5__dTtKLcEmJESXEGwTvtTFOpeLwFdg55RvC93N-ay3QdHPfgWl7amQS7RZOb0S1BhEuHvbBJa42_AFzGhgbPX5LZP4ghp2CL6Arbf3ehovt59nd9ZzOBVVSopiBQP_YNT7ap_ojUMy43NSd_W0jZ_54Qz6pthmeKXkpYTyYYccZ4X8bzvyJ4MpMR-WGJsTkgVZ8Ln9UxOadTNWHfGWk2eVZ0ZQsB02qj07va2KTlOCrlFlGjW46_1lOXg8ImiJAfdyJRHI7_y0wF7N3dnpXJO5bix-uzgwiC3msrNmDjYnwlD7rvGssq8L-4gi_9UgO1CTVZPuPkw'"
|
||
]
|
||
},
|
||
"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": [
|
||
"[✅ [100544a0] - Amsterdam1,\n",
|
||
" ✅ [10102231] - Australia,\n",
|
||
" ✅ [100a0565] - Boat Launch PTZ (5MP),\n",
|
||
" ✅ [10031d80] - CF1 16th Floor Break Room (4MP),\n",
|
||
" ✅ [1003dc62] - CF1 16th Floor Elevator Lobby (2MP),\n",
|
||
" ✅ [100eb87d] - CF1 16th Floor Freight Elevator (2MP),\n",
|
||
" ✅ [10023191] - CF1 16th Floor Kitchen (4MP),\n",
|
||
" ✅ [10013585] - CF1 16th Floor Library (2MP),\n",
|
||
" ✅ [1009e1ac] - CF1 16th Floor Lobby Fisheye (10MP),\n",
|
||
" ✅ [100be266] - CF1 16th Floor Lockers (2MP),\n",
|
||
" ✅ [10079c0f] - CF1 16th Floor Mentor Area,\n",
|
||
" ✅ [1007a107] - CF1 16th Floor Metal Room (3MP),\n",
|
||
" ✅ [1003fdad] - CF1 16th Floor Network Closet (1MP),\n",
|
||
" ✅ [10061445] - CF1 Astro_Boy,\n",
|
||
" ✅ [100f881f] - CF1 Dedicated Desks,\n",
|
||
" ✅ [100b4012] - CF1 Green Room (2MP),\n",
|
||
" ✅ [100f7041] - CF1 Lobby Center (2MP),\n",
|
||
" ✅ [10004d85] - CF1 Lobby Fisheye (5MP),\n",
|
||
" ✅ [10005281] - CF1 Lobby Reception (4MP),\n",
|
||
" ✅ [10095a7f] - CF1 Lobby Right (2MP),\n",
|
||
" ✅ [1007ab35] - CF1 North Office (2MP),\n",
|
||
" ✅ [1007e158] - CF1 Open Work Space 1 (1MP),\n",
|
||
" ✅ [1009ead6] - CF1 Open Work Space 2 (2MP),\n",
|
||
" ✅ [100baf8b] - CF1 Open Work Space 3 (2MP),\n",
|
||
" ✅ [10079cc5] - CF1 Podcast Studio (1MP),\n",
|
||
" ✅ [1003a079] - CF1 Rear Exit (1MP),\n",
|
||
" ✅ [100530a8] - CF1 Thermal Station,\n",
|
||
" ✅ [10058b7a] - CF1 Thermal Station Color View,\n",
|
||
" ✅ [10099857] - CF2 1st Floor Closet (1MP),\n",
|
||
" ✅ [1004549e] - CF2 1st Floor Exit (1MP),\n",
|
||
" ✅ [10107a26] - CF2 1st Floor Hallway (1MP),\n",
|
||
" ✅ [1001870e] - CF2 1st Floor Network Closet 1 (1MP),\n",
|
||
" ✅ [10083f1d] - CF2 1st Floor Term Exit (1MP),\n",
|
||
" ✅ [10032e17] - CF2 BB8 Back,\n",
|
||
" ✅ [100916ba] - CF2 Beer Robot (1MP),\n",
|
||
" ✅ [1006c703] - CF2 Device Lab (1MP),\n",
|
||
" ✅ [10035428] - CF2 Elevator Lobby 1 (4MP),\n",
|
||
" ✅ [10002b34] - CF2 Elevator Lobby 2 (2MP),\n",
|
||
" ✅ [1002737c] - CF2 Entrance (Fisheye) (5MP),\n",
|
||
" ✅ [1000881c] - CF2 Freight Elevator (1MP),\n",
|
||
" ✅ [1000cdc9] - CF2 Game Room (1MP),\n",
|
||
" ✅ [10051ab9] - CF2 Johnny-Five Room (1MP),\n",
|
||
" ✅ [1002931e] - CF2 Main Entrance (1MP),\n",
|
||
" ✅ [100e25eb] - CF2 Mobility Room (1MP),\n",
|
||
" ✅ [10035320] - CF2 Network Closet (1MP),\n",
|
||
" ✅ [10058b99] - CF2 Network Closet 2 (1MP),\n",
|
||
" ✅ [100ab69f] - CF2 Retail,\n",
|
||
" ✅ [1008ed00] - CF2 Retail Entrance,\n",
|
||
" ✅ [100254d4] - CF2 Retail Inventory,\n",
|
||
" ✅ [10104a9a] - CF2 Robo Cop Room Side Door (4MP),\n",
|
||
" ✅ [100abbbf] - CF2 Shared Workspace (1MP),\n",
|
||
" ✅ [1004d2cc] - CF2 Stage (1MP),\n",
|
||
" ✅ [1002d41b] - CF2 Terminator Room (1MP),\n",
|
||
" ✅ [10102f00] - CF2 VR Lab (4MP),\n",
|
||
" ✅ [10057197] - CF2 VR Lab Entrance (1MP),\n",
|
||
" ✅ [10001523] - CF3 Entry Drive (2MP),\n",
|
||
" ✅ [100cd8e3] - CF3 Lobby Overhead (1MP),\n",
|
||
" ✅ [10099a4e] - CF4 1st Floor Elevator (1MP),\n",
|
||
" ✅ [1004de41] - Chidori Marine Service(Mt.Fuji),\n",
|
||
" ✅ [100e0d6e] - Display Station View,\n",
|
||
" ✅ [100d4c42] - EEN HQ Entrance LPR,\n",
|
||
" ✅ [100ca645] - HD-TVI Encoder (Channel 3),\n",
|
||
" ✅ [1009d55a] - Hikvision PTZ,\n",
|
||
" ✅ [1001cdde] - JB1 Bay2 (2MP),\n",
|
||
" ✅ [1005a220] - JB1 hallway (1MP),\n",
|
||
" ✅ [1001c44b] - JB1 Lobby (2MP),\n",
|
||
" ✅ [1006e5ac] - Lagos - Avigilon PTZ,\n",
|
||
" ✅ [100e0fa0] - Malaysia,\n",
|
||
" ✅ [1009f383] - Parking,\n",
|
||
" ✅ [1002cc03] - 店内,\n",
|
||
" ✅ [1006242c] - 桟橋側]"
|
||
]
|
||
},
|
||
"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": "ad33bf2a-ea36-4ec1-8335-8a44089f5f7e",
|
||
"metadata": {},
|
||
"outputs": [
|
||
{
|
||
"data": {
|
||
"text/plain": [
|
||
"[? [1001e8e4] - CF4 East Hall (1MP),\n",
|
||
" ? [10079be3] - CF4 North East Hall (1MP),\n",
|
||
" ? [10081317] - CF4 West Hall (1MP),\n",
|
||
" ? [1007e81e] - EE ST01 Thermal Camera (1MP),\n",
|
||
" ? [100ac28e] - HD-TVI Encoder,\n",
|
||
" ? [100e1e7d] - JB3 Customer Area (SD),\n",
|
||
" ? [10097da5] - JB3 Dough Machine (SD),\n",
|
||
" ? [100a5bc2] - JB3 Make Line (SD),\n",
|
||
" ? [1001c49e] - JB3 Prep Area Mixer (SD),\n",
|
||
" ? [1002129c] - SAM1 Showroom (1MP),\n",
|
||
" ❌ [100d6e2a] - zz_Example of Camera Offline,\n",
|
||
" ? [10106a81] - zz_Example of Camera turned off]"
|
||
]
|
||
},
|
||
"execution_count": 8,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"[i for i in een.cameras if not i.is_online()]"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 9,
|
||
"id": "f4c6fe67",
|
||
"metadata": {},
|
||
"outputs": [
|
||
{
|
||
"data": {
|
||
"text/plain": [
|
||
"[? [1001e8e4] - CF4 East Hall (1MP),\n",
|
||
" ? [10079be3] - CF4 North East Hall (1MP),\n",
|
||
" ? [10081317] - CF4 West Hall (1MP),\n",
|
||
" ? [1007e81e] - EE ST01 Thermal Camera (1MP),\n",
|
||
" ? [100ac28e] - HD-TVI Encoder,\n",
|
||
" ? [100e1e7d] - JB3 Customer Area (SD),\n",
|
||
" ? [10097da5] - JB3 Dough Machine (SD),\n",
|
||
" ? [100a5bc2] - JB3 Make Line (SD),\n",
|
||
" ? [1001c49e] - JB3 Prep Area Mixer (SD),\n",
|
||
" ? [1002129c] - SAM1 Showroom (1MP),\n",
|
||
" ❌ [100d6e2a] - zz_Example of Camera Offline,\n",
|
||
" ? [10106a81] - zz_Example of Camera turned off]"
|
||
]
|
||
},
|
||
"execution_count": 9,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"[i for i in een.cameras if not i.is_online()]"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "b0ec786b-ed07-4486-a4d7-a7483e5a02ce",
|
||
"metadata": {},
|
||
"outputs": [],
|
||
"source": []
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"id": "8c140aaf-766f-4255-94ef-199d17cbc7a6",
|
||
"metadata": {},
|
||
"source": [
|
||
"## Getting list of Events"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 10,
|
||
"id": "74e78ee1-33b8-4a88-9d23-cd6281603a5b",
|
||
"metadata": {},
|
||
"outputs": [
|
||
{
|
||
"name": "stdout",
|
||
"output_type": "stream",
|
||
"text": [
|
||
"2023-06-01T13:54:01.906-05:00 2023-06-01T07:54:01.906-05:00\n"
|
||
]
|
||
}
|
||
],
|
||
"source": [
|
||
"print(een.time_now(), een.time_before())"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "c84c30dd-4b7c-415b-8e6f-e77de70d1924",
|
||
"metadata": {
|
||
"scrolled": true
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"for i in range(0,20):\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": null,
|
||
"id": "13809cc7-9ec2-4e15-9495-e64feaecca6d",
|
||
"metadata": {},
|
||
"outputs": [],
|
||
"source": [
|
||
"len(een.cameras[2].events['status'])"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "67d4f79b-2b43-4bdb-9068-28ac9d8d921c",
|
||
"metadata": {},
|
||
"outputs": [],
|
||
"source": [
|
||
"len(een.cameras[0].events['motion'])"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"id": "8be8d503-b46d-4ba7-884e-2c21c3987129",
|
||
"metadata": {},
|
||
"outputs": [],
|
||
"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": []
|
||
}
|
||
],
|
||
"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.8.10"
|
||
}
|
||
},
|
||
"nbformat": 4,
|
||
"nbformat_minor": 5
|
||
}
|