26 lines
723 B
Python
26 lines
723 B
Python
import requests
|
|
import sys
|
|
|
|
file_name = sys.argv[1]
|
|
dptFile = open("DPT/" + file_name, 'r')
|
|
lines = dptFile.readlines()
|
|
|
|
jsonString = '['
|
|
|
|
# Concatenate data
|
|
for line in lines:
|
|
content = line.split(',')
|
|
jsonString += '[' + str(content[0]) + ', ' + str(content[1].strip()) + '],'
|
|
|
|
# Remove last comma
|
|
jsonString = jsonString[:-1]
|
|
jsonString += ']'
|
|
|
|
headers = {
|
|
'accept': '*/*',
|
|
'Authorization': 'Basic ZGVmaW5tYV9jb25uZWN0X1JuZ0B0YTJlMzViYjkyZDRjNDkyZDgwMjdkNDMyOTMxNzBkMDRfaHViOkRlZmlubWE=',
|
|
'Content-Type': 'application/json',
|
|
}
|
|
|
|
data = '{"topic":"definma_connect/Rng/things/twin/commands/modify", "path":"features/data","value":{"properties":' + jsonString + '}}'
|