-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsensorNoNeed.py
More file actions
31 lines (25 loc) · 795 Bytes
/
Copy pathsensorNoNeed.py
File metadata and controls
31 lines (25 loc) · 795 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
import requests
import socket
from time import sleep
import fuzzy
# hostname = socket.gethostname()
# ip_address = socket.gethostbyname(hostname)
# print(ip_address)
# endpoint_url = f'http://{ip_address}/device/'
endpoint_url=f'http://127.0.0.1:8000/device/'
while True:
temperature = 28
humidity = 59
gases = 989
status=fuzzy.estimate_Shelf_life(temperature,humidity,gases)
print(f"sensorNoNeed.py : temp={temperature}, Humidity={humidity}, gases={gases} ,status={status}, endpoint_url={endpoint_url}")
data = {
'name': 'Device 1',
'temperature': temperature,
'humidity': humidity,
'toxicGases': gases,
'status': status
}
requests.post(endpoint_url, json=data)
print("sensorNoNeed.py : post api called successfully")
sleep(10)