36 lines
1.2 KiB
Python
36 lines
1.2 KiB
Python
import requests;
|
|
import json;
|
|
import time;
|
|
from random import randint
|
|
|
|
with open("dispositivosdata.json", "r") as f:
|
|
data=json.load(f);
|
|
|
|
for item in data:
|
|
loops1 = randint(1,9)
|
|
for i in range(loops1):
|
|
temperatura = randint(10,40)
|
|
umidade = randint(9,85)
|
|
myURL = "http://nexuswebdigital.com:9999/feed/{}?temperatura={}&umidade={}".format(item[0]["chave"], temperatura, umidade)
|
|
response = requests.post(url=myURL);
|
|
print(response.text);
|
|
time.sleep(0.1);
|
|
|
|
loops2 = randint(1,9)
|
|
for i in range(loops2):
|
|
temperatura = randint(10,40)
|
|
umidade = randint(9,85)
|
|
myURL = "http://nexuswebdigital.com:9999/feed/{}?temperatura={}&umidade={}".format(item[1]["chave"], temperatura, umidade)
|
|
response = requests.post(url=myURL);
|
|
print(response.text);
|
|
time.sleep(0.1);
|
|
|
|
loops3 = randint(1,9)
|
|
for i in range(loops3):
|
|
temperatura = randint(10,40)
|
|
umidade = randint(9,85)
|
|
myURL = "http://nexuswebdigital.com:9999/feed/{}?temperatura={}&umidade={}".format(item[2]["chave"], temperatura, umidade)
|
|
response = requests.post(url=myURL);
|
|
print(response.text);
|
|
time.sleep(0.1);
|