Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
co2
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nikita Yurishev
co2
Commits
fdbf4366
Commit
fdbf4366
authored
Aug 09, 2024
by
Nikita Yurishev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed timestrap
parent
5b1aef3d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
6 deletions
+5
-6
influxConnection.cpython-39.pyc
__pycache__/influxConnection.cpython-39.pyc
+0
-0
influxConnection.py
influxConnection.py
+5
-6
No files found.
__pycache__/influxConnection.cpython-39.pyc
View file @
fdbf4366
No preview for this file type
influxConnection.py
View file @
fdbf4366
...
...
@@ -13,8 +13,8 @@ class InfluxConnection:
# Разделение URL на хост и порт
url_parts
=
self
.
INFLUXDB_URL
.
split
(
'://'
)[
1
]
.
split
(
':'
)
host
=
url_parts
[
0
]
#port = int(url_parts[1]) if len(url_parts) > 1 else
8086
port
=
80
port
=
80
# Использование порта 80 вместо стандартного
8086
# Подключение к InfluxDB
self
.
client
=
InfluxDBClient
(
host
=
host
,
...
...
@@ -24,9 +24,7 @@ class InfluxConnection:
database
=
self
.
INFLUXDB_DB
)
# Создание базы данных (если её нет)
#self.client.create_database(self.INFLUXDB_DB)
def
write_data
(
self
,
sensor_id
,
values
):
json_body
=
[
{
...
...
@@ -34,7 +32,7 @@ class InfluxConnection:
"tags"
:
{
"sensor_id"
:
sensor_id
},
"time"
:
int
(
time
.
time
()
*
1000
),
# Текущая метка времени в милли
секундах
"time"
:
int
(
time
.
time
()
)
*
1000000000
,
# Текущая метка времени в
секундах
"fields"
:
values
}
]
...
...
@@ -46,3 +44,4 @@ class InfluxConnection:
def
__del__
(
self
):
self
.
client
.
close
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment