Compare commits
9 Commits
upgrade-10
...
comes-patc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3ccaa232c8 | ||
|
|
1002ab7847 | ||
|
|
79814c7f23 | ||
|
|
2899d38167 | ||
|
|
9f3685349d | ||
|
|
0fe6abf221 | ||
|
|
d9ec3ffbee | ||
|
|
81ae516367 | ||
|
|
f629fa5f29 |
23
.github/workflows/pint.yml
vendored
Normal file
23
.github/workflows/pint.yml
vendored
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
name: PHP Linting (Pint)
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
push:
|
||||||
|
branches-ignore:
|
||||||
|
- 'dependabot/npm_and_yarn/*'
|
||||||
|
jobs:
|
||||||
|
phplint:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
fetch-depth: 2
|
||||||
|
- name: "laravel-pint"
|
||||||
|
uses: aglipanci/laravel-pint-action@0.1.0
|
||||||
|
with:
|
||||||
|
preset: laravel
|
||||||
|
|
||||||
|
- name: Commit changes
|
||||||
|
uses: stefanzweifel/git-auto-commit-action@v4
|
||||||
|
with:
|
||||||
|
commit_message: PHP Linting (Pint)
|
||||||
|
skip_fetch: true
|
||||||
@@ -15,6 +15,7 @@ class EcowittExportCommand extends Command
|
|||||||
protected $endDate;
|
protected $endDate;
|
||||||
|
|
||||||
protected $ecowitt_account;
|
protected $ecowitt_account;
|
||||||
|
|
||||||
protected $ecowitt_passphrase;
|
protected $ecowitt_passphrase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -55,6 +56,7 @@ class EcowittExportCommand extends Command
|
|||||||
|
|
||||||
if (empty($this->ecowitt_account) || empty($this->ecowitt_passphrase)) {
|
if (empty($this->ecowitt_account) || empty($this->ecowitt_passphrase)) {
|
||||||
$this->error('Ecowitt Username or passphrase required!');
|
$this->error('Ecowitt Username or passphrase required!');
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,7 +68,6 @@ class EcowittExportCommand extends Command
|
|||||||
$this->endDate = Carbon::parse($this->argument('endDate'))->endOfDay();
|
$this->endDate = Carbon::parse($this->argument('endDate'))->endOfDay();
|
||||||
|
|
||||||
$device_ids->each(function ($deviceId) use ($session_id) {
|
$device_ids->each(function ($deviceId) use ($session_id) {
|
||||||
|
|
||||||
$startDate = $this->startDate->clone();
|
$startDate = $this->startDate->clone();
|
||||||
$endDate = $this->endDate->clone();
|
$endDate = $this->endDate->clone();
|
||||||
// declare output variable
|
// declare output variable
|
||||||
@@ -91,7 +92,7 @@ class EcowittExportCommand extends Command
|
|||||||
|
|
||||||
$ecowitt = $response->json();
|
$ecowitt = $response->json();
|
||||||
|
|
||||||
$this->times = data_get($ecowitt,'times',[]);
|
$this->times = data_get($ecowitt, 'times', []);
|
||||||
|
|
||||||
// Temperature in C
|
// Temperature in C
|
||||||
$this->debug('fetch outdoor temp');
|
$this->debug('fetch outdoor temp');
|
||||||
@@ -99,7 +100,7 @@ class EcowittExportCommand extends Command
|
|||||||
|
|
||||||
// Feels Like in C
|
// Feels Like in C
|
||||||
$this->debug('fetch outdoor temp gust');
|
$this->debug('fetch outdoor temp gust');
|
||||||
$outdoorTempGust = $this->getData($ecowitt, 'list.tempf.list.sendible_temp');
|
$outdoorTempGust = $this->getData($ecowitt, 'list.tempf.list.apparent_temp');
|
||||||
|
|
||||||
// Dew Point in C
|
// Dew Point in C
|
||||||
$this->debug('collecting: Dew Point in C');
|
$this->debug('collecting: Dew Point in C');
|
||||||
@@ -119,11 +120,18 @@ class EcowittExportCommand extends Command
|
|||||||
|
|
||||||
// solar in lx -- Solar and UVI
|
// solar in lx -- Solar and UVI
|
||||||
$this->debug('collecting: solar in lx -- Solar and UVI');
|
$this->debug('collecting: solar in lx -- Solar and UVI');
|
||||||
$solarradiation = $this->getData($ecowitt, 'list.solarradiation.list.solarradiation');
|
$solarradiation = $this->getData($ecowitt, 'list.so_uv.list.solarradiation');
|
||||||
|
|
||||||
// uv
|
// uv
|
||||||
$this->debug('collecting: uv');
|
$this->debug('collecting: uv');
|
||||||
$uvi = $this->getData($ecowitt, 'list.uv.list.uv');
|
$uvi = $this->getData($ecowitt, 'list.so_uv.list.uv');
|
||||||
|
|
||||||
|
//replace empty values with 0
|
||||||
|
foreach ($uvi as $key => $value) {
|
||||||
|
if (empty($value)) {
|
||||||
|
$uvi[$key] = '0';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// rainrate in mm/hr b
|
// rainrate in mm/hr b
|
||||||
$this->debug('collecting: rainrate in mm/hr b');
|
$this->debug('collecting: rainrate in mm/hr b');
|
||||||
@@ -179,10 +187,9 @@ class EcowittExportCommand extends Command
|
|||||||
$outputData[] = $tmp;
|
$outputData[] = $tmp;
|
||||||
}
|
}
|
||||||
$startDate = $startDate->addDay()->startOfDay();
|
$startDate = $startDate->addDay()->startOfDay();
|
||||||
} while ( $startDate->lte($endDate) );
|
} while ($startDate->lte($endDate));
|
||||||
|
|
||||||
$this->export(getcwd() . "/ecowitt_{$deviceId}.csv", $outputData);
|
|
||||||
|
|
||||||
|
$this->export(getcwd()."/ecowitt_{$deviceId}.csv", $outputData);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -191,6 +198,7 @@ class EcowittExportCommand extends Command
|
|||||||
return collect(data_get($stack, $key))
|
return collect(data_get($stack, $key))
|
||||||
->mapWithKeys(function ($value, $idx) {
|
->mapWithKeys(function ($value, $idx) {
|
||||||
$dateTime = data_get($this->times, $idx);
|
$dateTime = data_get($this->times, $idx);
|
||||||
|
|
||||||
return [$dateTime => $value ?: null];
|
return [$dateTime => $value ?: null];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -217,8 +225,6 @@ class EcowittExportCommand extends Command
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* fetch all available device IDs
|
* fetch all available device IDs
|
||||||
* @param $session_id
|
|
||||||
* @return \Illuminate\Support\Collection
|
|
||||||
*/
|
*/
|
||||||
protected function getDeviceIds($session_id): \Illuminate\Support\Collection
|
protected function getDeviceIds($session_id): \Illuminate\Support\Collection
|
||||||
{
|
{
|
||||||
@@ -229,7 +235,7 @@ class EcowittExportCommand extends Command
|
|||||||
->asForm()
|
->asForm()
|
||||||
->post('https://webapi.www.ecowitt.net/index/get_devices', [
|
->post('https://webapi.www.ecowitt.net/index/get_devices', [
|
||||||
'uid' => '',
|
'uid' => '',
|
||||||
'type' => 1
|
'type' => 1,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$devices = collect(data_get($deviceResponse->json(), 'device_list'));
|
$devices = collect(data_get($deviceResponse->json(), 'device_list'));
|
||||||
@@ -241,34 +247,29 @@ class EcowittExportCommand extends Command
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Takes in a filename and an array associative data array and outputs a csv file
|
* Takes in a filename and an array associative data array and outputs a csv file
|
||||||
* @param string $fileName
|
|
||||||
* @param array $data
|
|
||||||
*/
|
*/
|
||||||
protected function export(string $fileName, array $data) {
|
protected function export(string $fileName, array $data)
|
||||||
if(isset($data['0'])){
|
{
|
||||||
|
if (isset($data['0'])) {
|
||||||
$fp = fopen($fileName, 'w+');
|
$fp = fopen($fileName, 'w+');
|
||||||
fputs($fp, implode(',',array_keys($data['0'])) . "\n");
|
fwrite($fp, implode(',', array_keys($data['0']))."\n");
|
||||||
foreach($data AS $values){
|
foreach ($data as $values) {
|
||||||
fputs($fp, implode(',', $values) . "\n");
|
fwrite($fp, implode(',', $values)."\n");
|
||||||
}
|
}
|
||||||
fclose($fp);
|
fclose($fp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $msg
|
* @param mixed ...$args
|
||||||
* @param mixed ...$args
|
|
||||||
*/
|
*/
|
||||||
protected function debug(string $msg, ...$args)
|
protected function debug(string $msg, ...$args)
|
||||||
{
|
{
|
||||||
|
|
||||||
if ($this->option('debug')) {
|
if ($this->option('debug')) {
|
||||||
$this->info($msg);
|
$this->info($msg);
|
||||||
if (!empty($args)) {
|
if (! empty($args)) {
|
||||||
dump($args);
|
dump($args);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user