Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
bkw_info_page
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Martin Müller
bkw_info_page
Commits
8435c2c1
Commit
8435c2c1
authored
Oct 20, 2022
by
root
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
daily commit
parent
3c999777
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
28 additions
and
88 deletions
+28
-88
ShellyLogController.php
app/Http/Controllers/ShellyLogController.php
+22
-10
SolarPowerMinute.php
app/Models/SolarPowerMinute.php
+1
-1
2019_08_19_000000_create_failed_jobs_table.php
...migrations/2019_08_19_000000_create_failed_jobs_table.php
+0
-36
2019_12_14_000001_create_personal_access_tokens_table.php
...2019_12_14_000001_create_personal_access_tokens_table.php
+0
-37
2022_10_13_122225_create_solar_power_minutes_table.php
...ns/2022_10_13_122225_create_solar_power_minutes_table.php
+3
-2
chart.blade.php
resources/views/chart.blade.php
+1
-1
web.php
routes/web.php
+1
-1
No files found.
app/Http/Controllers/ShellyLogController.php
View file @
8435c2c1
...
@@ -22,7 +22,7 @@ static public function test()
...
@@ -22,7 +22,7 @@ static public function test()
$sum
=
$data
[
'meters'
][
0
][
'total'
]
/
60
/
1000
;
$sum
=
$data
[
'meters'
][
0
][
'total'
]
/
60
/
1000
;
echo
round
(
$sum
,
2
)
.
'kWh -> Total <br>'
;
echo
round
(
$sum
,
2
)
.
'kWh -> Total <br>'
;
$sum_power
=
$data
[
'meters'
][
0
][
'
counters'
][
0
];
$sum_power
=
$data
[
'meters'
][
0
][
'
power'
];
echo
round
(
$sum_power
,
2
)
.
'W <br>'
;
echo
round
(
$sum_power
,
2
)
.
'W <br>'
;
}
}
...
@@ -41,25 +41,29 @@ static public function fetch_data_and_store()
...
@@ -41,25 +41,29 @@ static public function fetch_data_and_store()
$endday
=
Carbon
::
create
(
$year
,
$month
,
$day
,
23
,
59
,
59
,
'Europe/Berlin'
)
->
timestamp
;
$endday
=
Carbon
::
create
(
$year
,
$month
,
$day
,
23
,
59
,
59
,
'Europe/Berlin'
)
->
timestamp
;
$timestamp
=
Carbon
::
now
()
->
timestamp
;
$timestamp
=
Carbon
::
now
()
->
timestamp
;
$wattnow
=
$data
[
'meters'
][
0
][
'counters'
][
0
];
$wattnow
=
$data
[
'meters'
][
0
][
'power'
];
$watttotal
=
$data
[
'meters'
][
0
][
'total'
];
//$watttotal = 1558452;
$power_last
=
SolarPowerMinute
::
take
(
1
)
->
where
(
'timestamp'
,
'>'
,
$startday
)
->
where
(
'timestamp'
,
'<'
,
$endday
)
->
orderBy
(
'timestamp'
,
'desc'
)
->
get
();
$power_last
=
SolarPowerMinute
::
take
(
1
)
->
where
(
'timestamp'
,
'>'
,
$startday
)
->
where
(
'timestamp'
,
'<'
,
$endday
)
->
orderBy
(
'timestamp'
,
'desc'
)
->
get
();
$watt_total
=
$wattnow
;
$watt_total
=
0
;
foreach
(
$power_last
as
$p
)
{
foreach
(
$power_last
as
$p
)
{
if
(
empty
(
$p
->
wattminutebefore
)){
if
(
empty
(
$p
->
wattminutetotal
)){
$watt_total
=
0
;
$watt_total
=
$wattnow
;
}
else
{
}
else
{
$watt_total
=
$p
->
wattminutetotal
+
$wattnow
;
$watt_total
=
$watttotal
-
$p
->
wattminutebefore
;
if
(
$watt_total
<
0
){
$watt_total
=
0
;
}
}
}
}
}
$data_minute
=
new
SolarPowerMinute
([
$data_minute
=
new
SolarPowerMinute
([
'timestamp'
=>
$timestamp
,
'timestamp'
=>
$timestamp
,
'wattminute'
=>
$wattnow
,
'wattminute'
=>
$wattnow
,
'wattminutetotal'
=>
$watt_total
'wattminutetotal'
=>
$watt_total
,
'wattminutebefore'
=>
$watttotal
]);
]);
$data_minute
->
save
();
$data_minute
->
save
();
...
@@ -128,9 +132,17 @@ public function fetch_monthly_data() {
...
@@ -128,9 +132,17 @@ public function fetch_monthly_data() {
public
function
show_chart
()
public
function
show_chart
()
{
{
$year
=
Carbon
::
now
()
->
format
(
'Y'
);
$month
=
Carbon
::
now
()
->
format
(
'm'
);
$day
=
Carbon
::
now
()
->
format
(
'd'
);
$startday
=
Carbon
::
create
(
$year
,
$month
,
$day
,
0
,
0
,
0
,
'Europe/Berlin'
)
->
timestamp
;
$endday
=
Carbon
::
create
(
$year
,
$month
,
$day
,
23
,
59
,
59
,
'Europe/Berlin'
)
->
timestamp
;
//$devices = Devices::whereIn('devices_team', $teams_arr)->get();
//$devices = Devices::whereIn('devices_team', $teams_arr)->get();
$power_last
=
SolarPowerTenMinute
::
take
(
144
)
->
orderBy
(
'timestamp'
,
'desc'
)
->
get
();
$power_last
=
SolarPowerTenMinute
::
take
(
144
)
->
orderBy
(
'timestamp'
,
'desc'
)
->
get
();
$power_last_sum
=
SolarPowerMinute
::
take
(
1440
)
->
orderBy
(
'timestamp'
,
'desc'
)
->
get
();
$power_last_sum
=
SolarPowerMinute
::
where
(
'timestamp'
,
'>'
,
$startday
)
->
where
(
'timestamp'
,
'<'
,
$endday
)
->
orderBy
(
'timestamp'
,
'desc'
)
->
get
();
$gesamt
=
round
(
$power_last_sum
->
sum
(
'wattminute'
)
/
60
/
1000
,
2
);
$gesamt
=
round
(
$power_last_sum
->
sum
(
'wattminute'
)
/
60
/
1000
,
2
);
//dd($power_last);
//dd($power_last);
...
...
app/Models/SolarPowerMinute.php
View file @
8435c2c1
...
@@ -9,6 +9,6 @@ class SolarPowerMinute extends Model
...
@@ -9,6 +9,6 @@ class SolarPowerMinute extends Model
{
{
protected
$table
=
'solar_power_minutes'
;
protected
$table
=
'solar_power_minutes'
;
protected
$primaryKey
=
'id'
;
protected
$primaryKey
=
'id'
;
protected
$fillable
=
[
'timestamp'
,
'wattminute'
,
'wattminutetotal'
];
protected
$fillable
=
[
'timestamp'
,
'wattminute'
,
'wattminutetotal'
,
'wattminutebefore'
];
}
}
database/migrations/2019_08_19_000000_create_failed_jobs_table.php
deleted
100755 → 0
View file @
3c999777
<?php
use
Illuminate\Database\Migrations\Migration
;
use
Illuminate\Database\Schema\Blueprint
;
use
Illuminate\Support\Facades\Schema
;
return
new
class
extends
Migration
{
/**
* Run the migrations.
*
* @return void
*/
public
function
up
()
{
Schema
::
create
(
'failed_jobs'
,
function
(
Blueprint
$table
)
{
$table
->
id
();
$table
->
string
(
'uuid'
)
->
unique
();
$table
->
text
(
'connection'
);
$table
->
text
(
'queue'
);
$table
->
longText
(
'payload'
);
$table
->
longText
(
'exception'
);
$table
->
timestamp
(
'failed_at'
)
->
useCurrent
();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public
function
down
()
{
Schema
::
dropIfExists
(
'failed_jobs'
);
}
};
database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php
deleted
100755 → 0
View file @
3c999777
<?php
use
Illuminate\Database\Migrations\Migration
;
use
Illuminate\Database\Schema\Blueprint
;
use
Illuminate\Support\Facades\Schema
;
return
new
class
extends
Migration
{
/**
* Run the migrations.
*
* @return void
*/
public
function
up
()
{
Schema
::
create
(
'personal_access_tokens'
,
function
(
Blueprint
$table
)
{
$table
->
id
();
$table
->
morphs
(
'tokenable'
);
$table
->
string
(
'name'
);
$table
->
string
(
'token'
,
64
)
->
unique
();
$table
->
text
(
'abilities'
)
->
nullable
();
$table
->
timestamp
(
'last_used_at'
)
->
nullable
();
$table
->
timestamp
(
'expires_at'
)
->
nullable
();
$table
->
timestamps
();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public
function
down
()
{
Schema
::
dropIfExists
(
'personal_access_tokens'
);
}
};
database/migrations/2022_10_13_122225_create_solar_power_minutes_table.php
View file @
8435c2c1
...
@@ -16,8 +16,9 @@ public function up()
...
@@ -16,8 +16,9 @@ public function up()
Schema
::
create
(
'solar_power_minutes'
,
function
(
Blueprint
$table
)
{
Schema
::
create
(
'solar_power_minutes'
,
function
(
Blueprint
$table
)
{
$table
->
id
();
$table
->
id
();
$table
->
integer
(
'timestamp'
,
$precision
=
0
);
$table
->
integer
(
'timestamp'
,
$precision
=
0
);
$table
->
float
(
"wattminute"
,
5
,
2
);
$table
->
float
(
"wattminute"
,
6
,
2
);
$table
->
float
(
"wattminutetotal"
,
10
,
2
);
$table
->
integer
(
"wattminutetotal"
);
$table
->
integer
(
"wattminutebefore"
);
$table
->
timestampsTz
();
$table
->
timestampsTz
();
});
});
}
}
...
...
resources/views/chart.blade.php
View file @
8435c2c1
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
var
chart
=
new
CanvasJS
.
Chart
(
"chartContainer"
,
{
var
chart
=
new
CanvasJS
.
Chart
(
"chartContainer"
,
{
animationEnabled
:
false
,
animationEnabled
:
false
,
title
:
{
title
:
{
text
:
"Erzeugung
letzte 24h
({{$gesamt}}kWh)"
text
:
"Erzeugung
heute
({{$gesamt}}kWh)"
},
},
axisY
:
{
axisY
:
{
title
:
"Leistung"
,
title
:
"Leistung"
,
...
...
routes/web.php
View file @
8435c2c1
...
@@ -21,5 +21,5 @@
...
@@ -21,5 +21,5 @@
});
});
//Route::get('/test', [ShellyLogController::class, 'fetch_daily_data
']);
Route
::
get
(
'/test'
,
[
ShellyLogController
::
class
,
'test
'
]);
Route
::
get
(
'/show'
,
[
ShellyLogController
::
class
,
'show_chart'
]);
Route
::
get
(
'/show'
,
[
ShellyLogController
::
class
,
'show_chart'
]);
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment