Skip to content

Commit

Permalink
Add my sql support (#62)
Browse files Browse the repository at this point in the history
* Removed orderDict

* Added MySQL support and code cleanup

* Cleaned up --v1 support

* Release 2.0.5
  • Loading branch information
CharlesGodwin authored Mar 5, 2024
1 parent 5c7bcf0 commit d3d04eb
Show file tree
Hide file tree
Showing 10 changed files with 147 additions and 13 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ pymagnum.code-workspace
*.bak
credentials.txt
source/_build
docs/_build
testdata/**
testing/**
.pymodhis
Expand Down
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
=======================
pyMagnum Release Notes

Version 2.0.4 2023/11/05
------------------------
- Fixed bug in emitted JSON when using multiple devices
- Cleaned up code when using dummy data files instead of RS485 serial device
- Provided a complete dummy test file testdata/allpackets.txt
- Provided a JSON file testdata/allpackets.JSON
- Fixed All revision values are defined as string. It used to be mixed
- Enhancement --pretty option to magdump for formatted JSON output

- Fixed All revision values are defined as string. It used to be mixed
- Enhancement --pretty option to magdump for formatted JSON output
Expand Down
141 changes: 141 additions & 0 deletions allpackets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
{
"datetime":"2023-11-04T09:51:53-04:00",
"device":"MAGNUM",
"comm_device":"!testdata/allpackets.txt",
"data":[
{
"device":"INVERTER",
"data":{
"revision":"6.1",
"mode":64,
"mode_text":"INVERT",
"fault":0,
"fault_text":"None",
"vdc":24.6,
"adc":22.0,
"VACout":119.0,
"VACin":0.0,
"invled":1,
"invled_text":"On",
"chgled":0,
"chgled_text":"Off",
"bat":17.0,
"tfmr":51.0,
"fet":36.0,
"model":107,
"model_text":"MS4024PAE",
"stackmode":1,
"stackmode_text":"Parallel stack - master",
"AACin":0.0,
"AACout":5.0,
"Hz":60.0
}
},
{
"device":"REMOTE",
"data":{
"revision":4.0,
"searchwatts":0,
"batterysize":400,
"battype":8,
"absorb":0,
"chargeramps":100,
"ainput":10,
"parallel":0,
"lbco":20.0,
"vaccutout":155.0,
"vsfloat":26.4,
"vEQ":1.2,
"absorbtime":2.0,
"runtime":3.6,
"starttemp":-17.8,
"startvdc":23.0,
"quiettime":0,
"begintime":2400,
"stoptime":0,
"vdcstop":28.8,
"voltstartdelay":120,
"voltstopdelay":120,
"maxrun":12.0,
"socstart":70,
"socstop":85,
"ampstart":0.0,
"ampsstartdelay":120,
"ampstop":20,
"ampsstopdelay":120,
"quietbegintime":2330,
"quietendtime":2345,
"exercisedays":0,
"exercisestart":0,
"exerciseruntime":0,
"topoff":2,
"warmup":30,
"cool":30,
"batteryefficiency":0
}
},
{
"device":"BMK",
"data":{
"revision":"1.0",
"soc":76,
"vdc":25.45,
"adc":11.6,
"vmin":20.16,
"vmax":30.8,
"amph":-104,
"amphtrip":2046.4,
"amphout":2000,
"Fault":1,
"Fault_Text":"Normal"
}
},
{
"device":"AGS",
"data":{
"revision":"5.2",
"status":2,
"status_text":"Ready",
"running":false,
"temp":14.4,
"runtime":0.0,
"gen_last_run":0,
"last_full_soc":0,
"gen_total_run":0,
"vdc":25.4
}
},
{
"device":"RTR",
"data":{
"revision":"3"
}
},
{
"device":"PT100",
"data":{
"revision":"1.x",
"address":0,
"mode":3,
"mode_text":"Absorb",
"mode_hex":"0X13",
"regulation":1,
"regulation_text":"Voltage",
"fault":0,
"fault_text":"No Fault",
"battery":58.9,
"battery_amps":13.3,
"pv_voltage":146.8,
"charge_time":1.7,
"target_battery_voltage":29.6,
"relay_state":0,
"alarm_state":0,
"fan_on":0,
"day":1,
"battery_temperature":27.0,
"inductor_temperature":49.0,
"fet_temperature":62.0
}
}
]
}
4 changes: 1 addition & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@

# The full version, including alpha/beta/rc tags
release = '2.0'
version = '2.0.4'
=======

version = '2.0.5'

# -- General configuration ---------------------------------------------------

Expand Down
3 changes: 0 additions & 3 deletions examples/magsample.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,7 @@ def sigint_handler(signal, frame):
if args.verbose:
print(f"Magnum Sample Version:{magnum.__version__}")
print(f"Options:{str(args)[10:-1]}")


magnumReaders = {}

for device in args.device:
try:
magnumReader = Magnum(device=device, packets=args.packets, trace=args.trace,
Expand Down
1 change: 1 addition & 0 deletions examples/magsql.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ def post_data(alldata):
if field in rowdata:
if rowdata[field] != None:
value = rowdata[field]

if type(value) == bool:
if value:
value = str(1)
Expand Down
2 changes: 0 additions & 2 deletions examples/mqttlogger-2.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import sys
import time
import uuid

from datetime import datetime, timezone

import paho.mqtt.client as mqtt
Expand Down Expand Up @@ -63,7 +62,6 @@ def publish_data():
try:
devices = magnumReader.getDevices()
if len(devices) != 0:

data = {}
now = int(time.time())
data["datetime"] = datetime.now(timezone.utc).replace(
Expand Down
3 changes: 1 addition & 2 deletions magnum/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
# SPDX-License-Identifier: BSD-3-Clause
#
# BUILDINFO
__version__="2.0.4"

__version__="2.0.5"
#
# names of devices
#
Expand Down
1 change: 0 additions & 1 deletion magnum/aclddevice.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ def __init__(self, trace=False):
self.trace = True # force packet dump
self.data = {}
self.deviceData = {}

self.deviceData["device"] = ACLD
self.deviceData["data"] = self.data
if self.trace:
Expand Down
1 change: 0 additions & 1 deletion magnum/magdump.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ def main():
alldata["data"] = magnumdata
if args.allinone:
alldata = magnumReader.allinone(alldata)

commdevices.append(alldata)
except Exception as e:
print("{0} {1}".format(comm_device, str(e)))
Expand Down

0 comments on commit d3d04eb

Please sign in to comment.