Commit fdbf4366 authored by Nikita Yurishev's avatar Nikita Yurishev

fixed timestrap

parent 5b1aef3d
...@@ -13,8 +13,8 @@ class InfluxConnection: ...@@ -13,8 +13,8 @@ class InfluxConnection:
# Разделение URL на хост и порт # Разделение URL на хост и порт
url_parts = self.INFLUXDB_URL.split('://')[1].split(':') url_parts = self.INFLUXDB_URL.split('://')[1].split(':')
host = url_parts[0] host = url_parts[0]
#port = int(url_parts[1]) if len(url_parts) > 1 else 8086 port = 80 # Использование порта 80 вместо стандартного 8086
port = 80
# Подключение к InfluxDB # Подключение к InfluxDB
self.client = InfluxDBClient( self.client = InfluxDBClient(
host=host, host=host,
...@@ -24,9 +24,7 @@ class InfluxConnection: ...@@ -24,9 +24,7 @@ class InfluxConnection:
database=self.INFLUXDB_DB database=self.INFLUXDB_DB
) )
# Создание базы данных (если её нет)
#self.client.create_database(self.INFLUXDB_DB)
def write_data(self, sensor_id, values): def write_data(self, sensor_id, values):
json_body = [ json_body = [
{ {
...@@ -34,7 +32,7 @@ class InfluxConnection: ...@@ -34,7 +32,7 @@ class InfluxConnection:
"tags": { "tags": {
"sensor_id": sensor_id "sensor_id": sensor_id
}, },
"time": int(time.time() * 1000), # Текущая метка времени в миллисекундах "time": int(time.time())*1000000000, # Текущая метка времени в секундах
"fields": values "fields": values
} }
] ]
...@@ -46,3 +44,4 @@ class InfluxConnection: ...@@ -46,3 +44,4 @@ class InfluxConnection:
def __del__(self): def __del__(self):
self.client.close() self.client.close()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment