Use UTC time instead of timestamp
This commit is contained in:
parent
af87378fd3
commit
f01eeacbce
|
@ -7,13 +7,13 @@ logging.getLogger('aiohttp').setLevel(logging.DEBUG if os.environ.get('DEBUG') e
|
|||
|
||||
import asyncio
|
||||
from aiohttp import web
|
||||
from datetime import datetime, timedelta
|
||||
from datetime import datetime, timedelta, timezone
|
||||
import pytz
|
||||
|
||||
from APSystemsECUR import APSystemsECUR
|
||||
|
||||
ECU_IP = '192.168.69.153'
|
||||
LISTEN_IP = '192.168.69.100'
|
||||
LISTEN_IP = '192.168.69.106'
|
||||
ecu = APSystemsECUR(ECU_IP)
|
||||
app = web.Application()
|
||||
prev_ecu_timestamp = None
|
||||
|
@ -60,7 +60,7 @@ async def get_data():
|
|||
|
||||
if data['timestamp'] != prev_ecu_timestamp:
|
||||
total = 0
|
||||
timestamp = datetime.utcnow()
|
||||
utctime = datetime.now(timezone.utc)
|
||||
|
||||
for i in data['inverters'].values():
|
||||
total += i['power'][0]
|
||||
|
@ -73,7 +73,7 @@ async def get_data():
|
|||
points = []
|
||||
for i in data['inverters'].values():
|
||||
points.append({
|
||||
'time': timestamp,
|
||||
'time': utctime,
|
||||
'measurement': 'inverter',
|
||||
'tags': {'ecu': data['ecu_id'], 'inverter': i['uid']},
|
||||
'fields': {
|
||||
|
@ -85,7 +85,7 @@ async def get_data():
|
|||
})
|
||||
|
||||
points.append({
|
||||
'time': timestamp,
|
||||
'time': utctime,
|
||||
'measurement': 'panel',
|
||||
'tags': {'ecu': data['ecu_id'], 'inverter': i['uid'], 'channel': '0'},
|
||||
'fields': {
|
||||
|
@ -96,7 +96,7 @@ async def get_data():
|
|||
})
|
||||
|
||||
points.append({
|
||||
'time': timestamp,
|
||||
'time': utctime,
|
||||
'measurement': 'panel',
|
||||
'tags': {'ecu': data['ecu_id'], 'inverter': i['uid'], 'channel': '1'},
|
||||
'fields': {
|
||||
|
@ -107,7 +107,7 @@ async def get_data():
|
|||
})
|
||||
|
||||
points.append({
|
||||
'time': timestamp,
|
||||
'time': utctime,
|
||||
'measurement': 'ecu',
|
||||
'tags': {'ecu': data['ecu_id']},
|
||||
'fields': {
|
||||
|
|
Loading…
Reference in New Issue
Block a user