Compare commits
12 Commits
3-error-on
...
comes-patc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a4e7450cfd | ||
|
|
6f66e00145 | ||
|
|
8a15050614 | ||
|
|
1002ab7847 | ||
|
|
79814c7f23 | ||
|
|
2899d38167 | ||
|
|
9f3685349d | ||
|
|
0fe6abf221 | ||
|
|
d9ec3ffbee | ||
|
|
cb0b334476 | ||
|
|
81ae516367 | ||
|
|
8c266b5841 |
@@ -12,5 +12,4 @@ trim_trailing_whitespace = true
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
[*.yml]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
||||
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@2.3.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 $ecowitt_account;
|
||||
|
||||
protected $ecowitt_passphrase;
|
||||
|
||||
/**
|
||||
@@ -55,6 +56,7 @@ class EcowittExportCommand extends Command
|
||||
|
||||
if (empty($this->ecowitt_account) || empty($this->ecowitt_passphrase)) {
|
||||
$this->error('Ecowitt Username or passphrase required!');
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -66,7 +68,6 @@ class EcowittExportCommand extends Command
|
||||
$this->endDate = Carbon::parse($this->argument('endDate'))->endOfDay();
|
||||
|
||||
$device_ids->each(function ($deviceId) use ($session_id) {
|
||||
|
||||
$startDate = $this->startDate->clone();
|
||||
$endDate = $this->endDate->clone();
|
||||
// declare output variable
|
||||
@@ -91,7 +92,7 @@ class EcowittExportCommand extends Command
|
||||
|
||||
$ecowitt = $response->json();
|
||||
|
||||
$this->times = data_get($ecowitt,'times',[]);
|
||||
$this->times = data_get($ecowitt, 'times', []);
|
||||
|
||||
// Temperature in C
|
||||
$this->debug('fetch outdoor temp');
|
||||
@@ -99,7 +100,7 @@ class EcowittExportCommand extends Command
|
||||
|
||||
// Feels Like in C
|
||||
$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
|
||||
$this->debug('collecting: Dew Point in C');
|
||||
@@ -119,11 +120,18 @@ class EcowittExportCommand extends Command
|
||||
|
||||
// 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
|
||||
$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
|
||||
$this->debug('collecting: rainrate in mm/hr b');
|
||||
@@ -179,10 +187,9 @@ class EcowittExportCommand extends Command
|
||||
$outputData[] = $tmp;
|
||||
}
|
||||
$startDate = $startDate->addDay()->startOfDay();
|
||||
} while ( $startDate->lte($endDate) );
|
||||
|
||||
$this->export(getcwd() . "/ecowitt_{$deviceId}.csv", $outputData);
|
||||
} while ($startDate->lte($endDate));
|
||||
|
||||
$this->export(getcwd()."/ecowitt_{$deviceId}.csv", $outputData);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -191,6 +198,7 @@ class EcowittExportCommand extends Command
|
||||
return collect(data_get($stack, $key))
|
||||
->mapWithKeys(function ($value, $idx) {
|
||||
$dateTime = data_get($this->times, $idx);
|
||||
|
||||
return [$dateTime => $value ?: null];
|
||||
});
|
||||
}
|
||||
@@ -217,8 +225,6 @@ class EcowittExportCommand extends Command
|
||||
|
||||
/**
|
||||
* fetch all available device IDs
|
||||
* @param $session_id
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
protected function getDeviceIds($session_id): \Illuminate\Support\Collection
|
||||
{
|
||||
@@ -229,7 +235,7 @@ class EcowittExportCommand extends Command
|
||||
->asForm()
|
||||
->post('https://webapi.www.ecowitt.net/index/get_devices', [
|
||||
'uid' => '',
|
||||
'type' => 1
|
||||
'type' => 1,
|
||||
]);
|
||||
|
||||
$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
|
||||
* @param string $fileName
|
||||
* @param array $data
|
||||
*/
|
||||
protected function export(string $fileName, array $data) {
|
||||
if(isset($data['0'])){
|
||||
protected function export(string $fileName, array $data)
|
||||
{
|
||||
if (isset($data['0'])) {
|
||||
$fp = fopen($fileName, 'w+');
|
||||
fputs($fp, implode(',',array_keys($data['0'])) . "\n");
|
||||
foreach($data AS $values){
|
||||
fputs($fp, implode(',', $values) . "\n");
|
||||
fwrite($fp, implode(',', array_keys($data['0']))."\n");
|
||||
foreach ($data as $values) {
|
||||
fwrite($fp, implode(',', $values)."\n");
|
||||
}
|
||||
fclose($fp);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $msg
|
||||
* @param mixed ...$args
|
||||
* @param mixed ...$args
|
||||
*/
|
||||
protected function debug(string $msg, ...$args)
|
||||
{
|
||||
|
||||
if ($this->option('debug')) {
|
||||
$this->info($msg);
|
||||
if (!empty($args)) {
|
||||
if (! empty($args)) {
|
||||
dump($args);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,20 +8,16 @@ class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
public function boot(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Register any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
public function register(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
@@ -5,6 +5,10 @@
|
||||
"homepage": "https://github.com/comes/ecowitt2weewx",
|
||||
"type": "project",
|
||||
"license": "MIT",
|
||||
"support": {
|
||||
"issues": "https://github.com/comes/ecowitt2weewx/issues",
|
||||
"source": "https://github.com/comes/ecowitt2weewx"
|
||||
},
|
||||
"authors": [
|
||||
{
|
||||
"name": "Jeremias Wolff",
|
||||
@@ -12,15 +16,20 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": "^8.0",
|
||||
"guzzlehttp/guzzle": "^7.5",
|
||||
"illuminate/http": "^9.47",
|
||||
"laravel-zero/framework": "^9.2",
|
||||
"nesbot/carbon": "^2.65"
|
||||
"php": "^8.1",
|
||||
"laravel-zero/framework": "^10.0.2",
|
||||
"nunomaduro/termwind": "^1.15.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"laravel/pint": "^1.8",
|
||||
"mockery/mockery": "^1.5.1",
|
||||
"pestphp/pest": "^2.5"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"App\\": "app/"
|
||||
"App\\": "app/",
|
||||
"Database\\Factories\\": "database/factories/",
|
||||
"Database\\Seeders\\": "database/seeders/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
@@ -36,7 +45,7 @@
|
||||
"pestphp/pest-plugin": true
|
||||
}
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"minimum-stability": "stable",
|
||||
"prefer-stable": true,
|
||||
"bin": ["ecowitt2weewx"]
|
||||
}
|
||||
|
||||
4553
composer.lock
generated
4553
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -42,6 +42,19 @@ return [
|
||||
|
||||
'env' => 'development',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Timezone
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify the default timezone for your application, which
|
||||
| will be used by the PHP date and date-time functions. We have gone
|
||||
| ahead and set this to a sensible default for you out of the box.
|
||||
|
|
||||
*/
|
||||
|
||||
'timezone' => 'UTC',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Autoloaded Service Providers
|
||||
|
||||
@@ -56,10 +56,13 @@ return [
|
||||
|
||||
'hidden' => [
|
||||
NunoMaduro\LaravelConsoleSummary\SummaryCommand::class,
|
||||
Symfony\Component\Console\Command\DumpCompletionCommand::class,
|
||||
Symfony\Component\Console\Command\HelpCommand::class,
|
||||
Illuminate\Console\Scheduling\ScheduleRunCommand::class,
|
||||
Illuminate\Console\Scheduling\ScheduleListCommand::class,
|
||||
Illuminate\Console\Scheduling\ScheduleFinishCommand::class,
|
||||
Illuminate\Foundation\Console\VendorPublishCommand::class,
|
||||
LaravelZero\Framework\Commands\StubPublishCommand::class,
|
||||
],
|
||||
|
||||
/*
|
||||
|
||||
@@ -1,13 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit backupGlobals="false"
|
||||
backupStaticAttributes="false"
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
|
||||
bootstrap="vendor/autoload.php"
|
||||
colors="true"
|
||||
convertErrorsToExceptions="true"
|
||||
convertNoticesToExceptions="true"
|
||||
convertWarningsToExceptions="true"
|
||||
processIsolation="false"
|
||||
stopOnFailure="false">
|
||||
>
|
||||
<testsuites>
|
||||
<testsuite name="Feature">
|
||||
<directory suffix="Test.php">./tests/Feature</directory>
|
||||
@@ -16,9 +12,9 @@
|
||||
<directory suffix="Test.php">./tests/Unit</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<coverage processUncoveredFiles="true">
|
||||
<source>
|
||||
<include>
|
||||
<directory suffix=".php">./app</directory>
|
||||
</include>
|
||||
</coverage>
|
||||
</source>
|
||||
</phpunit>
|
||||
|
||||
@@ -3,15 +3,14 @@
|
||||
namespace Tests;
|
||||
|
||||
use Illuminate\Contracts\Console\Kernel;
|
||||
use Illuminate\Foundation\Application;
|
||||
|
||||
trait CreatesApplication
|
||||
{
|
||||
/**
|
||||
* Creates the application.
|
||||
*
|
||||
* @return \Illuminate\Foundation\Application
|
||||
*/
|
||||
public function createApplication()
|
||||
public function createApplication(): Application
|
||||
{
|
||||
$app = require __DIR__.'/../bootstrap/app.php';
|
||||
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
<?php
|
||||
|
||||
test('inspiring command', function () {
|
||||
$this->artisan('inspiring')
|
||||
->expectsOutput('Simplicity is the ultimate sophistication.')
|
||||
->assertExitCode(0);
|
||||
});
|
||||
@@ -1,3 +1,45 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Test Case
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The closure you provide to your test functions is always bound to a specific PHPUnit test
|
||||
| case class. By default, that class is "PHPUnit\Framework\TestCase". Of course, you may
|
||||
| need to change it using the "uses()" function to bind a different classes or traits.
|
||||
|
|
||||
*/
|
||||
|
||||
uses(Tests\TestCase::class)->in('Feature');
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Expectations
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When you're writing tests, you often need to check that values meet certain conditions. The
|
||||
| "expect()" function gives you access to a set of "expectations" methods that you can use
|
||||
| to assert different things. Of course, you may extend the Expectation API at any time.
|
||||
|
|
||||
*/
|
||||
|
||||
expect()->extend('toBeOne', function () {
|
||||
return $this->toBe(1);
|
||||
});
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Functions
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| While Pest is very powerful out-of-the-box, you may have some testing code specific to your
|
||||
| project that you don't want to repeat in every file. Here you can also expose helpers as
|
||||
| global functions to help you to reduce the number of lines of code in your test files.
|
||||
|
|
||||
*/
|
||||
|
||||
function something(): void
|
||||
{
|
||||
// ..
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user