correcao dos scripts para coletar os tokens e enviar as leituras
This commit is contained in:
@@ -1,18 +1,19 @@
|
|||||||
import requests;
|
import requests;
|
||||||
import json;
|
import json;
|
||||||
|
|
||||||
myURL = "http://nexuswebdigital.com:9999/dispositivos"
|
myURL = "http://nexuswebdigital.com:9999/dispositivos";
|
||||||
dados = []
|
dados = [];
|
||||||
|
|
||||||
with open("logindata.json", "r") as f:
|
with open("logindata.json", "r") as f:
|
||||||
data=json.load(f);
|
data=json.load(f);
|
||||||
|
|
||||||
for item in data:
|
for item in data:
|
||||||
head = {'Authorization': '{}'.format(item["token_api"])}
|
head = {'Authorization': '{}'.format(item["token_api"])};
|
||||||
response = requests.get(url=myURL, headers=head, json={"nome":"Sensor Sala","descricao":"Um sensor que fica na sala"});
|
response = requests.get(url=myURL, headers=head, json={"nome":"Sensor Sala","descricao":"Um sensor que fica na sala"});
|
||||||
print(response.text);
|
print(response.text);
|
||||||
dados.append(json.loads(response.text))
|
for item2 in json.loads(response.text):
|
||||||
|
dados.append(item2);
|
||||||
|
|
||||||
arquivo = open("dispositivosdata.json", "w")
|
arquivo = open("dispositivosdata.json", "w");
|
||||||
json.dump(dados, arquivo, indent=4)
|
json.dump(dados, arquivo, indent=4);
|
||||||
arquivo.close()
|
arquivo.close();
|
||||||
+1680
-1840
File diff suppressed because it is too large
Load Diff
+5
-23
@@ -7,29 +7,11 @@ with open("dispositivosdata.json", "r") as f:
|
|||||||
data=json.load(f);
|
data=json.load(f);
|
||||||
|
|
||||||
for item in data:
|
for item in data:
|
||||||
loops1 = randint(1,9)
|
loops1 = randint(1,300);
|
||||||
for i in range(loops1):
|
for i in range(loops1):
|
||||||
temperatura = randint(10,40)
|
temperatura = randint(10,40);
|
||||||
umidade = randint(9,85)
|
umidade = randint(9,85);
|
||||||
myURL = "http://nexuswebdigital.com:9999/feed/{}?temperatura={}&umidade={}".format(item[0]["chave"], temperatura, umidade)
|
myURL = "http://nexuswebdigital.com:9999/feed/{}?temperatura={}&umidade={}".format(item["chave"], temperatura, umidade);
|
||||||
response = requests.post(url=myURL);
|
response = requests.post(url=myURL);
|
||||||
print(response.text);
|
print(response.text);
|
||||||
time.sleep(0.1);
|
time.sleep(0.05);
|
||||||
|
|
||||||
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);
|
|
||||||
|
|||||||
Reference in New Issue
Block a user