-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexample7.py
More file actions
34 lines (27 loc) · 811 Bytes
/
example7.py
File metadata and controls
34 lines (27 loc) · 811 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env python
import os
import datetime
from honeydb import api
EVENT = "RX"
SERVICE = "HTTP"
API_ID = os.environ["HONEYDB_API_ID"]
API_KEY = os.environ["HONEYDB_API_KEY"]
honeydb = api.Client(API_ID, API_KEY)
today = datetime.datetime.today()
from_id = None # initialize from_id to None
while from_id != 0:
"""
Sensor data returns an array with two objects:
[
{"data": []}
{"from_id": 0}
]
"""
sensor_data = honeydb.sensor_data(
sensor_data_date=today.strftime("%Y-%m-%d"), from_id=from_id
)
for event in sensor_data[0]["data"]:
if event["event"] == EVENT and event["service"] == SERVICE:
byte_data = bytes.fromhex(event["data"])
print(f"{byte_data.decode()}")
from_id = int(sensor_data[1]["from_id"])