Use UTC time instead of timestamp

This commit is contained in:
Tanner Collin 2023-01-12 18:32:20 +00:00
parent af87378fd3
commit f01eeacbce

View File

@ -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': {