Compare commits
8 Commits
23e4aaefa8
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 9f72a69347 | |||
| 46e24640b5 | |||
| 81629ebfeb | |||
| 71d02abbd5 | |||
| 839c428ce6 | |||
| f9c9121975 | |||
| 2a097e4f69 | |||
| 86e5a4d2b8 |
@@ -5,7 +5,7 @@ on:
|
||||
branches: [ master ]
|
||||
schedule:
|
||||
# Run every Sunday at midnight
|
||||
- cron: '0 0 * * 0'
|
||||
- cron: '1 0 * * 0'
|
||||
|
||||
env:
|
||||
IMAGE: /home/power-consumption
|
||||
@@ -21,13 +21,29 @@ jobs:
|
||||
steps:
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
with:
|
||||
buildkitd-flags: '--allow-insecure-entitlement network.host'
|
||||
driver-opts: network=host
|
||||
|
||||
- name: Log into registry
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ${{ secrets.REGISTRY_URL }}
|
||||
username: ${{ secrets.REGISTRY_USER }}
|
||||
password: ${{ secrets.REGISTRY_PASS }}
|
||||
username: ${{ vars.DOCKERHUB_USER }}
|
||||
password: ${{ vars.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Log into CS registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ${{ vars.CS_REGISTRY_URL }}
|
||||
username: ${{ vars.CS_REGISTRY_USER }}
|
||||
password: ${{ vars.CS_REGISTRY_PASS }}
|
||||
|
||||
- name: Log into local registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ${{ vars.LOCAL_REGISTRY_URL }}
|
||||
username: ${{ vars.LOCAL_REGISTRY_USER }}
|
||||
password: ${{ vars.LOCAL_REGISTRY_PASS }}
|
||||
|
||||
- name: Extract Docker metadata
|
||||
id: meta
|
||||
@@ -36,24 +52,25 @@ jobs:
|
||||
images: ${{ secrets.REGISTRY_URL }}${{ env.IMAGE }}
|
||||
|
||||
- name: Build and push Docker image
|
||||
uses: docker/build-push-action@v4
|
||||
uses: docker/build-push-action@v6
|
||||
env:
|
||||
ACTIONS_RUNTIME_TOKEN: ''
|
||||
with:
|
||||
tags: ${{ secrets.REGISTRY_URL }}${{ env.IMAGE }}:latest
|
||||
allow: network.host
|
||||
network: host
|
||||
tags: ${{ vars.LOCAL_REGISTRY_URL }}${{ env.IMAGE }}:latest
|
||||
push: true
|
||||
|
||||
- name: Scan image
|
||||
uses: anchore/scan-action@v6
|
||||
id: scan
|
||||
with:
|
||||
image: ${{ secrets.REGISTRY_URL }}${{ env.IMAGE }}:latest
|
||||
image: ${{ vars.LOCAL_REGISTRY_URL }}${{ env.IMAGE }}:latest
|
||||
fail-build: false
|
||||
output-format: table
|
||||
severity-cutoff: critical
|
||||
registry-username: ${{ secrets.REGISTRY_USER }}
|
||||
registry-password: ${{ secrets.REGISTRY_PASS }}
|
||||
grype-version: 'v0.90.0'
|
||||
registry-username: ${{ vars.LOCAL_REGISTRY_USER }}
|
||||
registry-password: ${{ vars.LOCAL_REGISTRY_PASS }}
|
||||
|
||||
- name: Inspect file
|
||||
run: cat ${{ steps.scan.outputs.table }}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM cs-git.ddnss.de/docker/nginx-fpm-8-4
|
||||
FROM gitea.fam-steinle.de/docker/nginx-fpm-8-4
|
||||
|
||||
ENV SERVE_PATH=/public
|
||||
|
||||
|
||||
@@ -106,14 +106,15 @@ function get_grid_feed_by_month(mysqli $db, string $table_aggregation, string $t
|
||||
$price_result = $db->query($price_query);
|
||||
|
||||
$price = [];
|
||||
while ($row = $price_result->fetch_assoc()) {
|
||||
$price[$row['year'] . '-' . str_pad($row['month'], 2, '0', STR_PAD_LEFT)] = $row['price'];
|
||||
while ($price_row = $price_result->fetch_assoc()) {
|
||||
$price[$price_row['year'] . '-' . str_pad($price_row['month'], 2, '0', STR_PAD_LEFT)] = $price_row['price'];
|
||||
}
|
||||
|
||||
$grid_feed_by_month = [];
|
||||
|
||||
while ($row = $feed_result->fetch_assoc()) {
|
||||
$grid_feed_by_month[$row['year'] . '-' . str_pad($row['month'], 2, '0', STR_PAD_LEFT)] = $row['SUM(grid_feed)'] * $price[$row['year'] . '-' . str_pad($row['month'], 2, '0', STR_PAD_LEFT)] / 100000;
|
||||
$key = $row['year'] . '-' . str_pad($row['month'], 2, '0', STR_PAD_LEFT);
|
||||
$price[$key] = $price[$key] ?? 0;
|
||||
$grid_feed_by_month[$key] = $row['SUM(grid_feed)'] * $price[$key] / 100000;
|
||||
}
|
||||
|
||||
return $grid_feed_by_month;
|
||||
|
||||
@@ -47,6 +47,7 @@ button, .button {
|
||||
color: rgb(0, 0, 0);
|
||||
font-size: 1.3rem;
|
||||
padding: 8px 0;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#chart-container {
|
||||
|
||||
@@ -45,9 +45,11 @@ $chosen_date_time = new DateTime($chosen_date);
|
||||
if ($dates['first'] < $chosen_date_time) {
|
||||
echo "<button type='button' onclick='submit_form(\"" . $chosen_date_time->modify('-1 month')->format('Y-m') . "\")'><</button>";
|
||||
} else {
|
||||
$chosen_date_time->modify('-1 month');
|
||||
echo '<span></span>';
|
||||
}
|
||||
echo '<span style="text-align: center">' . $chosen_date_time->modify('+1 month')->format('Y-m') . '</span>';
|
||||
$chosen_date_time->modify('+1 month');
|
||||
echo '<span style="text-align: center">' . $chosen_date_time->format('Y-m') . '</span>';
|
||||
if ($dates['last'] > $chosen_date_time->modify('+1 month')) {
|
||||
echo "<button type='button' onclick='submit_form(\"" . $chosen_date_time->format('Y-m') . "\")'>></button>";
|
||||
} else {
|
||||
|
||||
@@ -45,11 +45,11 @@ $chosen_date_time = new DateTime($chosen_date);
|
||||
<title>Consumption values</title>
|
||||
<link rel="stylesheet" href="/css/layout.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<form id="date_form" style="align-self: center; width: 500px; display: grid; grid-template-columns: 20% 20% 20% 20% 20%; gap: 10px;" action="/production.php" method="post">
|
||||
<body style="max-width: 1000px; align-self: center; margin: 0 auto;">
|
||||
<form id="date_form" style="display: grid; grid-template-columns: 20% 20% 20% 20% 20%; gap: 10px;" action="/production.php" method="post">
|
||||
<?php
|
||||
if ($dates['first'] < $chosen_date_time) {
|
||||
echo "<button type='button' onclick='submit_form(\"" . $chosen_date_time->modify('-1 month')->format('Y-m') . "\")'><</button>";
|
||||
echo "<button type='button' onclick='submit_form(\"" . $chosen_date_time->modify('-1 month')->format('Y-m') . "\")'><</button>\n";
|
||||
} else {
|
||||
echo '<span></span>';
|
||||
}
|
||||
@@ -66,7 +66,7 @@ $chosen_date_time = new DateTime($chosen_date);
|
||||
</form>
|
||||
|
||||
<form action="production.php" method="post"
|
||||
style="display: grid; grid-template-columns: 15% 12% 10% 10% 12%; gap: 2px 10px; margin-top: 10px; font-size: 1.3rem;">
|
||||
style="display: grid; grid-template-columns: 20% 20% 20% 20% 20%; gap: 2px 10px; margin-top: 10px; font-size: 1.3rem; border-top: 2px solid gray; padding-top: 20px;">
|
||||
<?php
|
||||
foreach ($production_values as $daily_production) {
|
||||
?>
|
||||
|
||||
@@ -11,6 +11,10 @@ $chosen_year = (isset($_POST['year'])) ? $_POST['year'] : date('Y');
|
||||
$years = get_years($local_db, $table_aggregation);
|
||||
$values = get_year_values($local_db, $table_aggregation, $chosen_year);
|
||||
|
||||
$aggregation = get_year_aggregation($local_db, $table_aggregation, $chosen_year);
|
||||
$year_production = get_year_production($local_db, $table_production, $chosen_year);
|
||||
$grid_feed_by_month = get_grid_feed_by_month($local_db, $table_aggregation, $table_production, $chosen_year);
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
@@ -41,6 +45,37 @@ $values = get_year_values($local_db, $table_aggregation, $chosen_year);
|
||||
<a class="button" href="production.php">Werte</a>
|
||||
<input type="hidden" name="year" id="year" value=""/>
|
||||
</form>
|
||||
|
||||
<div style="display: grid; grid-template-columns: 5% 15% 15%; gap: 2px 10px; margin-top: 5px; border-top: 2px solid gray; padding-top: 5px;">
|
||||
<span class="color"></span>
|
||||
<label><b>Messung</b></label>
|
||||
<span><b>Jahr</b></span>
|
||||
|
||||
<span class="color color-1"></span>
|
||||
<label>Verbrauch</label>
|
||||
<span><?php echo number_format($aggregation['meter_consumption'], 1, ',', '.'); ?> KWh</span>
|
||||
|
||||
<span class="color color-2"></span>
|
||||
<label>Berechnet</label>
|
||||
<span><?php echo number_format($aggregation['power_sensor'], 1, ',', '.'); ?> KWh</span>
|
||||
|
||||
<span class="color color-3"></span>
|
||||
<label>Einspeisung</label>
|
||||
<span><?php echo number_format($aggregation['grid_feed'], 1, ',', '.'); ?> KWh</span>
|
||||
|
||||
<span class="color color-4"></span>
|
||||
<label>Produktion</label>
|
||||
<span><?php echo number_format($year_production['eg'] + $year_production['og'], 1, ',', '.'); ?> KWh</span>
|
||||
|
||||
<span class="color"></span>
|
||||
<label><b>Ersparnis</b></label>
|
||||
<span><b><?php echo number_format(($year_production['eg_price'] + $year_production['og_price'] - array_sum($grid_feed_by_month)), 2, ',', '.'); ?> €</b></span>
|
||||
|
||||
<span class="color"></span>
|
||||
<label><b>Eigenverbrauch</b></label>
|
||||
<span><b><?php echo number_format(100 - $aggregation['grid_feed'] * 100 / ($year_production['eg'] + $year_production['og']), 2, ',', '.'); ?> %</b></span>
|
||||
</div>
|
||||
|
||||
<div id="chart-container">
|
||||
<canvas id="chart"></canvas>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user