Skip to content

Commit

Permalink
Merge pull request #328 from fboundy/add_workflows
Browse files Browse the repository at this point in the history
Add workflows
  • Loading branch information
fboundy authored Dec 23, 2024
2 parents 3c136b4 + e005ad7 commit bd123fa
Show file tree
Hide file tree
Showing 9 changed files with 279 additions and 876 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/auto_release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ jobs:
exit 1
fi
echo "VERSION=$VERSION"
echo "version=$VERSION" >> $GITHUB_ENV
echo "::set-output name=version::$VERSION"
echo "version=$VERSION" >> $GITHUB_ENV # Save to environment file
# Step 3: Create GitHub Release
- name: Create GitHub Release
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/black.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
- name: Run Black and isort
run: |
echo "Running black..."
black .
black --line-length=119 .
echo "Running isort..."
isort .
Expand Down
40 changes: 8 additions & 32 deletions .test/solis_cloud_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,7 @@ def get_body(self, **params):
return body

def digest(self, body: str) -> str:
return base64.b64encode(hashlib.md5(body.encode("utf-8")).digest()).decode(
"utf-8"
)
return base64.b64encode(hashlib.md5(body.encode("utf-8")).digest()).decode("utf-8")

def header(self, body: str, canonicalized_resource: str) -> dict[str, str]:
content_md5 = self.digest(body)
Expand All @@ -74,17 +72,7 @@ def header(self, body: str, canonicalized_resource: str) -> dict[str, str]:
now = datetime.now(timezone.utc)
date = now.strftime("%a, %d %b %Y %H:%M:%S GMT")

encrypt_str = (
"POST"
+ "\n"
+ content_md5
+ "\n"
+ content_type
+ "\n"
+ date
+ "\n"
+ canonicalized_resource
)
encrypt_str = "POST" + "\n" + content_md5 + "\n" + content_type + "\n" + date + "\n" + canonicalized_resource
hmac_obj = hmac.new(
self.key_secret.encode("utf-8"),
msg=encrypt_str.encode("utf-8"),
Expand All @@ -105,29 +93,23 @@ def header(self, body: str, canonicalized_resource: str) -> dict[str, str]:
def inverter_id(self):
body = self.get_body(stationId=self.plant_id)
header = self.header(body, self.URLS["inverterList"])
response = requests.post(
self.URLS["root"] + self.URLS["inverterList"], data=body, headers=header
)
response = requests.post(self.URLS["root"] + self.URLS["inverterList"], data=body, headers=header)
if response.status_code == HTTPStatus.OK:
return response.json()["data"]["page"]["records"][0].get("id", "")

@property
def inverter_sn(self):
body = self.get_body(stationId=self.plant_id)
header = self.header(body, self.URLS["inverterList"])
response = requests.post(
self.URLS["root"] + self.URLS["inverterList"], data=body, headers=header
)
response = requests.post(self.URLS["root"] + self.URLS["inverterList"], data=body, headers=header)
if response.status_code == HTTPStatus.OK:
return response.json()["data"]["page"]["records"][0].get("sn", "")

@property
def inverter_details(self):
body = self.get_body(id=self.inverter_id, sn=self.inverter_sn)
header = self.header(body, self.URLS["inverterDetail"])
response = requests.post(
self.URLS["root"] + self.URLS["inverterDetail"], data=body, headers=header
)
response = requests.post(self.URLS["root"] + self.URLS["inverterDetail"], data=body, headers=header)

if response.status_code == HTTPStatus.OK:
return response.json()["data"]
Expand All @@ -148,9 +130,7 @@ def set_code(self, cid, value):
body = self.get_body(inverterSn=self.inverter_sn, cid=cid, value=value)
headers = self.header(body, self.URLS["control"])
headers["token"] = self.token
response = requests.post(
self.URLS["root"] + self.URLS["control"], data=body, headers=headers
)
response = requests.post(self.URLS["root"] + self.URLS["control"], data=body, headers=headers)
if response.status_code == HTTPStatus.OK:
return response.json()

Expand All @@ -162,18 +142,14 @@ def read_code(self, cid):
body = self.get_body(inverterSn=self.inverter_sn, cid=cid)
headers = self.header(body, self.URLS["atRead"])
headers["token"] = self.token
response = requests.post(
self.URLS["root"] + self.URLS["atRead"], data=body, headers=headers
)
response = requests.post(self.URLS["root"] + self.URLS["atRead"], data=body, headers=headers)
if response.status_code == HTTPStatus.OK:
return response.json()["data"]["msg"]

def login(self):
body = self.get_body(username=self.username, password=self.md5passowrd)
header = self.header(body, self.URLS["login"])
response = requests.post(
self.URLS["root"] + self.URLS["login"], data=body, headers=header
)
response = requests.post(self.URLS["root"] + self.URLS["login"], data=body, headers=header)
status = response.status_code
if status == HTTPStatus.OK:
result = response.json()
Expand Down
14 changes: 2 additions & 12 deletions apps/pv_opt/.test.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,9 @@
result = query_api.query(org=org, query=query)

# Process the results
data = [
{"Time": record.get_time(), "Value": record.get_value()}
for record in result[-1].records
]
data = [{"Time": record.get_time(), "Value": record.get_value()} for record in result[-1].records]
series += [pd.DataFrame(data)]
series[-1] = (
series[-1]
.set_index("Time")
.resample("1min")
.mean()
.fillna(0)["Value"]
.rename(entity)
)
series[-1] = series[-1].set_index("Time").resample("1min").mean().fillna(0)["Value"].rename(entity)
df = pd.concat(series, axis=1)
df = df.resample("5min").mean()
# Close the client
Expand Down
Loading

0 comments on commit bd123fa

Please sign in to comment.