-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 727bad6
Showing
7 changed files
with
138 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
version: 2 | ||
updates: | ||
- package-ecosystem: "docker" | ||
directory: "web_server/" | ||
schedule: | ||
interval: "daily" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
--- | ||
name: Linting | ||
|
||
on: # yamllint disable-line rule:truthy | ||
push: | ||
branches-ignore: | ||
- master | ||
|
||
workflow_dispatch: | ||
|
||
permissions: read-all | ||
|
||
jobs: | ||
check: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
issues: write | ||
pull-requests: write | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
token: ${{ secrets.CUSTOM_PTA }} | ||
|
||
- name: Lint Code Base with MegaLinter | ||
uses: oxsecurity/megalinter/flavors/python@beta | ||
env: | ||
VALIDATE_ALL_CODEBASE: true | ||
DEFAULT_BRANCH: master | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
megalinter-reports/ | ||
.ruff_cache | ||
api.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
DISABLE_LINTERS: | ||
- SPELL_CSPELL | ||
SHOW_ELAPSED_TIME: true | ||
ENABLE_LINTERS: | ||
- YAML_YAMLLINT | ||
- MARKDOWN_MARKDOWNLINT | ||
- PYTHON_PYLINT | ||
- PYTHON_BLACK | ||
- PYTHON_FLAKE8 | ||
- DOCKERFILE_HADOLINT | ||
ANSIBLE_DIRECTORY: . | ||
PRE_COMMANDS: | ||
- command: pip install requests | ||
venv: requests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
""" | ||
Importing data from the Fronius device. | ||
""" | ||
import requests # pylint: disable=import-error | ||
from requests.exceptions import HTTPError # pylint: disable=import-error | ||
|
||
with open("api.txt", "r", encoding="utf8") as file: | ||
URL = file.read().rstrip() | ||
|
||
# URL = "http://localhost:8080/GetPowerFlowRealtimeData.fcgi" | ||
|
||
|
||
def check_values(): | ||
""" | ||
Actual logic of getting the JSON file with data and analyzing parts of it. | ||
""" | ||
try: | ||
response = requests.get(URL, timeout=5) | ||
response.raise_for_status() | ||
jsondata = response.json() | ||
|
||
print("Timestamp:", jsondata["Head"]["Timestamp"]) | ||
print("Currently:", jsondata["Body"]["Data"]["Site"]["P_PV"]) | ||
print("Day:", jsondata["Body"]["Data"]["Site"]["E_Day"]) | ||
print("Year:", jsondata["Body"]["Data"]["Site"]["E_Year"]) | ||
print("Total:", jsondata["Body"]["Data"]["Site"]["E_Total"]) | ||
|
||
except HTTPError as http_err: | ||
print(f"HTTP error occurred: {http_err}") | ||
except Exception as err: # pylint: disable=broad-except | ||
print(f"Other error occurred: {err}") | ||
|
||
|
||
if __name__ == "__main__": | ||
check_values() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
FROM nginx:1.25.2 | ||
|
||
HEALTHCHECK CMD curl --fail http://localhost:80 || exit 1 | ||
|
||
LABEL testing-service="Mocking Fronius Inverter" | ||
USER nginx | ||
|
||
COPY GetPowerFlowRealtimeData.fcgi /usr/share/nginx/html/GetPowerFlowRealtimeData.fcgi | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"Body" : { | ||
"Data" : { | ||
"Inverters" : { | ||
"1" : { | ||
"DT" : 110, | ||
"E_Day" : 5961, | ||
"E_Total" : 236993, | ||
"E_Year" : 236993.109375, | ||
"P" : 1091 | ||
} | ||
}, | ||
"Site" : { | ||
"E_Day" : 5961, | ||
"E_Total" : 236993, | ||
"E_Year" : 236993.109375, | ||
"Meter_Location" : "unknown", | ||
"Mode" : "produce-only", | ||
"P_Akku" : null, | ||
"P_Grid" : null, | ||
"P_Load" : null, | ||
"P_PV" : 1091, | ||
"rel_Autonomy" : null, | ||
"rel_SelfConsumption" : null | ||
}, | ||
"Version" : "12" | ||
} | ||
}, | ||
"Head" : { | ||
"RequestArguments" : {}, | ||
"Status" : { | ||
"Code" : 0, | ||
"Reason" : "", | ||
"UserMessage" : "" | ||
}, | ||
"Timestamp" : "2021-05-06T14:54:37+03:00" | ||
} | ||
} |