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
bb48b780
Commit
bb48b780
authored
Oct 14, 2022
by
root
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
First test routine
parent
35f747e2
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
37 additions
and
16 deletions
+37
-16
Kernel.php
app/Console/Kernel.php
+5
-1
ShellyLogController.php
app/Http/Controllers/ShellyLogController.php
+26
-9
app.php
config/app.php
+2
-2
database.php
config/database.php
+1
-1
2022_10_13_122225_create_solar_power_minutes_table.php
...ns/2022_10_13_122225_create_solar_power_minutes_table.php
+2
-2
web.php
routes/web.php
+1
-1
No files found.
app/Console/Kernel.php
View file @
bb48b780
...
...
@@ -17,7 +17,11 @@ class Kernel extends ConsoleKernel
protected
function
schedule
(
Schedule
$schedule
)
{
// $schedule->command('inspire')->hourly();
$schedule
->
call
(
ShellyLogController
::
class
,
'fetch_data'
)
->
everyMinute
();
$schedule
->
call
(
function
()
{
ShellyLogController
::
fetch_data
();
})
->
everyMinute
();
//$schedule->call('ShellyLogController@test')->everyMinute;
//$schedule->call('App\Http\Controllers\ShellyLogController@fetch_data')->everyMinute();
}
...
...
app/Http/Controllers/ShellyLogController.php
View file @
bb48b780
...
...
@@ -30,27 +30,44 @@ static public function fetch_data()
$data
=
json_decode
(
$json
,
true
);
$sum_power
=
$data
[
'meters'
][
0
][
'counters'
][
0
];
//echo round($sum_power, 2).'W <br>';
Carbon
::
now
()
->
format
(
'Y'
);
$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
;
//dd($startday);
$timestamp
=
Carbon
::
now
()
->
timestamp
;
$wattnow
=
$data
[
'meters'
][
0
][
'counters'
][
0
];
//$wattnow = 182.53;
$power_last
=
SolarPowerMinute
::
take
(
1
)
->
where
(
'timestamp'
,
'>'
,
$startday
)
->
where
(
'timestamp'
,
'<'
,
$endday
)
->
orderBy
(
'timestamp'
,
'desc'
)
->
get
();
$power_last
=
SolarPowerMinute
::
take
(
1
)
->
first
();
//dd($power_last);
$watt_total
=
$wattnow
;
foreach
(
$power_last
as
$p
)
{
//dd($p->timestamp);
dd
(
$power_last
);
if
(
empty
(
$p
->
wattminutetotal
)){
$watt_total
=
$wattnow
;
}
else
{
$watt_total
=
$p
->
wattminutetotal
+
$wattnow
;
}
/*if($power_last->wattminutetotal == null){
$watt_total = $wattnow;
} else {
$watt_total = $power_last->wattminutetotal + $wattnow;
}
*/
$log
=
new
SolarPowerMinute
([
'timestamp'
=>
$timestamp
,
'wattminute'
=>
$wattnow
,
'wattminutetotal'
=>
0
'wattminutetotal'
=>
$watt_total
]);
//$log->save();
$log
->
save
();
...
...
config/app.php
View file @
bb48b780
...
...
@@ -69,7 +69,7 @@
|
*/
'timezone'
=>
'
UTC
'
,
'timezone'
=>
'
Europe/Berlin
'
,
/*
|--------------------------------------------------------------------------
...
...
@@ -82,7 +82,7 @@
|
*/
'locale'
=>
'
en
'
,
'locale'
=>
'
de
'
,
/*
|--------------------------------------------------------------------------
...
...
config/database.php
View file @
bb48b780
...
...
@@ -46,7 +46,7 @@
'mysql'
=>
[
'driver'
=>
'mysql'
,
'url'
=>
env
(
'DATABASE_URL'
),
'host'
=>
env
(
'DB_HOST'
,
'1
27.0.0.1
'
),
'host'
=>
env
(
'DB_HOST'
,
'1
92.168.88.160
'
),
'port'
=>
env
(
'DB_PORT'
,
'3306'
),
'database'
=>
env
(
'DB_DATABASE'
,
'bkw_info'
),
'username'
=>
env
(
'DB_USERNAME'
,
'root'
),
...
...
database/migrations/2022_10_13_122225_create_solar_power_minutes_table.php
View file @
bb48b780
...
...
@@ -16,8 +16,8 @@ public function up()
Schema
::
create
(
'solar_power_minutes'
,
function
(
Blueprint
$table
)
{
$table
->
id
();
$table
->
integer
(
'timestamp'
,
$precision
=
0
);
$table
->
integer
(
"wattminute"
);
$table
->
integer
(
"wattminutetotal"
);
$table
->
float
(
"wattminute"
,
5
,
2
);
$table
->
float
(
"wattminutetotal"
,
10
,
2
);
$table
->
timestampsTz
();
});
}
...
...
routes/web.php
View file @
bb48b780
...
...
@@ -22,4 +22,4 @@
Route
::
get
(
'/test'
,
[
ShellyLogController
::
class
,
'test'
]);
Route
::
get
(
'/data'
,
[
ShellyLogController
::
class
,
'fetch_data'
]);
//
Route::get('/data', [ShellyLogController::class, 'fetch_data']);
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