From f01eeacbce94f2405d14c86d11dccc7d76afa8f2 Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Thu, 12 Jan 2023 18:32:20 +0000 Subject: [PATCH] Use UTC time instead of timestamp --- server/main.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/server/main.py b/server/main.py index 72f61c5..72403ad 100644 --- a/server/main.py +++ b/server/main.py @@ -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': {