first commit
This commit is contained in:
3
Requirements.txt
Normal file
3
Requirements.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
requests
|
||||
vedirect
|
||||
flask
|
||||
BIN
dist/victrondata.exe
vendored
Normal file
BIN
dist/victrondata.exe
vendored
Normal file
Binary file not shown.
12
testapi.py
Normal file
12
testapi.py
Normal file
@@ -0,0 +1,12 @@
|
||||
import requests
|
||||
import json
|
||||
|
||||
url = r"https://carlapi.bteam.construction/orange/battery_info"
|
||||
response = requests.get(url)
|
||||
data = response.json()
|
||||
print(data)
|
||||
|
||||
url = r"https://carlapi.bteam.construction/orange/mppt_info"
|
||||
response = requests.get(url)
|
||||
data = response.json()
|
||||
print(data)
|
||||
47
victrondata.py
Normal file
47
victrondata.py
Normal file
@@ -0,0 +1,47 @@
|
||||
import vedirect
|
||||
import json
|
||||
from flask import Flask, jsonify, request
|
||||
app = Flask(__name__)
|
||||
|
||||
@app.route('/orange/battery_info', methods=['GET'])
|
||||
def get_battery_data():
|
||||
device = vedirect.VEDirect("COM3")
|
||||
volts = float(str(device._get_data( )[0].decode('ascii')).strip().split("\t")[1])/1000.0
|
||||
power_usage = int(str(device._get_data( )[2].decode('ascii')).strip().split("\t")[1])
|
||||
battery_percentage = int(str(device._get_data( )[4].decode('ascii')).strip().split("\t")[1])/10
|
||||
|
||||
battery_data = { 'draw' : power_usage, 'percentage' : battery_percentage, 'voltage' : volts }
|
||||
return jsonify(battery_data)
|
||||
|
||||
@app.route('/orange/mppt_info', methods=['GET'])
|
||||
def get_mppt_data():
|
||||
mppt_device = vedirect.VEDirect("COM4")
|
||||
wh_used_today = int(str(mppt_device._get_data( )[12].decode('ascii')).strip().split("\t")[1]) * 10
|
||||
peak_charge_rate_today = int(str(mppt_device._get_data( )[13].decode('ascii')).strip().split("\t")[1])
|
||||
wh_used_yesterday = int(str(mppt_device._get_data( )[14].decode('ascii')).strip().split("\t")[1]) * 10
|
||||
peak_charge_rate_yesterday = int(str(mppt_device._get_data( )[15].decode('ascii')).strip().split("\t")[1])
|
||||
|
||||
mppt_data = { 'current draw' : mppt_device.solar_power, 'todays_wh' : wh_used_today, 'todays_peak' : peak_charge_rate_today, 'yesterdays_wh' : wh_used_yesterday, 'yesterdays_peak' : peak_charge_rate_yesterday }
|
||||
return jsonify(mppt_data)
|
||||
# device = vedirect.VEDirect("COM3")
|
||||
# volts = float(str(device._get_data( )[0].decode('ascii')).strip().split("\t")[1])/1000.0
|
||||
# power_usage = int(str(device._get_data( )[2].decode('ascii')).strip().split("\t")[1])
|
||||
# battery_percentage = int(str(device._get_data( )[4].decode('ascii')).strip().split("\t")[1])/10
|
||||
# print("Battery Percent:", battery_percentage)
|
||||
# print("Battery Voltage:", volts)
|
||||
# print("Current Battery Draw:", power_usage, "watts")
|
||||
|
||||
# mppt_device = vedirect.VEDirect("COM4")
|
||||
# kwh_used_today = int(str(mppt_device._get_data( )[12].decode('ascii')).strip().split("\t")[1]) * 10
|
||||
# peak_charge_rate_today = int(str(mppt_device._get_data( )[13].decode('ascii')).strip().split("\t")[1])
|
||||
# kwh_used_yesterday = int(str(mppt_device._get_data( )[14].decode('ascii')).strip().split("\t")[1]) * 10
|
||||
# peak_charge_rate_yesterday = int(str(mppt_device._get_data( )[15].decode('ascii')).strip().split("\t")[1])
|
||||
# print("Solar Power being used:", mppt_device.solar_power, "watts")
|
||||
# print("Todays Generated Power:", kwh_used_today, "Wh")
|
||||
# print("Todays Peak Charge Rate:", peak_charge_rate_today, "Wh")
|
||||
# print("Yesterdayss Generated Power:", kwh_used_yesterday, "Wh")
|
||||
# print("Yesterdays Peak Charge Rate:", peak_charge_rate_yesterday, "Wh")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run(port=1099)
|
||||
38
victrondata.spec
Normal file
38
victrondata.spec
Normal file
@@ -0,0 +1,38 @@
|
||||
# -*- mode: python ; coding: utf-8 -*-
|
||||
|
||||
|
||||
a = Analysis(
|
||||
['victrondata.py'],
|
||||
pathex=[],
|
||||
binaries=[],
|
||||
datas=[],
|
||||
hiddenimports=['win32timezone'],
|
||||
hookspath=[],
|
||||
hooksconfig={},
|
||||
runtime_hooks=[],
|
||||
excludes=[],
|
||||
noarchive=False,
|
||||
optimize=0,
|
||||
)
|
||||
pyz = PYZ(a.pure)
|
||||
|
||||
exe = EXE(
|
||||
pyz,
|
||||
a.scripts,
|
||||
a.binaries,
|
||||
a.datas,
|
||||
[],
|
||||
name='victrondata',
|
||||
debug=False,
|
||||
bootloader_ignore_signals=False,
|
||||
strip=False,
|
||||
upx=True,
|
||||
upx_exclude=[],
|
||||
runtime_tmpdir=None,
|
||||
console=True,
|
||||
disable_windowed_traceback=False,
|
||||
argv_emulation=False,
|
||||
target_arch=None,
|
||||
codesign_identity=None,
|
||||
entitlements_file=None,
|
||||
)
|
||||
Reference in New Issue
Block a user