27 lines
915 B
Python
27 lines
915 B
Python
|
|
import sys
|
|
import os
|
|
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
|
|
|
from dotenv import load_dotenv
|
|
load_dotenv()
|
|
from database import get_supabase_client
|
|
from datetime import datetime, timezone, timedelta
|
|
|
|
def check_today():
|
|
c = get_supabase_client()
|
|
# Today in KST
|
|
kst = timezone(timedelta(hours=9))
|
|
now = datetime.now(kst)
|
|
today_start = now.replace(hour=0, minute=0, second=0, microsecond=0)
|
|
print(f"Checking data since {today_start.isoformat()} (KST)")
|
|
|
|
res = c.table('solar_logs').select('created_at, current_kw, today_kwh, status').eq('plant_id', 'cmsolar-10').gte('created_at', today_start.isoformat()).order('created_at', desc=True).execute()
|
|
|
|
print(f"Found {len(res.data)} records for today:")
|
|
for item in res.data:
|
|
print(f"{item['created_at']} | {item.get('current_kw')} kW")
|
|
|
|
if __name__ == "__main__":
|
|
check_today()
|