switching to demo user, cleaning up Playground to work in a different account

full_example
mcotton 2023-06-01 13:59:15 -05:00
parent 09e153e3f6
commit 0a63657305
2 changed files with 103 additions and 197 deletions

1
.gitignore vendored
View File

@ -4,5 +4,6 @@ __pycache__
my_settings.py
*.orig
.lazy_login
.lazy_login*
.ipynb_checkpoints/
.ipynb_checkpoints/*

View File

@ -88,7 +88,7 @@
{
"data": {
"text/plain": [
"'Mark Cotton - mcotton@mcottondesign.com'"
"'Demo User - demo@een.com'"
]
},
"execution_count": 4,
@ -109,7 +109,7 @@
{
"data": {
"text/plain": [
"'eyJraWQiOiI2ODYxYjBjYS0wZjI2LTExZWQtODYxZC0wMjQyYWMxMjAwMDIiLCJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJzdWIiOiJjYWZlZGVmMiIsImF1ZCI6InZtcy5hcGkiLCJpc3MiOiJ2bXMuYXV0aC52MSIsInZtc19hY2NvdW50IjoiMDAwMjgyMDEiLCJleHAiOjE2ODYwMTQ0NjUsImlhdCI6MTY4NTQwOTY2NiwianRpIjoiNDBkMThmZTA0YTZlNWE5NDI0OWE4NmVjNmE5NDA0YzYiLCJjbGllbnRfaWQiOiJQUkVWSUVXLU1BUkstV0VCIiwidm1zX2NsdXN0ZXIiOiJjMDEyIn0.RAVxuQtnb9WSv4jp4hNqEyPaVzlpK6GqodFAUybzrnGiPR9tHE5OIanCZf2aX5IGAyOk9Kn5UYD4h96iIt8cpCXIyrFPKGE3WtspAxYNBwczjAWTuZQ6lOxH2eIeo3QjoTeOZaL8JEfCmc5-NyK4xaTrnb0nuhUnWzB4Vo9xtqzn2mupYUEyOvkgM0nOaTxPlrJLRNjNKDWKwMtuE2wo94HbjeOi8lSvQcMPvm07qvS1nFEaTjzpHCdwENcK6ghEUv5wzbUsDm5FYZFi29MyGLLiwv6csGD8lY0C3FFsG5EbMFzNAqS-v-CriPgA-3X9rpgLiWNIjSFG8vj7ZzCtsg'"
"'eyJraWQiOiI2ODYxYjBjYS0wZjI2LTExZWQtODYxZC0wMjQyYWMxMjAwMDIiLCJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJzdWIiOiJjYTBmNjFhYiIsImF1ZCI6InZtcy5hcGkiLCJpc3MiOiJ2bXMuYXV0aC52MSIsInZtc19hY2NvdW50IjoiMDAwMDExMDYiLCJleHAiOjE2ODYyNTAzMTUsImlhdCI6MTY4NTY0NTUxNiwianRpIjoiMjBiMjZjNzc1MGU4YjQ0YTIzZTdhZWVmYWE5ZjlhZTUiLCJjbGllbnRfaWQiOiJQUkVWSUVXLU1BUkstV0VCIiwidm1zX2NsdXN0ZXIiOiJjMDAwIn0.MTBcdMhHfDMM5__dTtKLcEmJESXEGwTvtTFOpeLwFdg55RvC93N-ay3QdHPfgWl7amQS7RZOb0S1BhEuHvbBJa42_AFzGhgbPX5LZP4ghp2CL6Arbf3ehovt59nd9ZzOBVVSopiBQP_YNT7ap_ojUMy43NSd_W0jZ_54Qz6pthmeKXkpYTyYYccZ4X8bzvyJ4MpMR-WGJsTkgVZ8Ln9UxOadTNWHfGWk2eVZ0ZQsB02qj07va2KTlOCrlFlGjW46_1lOXg8ImiJAfdyJRHI7_y0wF7N3dnpXJO5bix-uzgwiC3msrNmDjYnwlD7rvGssq8L-4gi_9UgO1CTVZPuPkw'"
]
},
"execution_count": 5,
@ -148,7 +148,77 @@
{
"data": {
"text/plain": [
"[✅ [1001423e] - ATM & Wine, ✅ [100d8666] - Cash Register, ✅ [1002584c] - Safe]"
"[✅ [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,
@ -169,12 +239,18 @@
{
"data": {
"text/plain": [
"[ [10090759] - Benny Camera,\n",
" [1003e10b] - Driveway,\n",
" [100ba388] - Front Door,\n",
" [10012735] - Fuel Dock,\n",
" [100b7b3b] - Max Camera,\n",
" [1009ae55] - Office]"
"[ [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,
@ -195,12 +271,18 @@
{
"data": {
"text/plain": [
"[ [10090759] - Benny Camera,\n",
" [1003e10b] - Driveway,\n",
" [100ba388] - Front Door,\n",
" [10012735] - Fuel Dock,\n",
" [100b7b3b] - Max Camera,\n",
" [1009ae55] - Office]"
"[ [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,
@ -220,161 +302,6 @@
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"id": "295b9ef8-df88-447e-b787-0098b4778f6a",
"metadata": {},
"source": [
"## User timezone fun"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "ef1ea137-d9fb-4f6f-b241-fb019c8e3230",
"metadata": {},
"outputs": [],
"source": [
"#from datetime import datetime, timedelta\n",
"#from pytz import timezone"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "0841aef0-89c1-45ac-b501-a9196f481d49",
"metadata": {},
"outputs": [],
"source": [
"#een.user_tz_obj = timezone(een.current_user['timeZone']['timeZone'])\n",
"#now = datetime.now(tz=een.user_tz_obj)"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "ae53f810-cb77-48e3-b148-72ef7038bb89",
"metadata": {},
"outputs": [],
"source": [
"#now.isoformat(timespec='milliseconds')"
]
},
{
"cell_type": "code",
"execution_count": 13,
"id": "4d708ccb-80b1-4d88-aa2e-d93a71cbdc04",
"metadata": {},
"outputs": [],
"source": [
"#(datetime.now(tz=een.user_tz_obj) - timedelta(hours=6)).isoformat(timespec='milliseconds')"
]
},
{
"cell_type": "markdown",
"id": "f4d8c154-400a-4af9-b677-29190b588408",
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": []
},
"source": [
"## Event Subscription"
]
},
{
"cell_type": "code",
"execution_count": 14,
"id": "a9d81b0d-72e6-4404-b30e-3a341a9e6639",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{\"id\":\"967034aa-aa8c-45d4-92c1-af73d0bc9f8d\",\"subscriptionConfig\":{\"lifeCycle\":\"temporary\",\"timeToLiveSeconds\":900},\"deliveryConfig\":{\"type\":\"serverSentEvents.v1\",\"sseUrl\":\"https://api.c012.eagleeyenetworks.com/api/v3.0/sse/eventSubscriptions/967034aa-aa8c-45d4-92c1-af73d0bc9f8d\"}}\n"
]
}
],
"source": [
"import requests\n",
"\n",
"url = \"https://api.c012.eagleeyenetworks.com/api/v3.0/eventSubscriptions\"\n",
"\n",
"payload = {\n",
" \"deliveryConfig\": {\"type\": \"serverSentEvents.v1\"},\n",
" \"filters\": [\n",
" {\n",
" \"actors\": [\"camera:100d8666\"],\n",
" \"types\": [{\"id\": \"een.motionDetectionEvent.v1\"}]\n",
" }\n",
" ]\n",
"}\n",
"headers = {\n",
" \"accept\": \"application/json\",\n",
" \"content-type\": \"application/json\",\n",
" \"authorization\": f\"Bearer {een.access_token}\"\n",
"}\n",
"\n",
"response = requests.post(url, json=payload, headers=headers)\n",
"\n",
"print(response.text)"
]
},
{
"cell_type": "code",
"execution_count": 15,
"id": "53d3bff7-848f-4669-ab66-57597313fa0d",
"metadata": {
"editable": true,
"scrolled": true,
"slideshow": {
"slide_type": ""
},
"tags": []
},
"outputs": [],
"source": [
"#pip install sseclient\n",
"from sseclient import SSEClient\n",
"\n",
"messages = SSEClient(f\"{response.json()['deliveryConfig']['sseUrl']}\", headers=headers)"
]
},
{
"cell_type": "code",
"execution_count": 16,
"id": "91cfe32d-db80-40fb-8ea9-d60f8a647b0d",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<Response [200]>"
]
},
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"messages.resp"
]
},
{
"cell_type": "code",
"execution_count": 17,
"id": "2016a9cf-9ce8-48af-8e3f-c058024c544e",
"metadata": {},
"outputs": [],
"source": [
"#for msg in messages:\n",
"# print(msg)"
]
},
{
"cell_type": "markdown",
"id": "8c140aaf-766f-4255-94ef-199d17cbc7a6",
@ -385,7 +312,7 @@
},
{
"cell_type": "code",
"execution_count": 18,
"execution_count": 10,
"id": "74e78ee1-33b8-4a88-9d23-cd6281603a5b",
"metadata": {},
"outputs": [
@ -393,7 +320,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"2023-06-01T13:41:19.422-05:00 2023-06-01T07:41:19.422-05:00\n"
"2023-06-01T13:54:01.906-05:00 2023-06-01T07:54:01.906-05:00\n"
]
}
],
@ -438,18 +365,6 @@
"len(een.cameras[0].events['motion'])"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "287cbf7b-52c4-4aac-abeb-be94d0594c19",
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"#een.cameras[2].get_list_of_events(end_timestamp=een.time_now(), start_timestamp=een.time_before())"
]
},
{
"cell_type": "code",
"execution_count": null,
@ -457,19 +372,9 @@
"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": "b761affe-ec32-4bd2-ba20-a2a6fb9db801",
"metadata": {},
"outputs": [],
"source": [
"#sorted(een.cameras[2].events['status'], key=lambda x: x['startTimestamp'], reverse=True) "
"for cam in een.cameras:\n",
" for i in cam.events['status']:\n",
" print(f\"{cam.name} - {i['startTimestamp']} - {i['data'][0]['newStatus']['connectionStatus']} \")"
]
},
{