Skip to content

Commit

Permalink
use github actions, deprecate circleci (jbuehl#172)
Browse files Browse the repository at this point in the history
  • Loading branch information
ericbuehl committed Dec 9, 2022
1 parent f097b3b commit 8f72df1
Show file tree
Hide file tree
Showing 16 changed files with 41 additions and 69 deletions.
41 changes: 0 additions & 41 deletions .circleci/config.yml

This file was deleted.

16 changes: 16 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: CI
on:
push
jobs:
integration:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
lfs: true
- uses: actions/setup-python@v4
with:
python-version: '3.10'
cache: 'pip'
- run: pip install -r requirements.txt
- run: test/test.sh
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![CircleCI](https://circleci.com/gh/jbuehl/solaredge.svg?style=svg)](https://circleci.com/gh/jbuehl/solaredge)
![CI](https://github.com/jbuehl/solaredge/actions/workflows/test.yml/badge.svg)

SolarEdge Monitoring
====================
Expand Down
2 changes: 1 addition & 1 deletion conversion/pickle2graphite.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
"""
Send SolarEdge performance metrics to Graphite via the graphite/carbon pickle listener port.
Expand Down
6 changes: 3 additions & 3 deletions conversion/se2MQTT.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3

# Send JSON performance data to Mosquitto MQTT Broker
#
Expand All @@ -10,11 +10,11 @@
#
#example:
#
# python2 se2MQTT.py -c solaredge -u solaredge -p s0lar3dg3 -s mosquitto.domain.local -t /ha/value/solaredge /root/solaredge/performance.json
# python3 se2MQTT.py -c solaredge -u solaredge -p s0lar3dg3 -s mosquitto.domain.local -t /ha/value/solaredge /root/solaredge/performance.json
#
# follow /root/solaredge/performance.json file and publish to topic "/ha/value/solaredge" on server "mosquitto.domain.local" with client id "solaredge" and user "solaredge" and password "s0lar3dg3"
#
# python2 semonitor.py -t 4 -d /root/solaredge/selog.txt -s 7f123456 -vvvv /dev/ttyUSB0 | python2 se2MQTT.py -c solaredge -u solaredge -p s0lar3dg3 -s mosquitto.domain.local -t /ha/value/solaredge
# python3 semonitor.py -t 4 -d /root/solaredge/selog.txt -s 7f123456 -vvvv /dev/ttyUSB0 | python3 se2MQTT.py -c solaredge -u solaredge -p s0lar3dg3 -s mosquitto.domain.local -t /ha/value/solaredge
#
# pipe output from semonitor directly into se2MQTT.py and publish to topic "/ha/value/solaredge" on server "mosquitto.domain.local" with client id "solaredge" and user "solaredge" and password "s0lar3dg3"

Expand Down
2 changes: 1 addition & 1 deletion conversion/se2csv.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3

# Convert SolarEdge inverter performance monitoring data from JSON to CSV

Expand Down
2 changes: 1 addition & 1 deletion conversion/se2graphite.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3

# send a SolarEdge performance metrics to Graphite

Expand Down
2 changes: 1 addition & 1 deletion conversion/se2state.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3

# Maintain a file containing the current state and selected statistics
# of SolarEdge inverters and optimizers
Expand Down
7 changes: 3 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
future==0.17.1
netifaces==0.10.6
pycrypto==2.6.1
pyserial==3.4
netifaces==0.11.0
pycryptodome==3.16.0
pyserial==3.5
6 changes: 3 additions & 3 deletions se/msg.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def __init__(self, key, msg0503):
curtime = datetime.datetime.now()
mystrtime = curtime.strftime("%Y-%m-%d %H:%M:%S")
# Create a key by encrypting the data from Solar Edge with our key)
enkey1 = bytes(AES.new(key).encrypt(msg0503[:16]))
enkey1 = bytes(AES.new(key, AES.MODE_ECB).encrypt(msg0503[:16]))
# Store the 0503 message in a hex string
hex_msg0503 = binascii.hexlify(msg0503)
# Format the line in the last0503.msg file
Expand All @@ -40,9 +40,9 @@ def __init__(self, key, msg0503):
# Write the outstr to the last0503.msg file, clobbering the previous (hence 'w' write mode)
ko = open(LAST0503FILE, "w")
ko.write(outstr)
ko.close
ko.close()
# self.cipher is an AES object
self.cipher = AES.new(bytes(list((enkey1[i] ^ msg0503[i + 16] for i in range(16)))))
self.cipher = AES.new(bytes(list((enkey1[i] ^ msg0503[i + 16] for i in range(16)))), AES.MODE_ECB)
self.encrypt_seq = random.randint(0, 0xffff)

def crypt(self, msg003d):
Expand Down
2 changes: 1 addition & 1 deletion semonitor.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3

# SolarEdge inverter performance monitoring using the SolarEdge protocol

Expand Down
14 changes: 6 additions & 8 deletions test/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,34 @@ set -eux

export TZ='US/Pacific'

for pcap in test/pcap/*.pcap; do
for rec in test/rec/*.rec; do
TMP=$(mktemp -d)
if [ ! -d "${TMP}" ]; then
echo "Failed to create temporary directory '${TMP}'"
break
fi
TMPSE2CSV="${TMP}/se2csv"
SAMPLE="$(basename -s ".pcap" "${pcap}")"
SAMPLE="$(basename -s ".rec" "${rec}")"
REC_OPTION="-r ${TMP}/${SAMPLE}.rec"
OUT_OPTION="-o ${TMP}/${SAMPLE}.json"
KEY_OPTION=""
if [ -f "test/keys/${SAMPLE}.key" ]; then
KEY_OPTION="-k test/keys/${SAMPLE}.key"
fi
SEMONITOR_OPTIONS="${REC_OPTION} ${OUT_OPTION} - ${KEY_OPTION} -v -x"

tshark -r "test/pcap/${SAMPLE}.pcap" -T fields -e data | xxd -r -p | ./semonitor.py ${SEMONITOR_OPTIONS}
./semonitor.py ${REC_OPTION} ${OUT_OPTION} "test/rec/${SAMPLE}.rec" ${KEY_OPTION} -v -x
diff "test/json/${SAMPLE}.json" "${TMP}/${SAMPLE}.json"
cmp -l "test/rec/${SAMPLE}.rec" "${TMP}/${SAMPLE}.rec"
cmp "test/rec/${SAMPLE}.rec" "${TMP}/${SAMPLE}.rec"
mkdir "${TMPSE2CSV}"
./conversion/se2csv.py -p "${TMPSE2CSV}/${SAMPLE}" -t < "test/json/${SAMPLE}.json"
diff "test/csv/${SAMPLE}/" "${TMPSE2CSV}/" -w

IN_OPTION="test/rec/${SAMPLE}.rec"
REC_OPTION="-r ${TMP}/${SAMPLE}.re.rec"
OUT_OPTION="-o ${TMP}/${SAMPLE}.re.json"
SEMONITOR_OPTIONS="${REC_OPTION} ${OUT_OPTION} ${IN_OPTION} ${KEY_OPTION} -v -x"
./semonitor.py ${SEMONITOR_OPTIONS}
./semonitor.py ${REC_OPTION} ${OUT_OPTION} ${IN_OPTION} ${KEY_OPTION} -v -x
diff "test/json/${SAMPLE}.json" "${TMP}/${SAMPLE}.re.json"
cmp -l "test/rec/${SAMPLE}.rec" "${TMP}/${SAMPLE}.re.rec"
cmp "test/rec/${SAMPLE}.rec" "${TMP}/${SAMPLE}.re.rec"

if [ -d "${TMP}" ] && [ "${TMP#/tmp/tmp.}x" != "${TMP}x" ]; then
rm -rf "${TMP}"
Expand Down
2 changes: 1 addition & 1 deletion utilities/se2file.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3

import time
import os
Expand Down
2 changes: 1 addition & 1 deletion utilities/sekey.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3

# Get the encryption key for an inverter

Expand Down
2 changes: 1 addition & 1 deletion utilities/seprint.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3

# print(selected data from a JSON file

Expand Down
2 changes: 1 addition & 1 deletion utilities/tinyPythonSyslogServer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3

## Tiny Syslog Server in Python.
##
Expand Down

0 comments on commit 8f72df1

Please sign in to comment.