upgrade to 10.x

This commit is contained in:
Jeremias Wolff
2023-04-18 20:40:09 +02:00
parent b382d98c10
commit 8c266b5841
11 changed files with 3152 additions and 1767 deletions

View File

@@ -12,5 +12,4 @@ trim_trailing_whitespace = true
trim_trailing_whitespace = false trim_trailing_whitespace = false
[*.yml] [*.yml]
indent_style = space
indent_size = 2 indent_size = 2

250
README.md
View File

@@ -1,236 +1,40 @@
# Restore weewx Database from Ecowitt.net <a href="https://supportukrainenow.org/"><img src="https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/banner-direct.svg" width="100%"></a>
**PRs welcome!** ------
## General <p align="center">
<img title="Laravel Zero" height="100" src="https://raw.githubusercontent.com/laravel-zero/docs/master/images/logo/laravel-zero-readme.png" />
</p>
In case your weather station send all data to ecowitt.net and you lost your weewx database, <p align="center">
this huge cannonball will help you to reintegrate your data. build with https://laravel-zero.com <a href="https://github.com/laravel-zero/framework/actions"><img src="https://github.com/laravel-zero/laravel-zero/actions/workflows/tests.yml/badge.svg" alt="Build Status"></img></a>
<a href="https://packagist.org/packages/laravel-zero/framework"><img src="https://img.shields.io/packagist/dt/laravel-zero/framework.svg" alt="Total Downloads"></a>
<a href="https://packagist.org/packages/laravel-zero/framework"><img src="https://img.shields.io/packagist/v/laravel-zero/framework.svg?label=stable" alt="Latest Stable Version"></a>
<a href="https://packagist.org/packages/laravel-zero/framework"><img src="https://img.shields.io/packagist/l/laravel-zero/framework.svg" alt="License"></a>
</p>
The steps are easy. <h4> <center>This is a <bold>community project</bold> and not an official Laravel one </center></h4>
Laravel Zero was created by [Nuno Maduro](https://github.com/nunomaduro) and [Owen Voke](https://github.com/owenvoke), and is a micro-framework that provides an elegant starting point for your console application. It is an **unofficial** and customized version of Laravel optimized for building command-line applications.
### 1. Export and Convert - Built on top of the [Laravel](https://laravel.com) components.
- Optional installation of Laravel [Eloquent](https://laravel-zero.com/docs/database/), Laravel [Logging](https://laravel-zero.com/docs/logging/) and many others.
- Supports interactive [menus](https://laravel-zero.com/docs/build-interactive-menus/) and [desktop notifications](https://laravel-zero.com/docs/send-desktop-notifications/) on Linux, Windows & MacOS.
- Ships with a [Scheduler](https://laravel-zero.com/docs/task-scheduling/) and a [Standalone Compiler](https://laravel-zero.com/docs/build-a-standalone-application/).
- Integration with [Collision](https://github.com/nunomaduro/collision) - Beautiful error reporting
This simple tool will login into your ecowitt.net account, fetch all available devices and download all available data ------
for the range between `startdate` and `enddate`.
```sh ## Documentation
./ecowitt2weewx export --user <ecowitt username> --pass <ecowitt password> start_date end_date
```
example For full documentation, visit [laravel-zero.com](https://laravel-zero.com/).
```sh
./ecowitt2weewx export --user foo@example.org --pass 12345 2020-01-01 2020-12-31
```
Details see source file: `/app/Commands/EcowittExportCommand.php` ## Support the development
**Do you like this project? Support it by donating**
This script will generate a CSV File which is compatible with wee_import config in step 2. - PayPal: [Donate](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=66BYDWAT92N6L)
The file will be generated in `ecowitt_<device_id>.csv`. - Patreon: [Donate](https://www.patreon.com/nunomaduro)
### 2. import ## License
Import your data with wee_import. Sample config below Laravel Zero is an open-source software licensed under the MIT license.
Sample Import File: weewx_import.conf:
```conf
# EXAMPLE CONFIGURATION FILE FOR IMPORTING FROM CSV FILES
#
# Copyright (c) 2009-2019 Tom Keffer <tkeffer@gmail.com> and Gary Roderick.
# See the file LICENSE.txt for your rights.
##############################################################################
# Specify the source. Available options are:
# CSV - import obs from a single CSV format file
# WU - import obs from a Weather Underground PWS history
# Cumulus - import obs from a one or more Cumulus monthly log files
# WD - import obs from a one or more WD monthly log files
# Format is:
# source = (CSV | WU | Cumulus)
source = CSV
##############################################################################
[CSV]
# Parameters used when importing from a CSV file
# Path and name of our CSV source file. Format is:
# file = full path and filename
file = /home/pi/input.csv
# The character used to separate fields. Format is:
# delimiter = <single character>
# Default is , (comma).
delimiter = ","
# If there is no mapped interval field how will the interval field be
# determined for the imported records. Available options are:
# derive - Derive the interval field from the timestamp of successive
# records. This setting is best used when the imported records
# are equally spaced in time and there are no missing records.
# conf - Use the interval setting from weewx.conf. This setting is
# best used if the records to be imported have been produced by
# WeeWX using the same archive interval as set in weewx.conf on
# this machine.
# x - Use a fixed interval of x minutes for every record. This
# setting is best used if the records to be imported are
# equally based in time but there are some missing records.
#
# Note: If there is a mapped interval field then this setting will be
# ignored.
# Format is:
# interval = (derive | conf | x)
interval = derive
# Should the [StdQC] max/min limits in weewx.conf be applied to the
# imported data. This may be useful if the source has extreme values that
# are clearly incorrect for some observations. Available options are:
# True - weewx.conf [StdQC] max/min limits are applied.
# False - weewx.conf [StdQC] max/min limits are not applied.
# Format is:
# qc = (True | False)
qc = True
# Should any missing derived observations be calculated from the imported
# data if possible. Available options are:
# True - Any missing derived observations are calculated.
# False - Any missing derived observations are not calculated.
# Format is:
# calc_missing = (True | False)
calc_missing = True
# Specify how imported data fields that contain invalid data (eg a numeric
# field containing non-numeric data) are handled. Available options are:
# True - The invalid data is ignored, the WeeWX target field is set to
# None and the import continues.
# False - The import is halted.
# Format is:
# ignore_invalid_data = (True | False)
# Default is True.
ignore_invalid_data = True
# Imported records are written to archive in transactions of tranche
# records at a time. Increase for faster throughput, decrease to reduce
# memory requirements. Format is:
# tranche = x
# where x is an integer
tranche = 250
# Specify whether a UV sensor was used to produce any UV observations.
# Available options are:
# True - UV sensor was used and UV data will be imported.
# False - UV sensor was not used and any UV data will not be imported.
# UV fields will be set to None/NULL.
# For a CSV import UV_sensor should be set to False if a UV sensor was
# NOT present when the import data was created. Otherwise it may be set to
# True or omitted. Format is:
# UV_sensor = (True | False)
UV_sensor = True
# Specify whether a solar radiation sensor was used to produce any solar
# radiation observations. Available options are:
# True - Solar radiation sensor was used and solar radiation data will
# be imported.
# False - Solar radiation sensor was not used and any solar radiation
# data will not be imported. radiation fields will be set to
# None/NULL.
# For a CSV import solar_sensor should be set to False if a solar radiation
# sensor was NOT present when the import data was created. Otherwise it may
# be set to True or omitted. Format is:
# solar_sensor = (True | False)
solar_sensor = True
# Date-time format of CSV field from which the WeeWX archive record
# dateTime field is to be extracted. wee_import first attempts to interpret
# date/time info in this format, if this fails it then attempts to
# interpret it as a timestamp and if this fails it then raises an error.
# Uses Python strptime() format codes.
# raw_datetime_format = Python strptime() format string
raw_datetime_format = %Y-%m-%d %H:%M
# Does the imported rain field represent the total rainfall since the last
# record or a cumulative value. Available options are:
# discrete - rain field represents total rainfall since last record
# cumulative - rain field represents a cumulative rainfall reset at
# midnight
# rain = (discrete | cumulative)
rain = cumulative
# Lower and upper bounds for imported wind direction. It is possible,
# particularly for a calculated direction, to have a value (eg -45) outside
# of the WeeWX limits (0 to 360 inclusive). Format is:
#
# wind_direction = lower,upper
#
# where :
# lower is the lower limit of acceptable wind direction in degrees
# (may be negative)
# upper is the upper limit of acceptable wind direction in degrees
#
# Imported values from lower to upper will be normalised to the range 0 to
# 360. Values outside of the parameter range will be stored as None.
# Default is -360,360.
wind_direction = -360,360
# Map CSV record fields to WeeWX archive fields. Format is:
#
# weewx_archive_field_name = csv_field_name, weewx_unit_name
#
# where:
# weewx_archive_field_name - An observation name in the WeeWX database
# schema.
# csv_field_name - The name of a field from the CSV file.
# weewx_unit_name - The name of the units, as defined in WeeWX,
# used by csv_field_name. wee_import will do
# the necessary conversions to the unit system
# used by the WeeWX archive.
# For example,
# outTemp = Temp, degree_C
# would map the CSV field Temp, in degrees C, to the archive field outTemp.
#
# A mapping for WeeWX field dateTime is mandatory and the WeeWX unit name
# for the dateTime mapping must be unix_epoch. For example,
# dateTime = csv_date_and_time, unix_epoch
# would map the CSV field csv_date_and_time to the WeeWX dateTime field with
# the csv_date_and_time field being interpreted first using the format
# specified at the raw_datetime_format config option and if that fails as a
# unix epoch timestamp.
#
# Field mapping to the WeeWX usUnits archive field is currently not
# supported. If a usUnits field exists in the CSV data it should not be
# mapped, rather WeeWX unit names should included against each field to be
# imported in the field map.
#
# WeeWX archive fields that do not exist in the CSV data may be omitted.
# Any omitted fields that are derived (eg dewpoint) may be calculated
# during import using the equivalent of the WeeWX StdWXCalculate service
# through setting the calc-missing parameter above.
[[FieldMap]]
dateTime = date_and_time
interval =
barometer = pressure_rel, hPa
pressure = pressure_abs, hPa
altimeter =
inTemp = temp_in, degree_C
outTemp = temp_out, degree_C
inHumidity = humid_in, percent
outHumidity = humid_out, percent
windSpeed = wind, meter_per_second
windDir = wind_dir, degree_compass
windGust = wind_gust, meter_per_second
windGustDir =
rainRate = rain, mm_per_hour
rain = rain_daily, mm
dewpoint = temp_out_dew, degree_C
windchill = temp_out_gust, degree_C
heatindex =
ET =
radiation =
UV =
```
**DONE!**
regenerate / restart weewx daemon and check your data!

View File

@@ -8,20 +8,16 @@ class AppServiceProvider extends ServiceProvider
{ {
/** /**
* Bootstrap any application services. * Bootstrap any application services.
*
* @return void
*/ */
public function boot() public function boot(): void
{ {
// //
} }
/** /**
* Register any application services. * Register any application services.
*
* @return void
*/ */
public function register() public function register(): void
{ {
// //
} }

View File

@@ -5,6 +5,10 @@
"homepage": "https://github.com/comes/ecowitt2weewx", "homepage": "https://github.com/comes/ecowitt2weewx",
"type": "project", "type": "project",
"license": "MIT", "license": "MIT",
"support": {
"issues": "https://github.com/comes/ecowitt2weewx/issues",
"source": "https://github.com/comes/ecowitt2weewx"
},
"authors": [ "authors": [
{ {
"name": "Jeremias Wolff", "name": "Jeremias Wolff",
@@ -12,15 +16,20 @@
} }
], ],
"require": { "require": {
"php": "^8.0", "php": "^8.1",
"guzzlehttp/guzzle": "^7.5", "laravel-zero/framework": "^10.0.2",
"illuminate/http": "^9.47", "nunomaduro/termwind": "^1.15.1"
"laravel-zero/framework": "^9.2", },
"nesbot/carbon": "^2.65" "require-dev": {
"laravel/pint": "^1.8",
"mockery/mockery": "^1.5.1",
"pestphp/pest": "^2.5"
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {
"App\\": "app/" "App\\": "app/",
"Database\\Factories\\": "database/factories/",
"Database\\Seeders\\": "database/seeders/"
} }
}, },
"autoload-dev": { "autoload-dev": {
@@ -36,7 +45,7 @@
"pestphp/pest-plugin": true "pestphp/pest-plugin": true
} }
}, },
"minimum-stability": "dev", "minimum-stability": "stable",
"prefer-stable": true, "prefer-stable": true,
"bin": ["ecowitt2weewx"] "bin": ["ecowitt2weewx"]
} }

4553
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -42,6 +42,19 @@ return [
'env' => 'development', '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 | Autoloaded Service Providers

View File

@@ -56,10 +56,13 @@ return [
'hidden' => [ 'hidden' => [
NunoMaduro\LaravelConsoleSummary\SummaryCommand::class, NunoMaduro\LaravelConsoleSummary\SummaryCommand::class,
Symfony\Component\Console\Command\DumpCompletionCommand::class,
Symfony\Component\Console\Command\HelpCommand::class, Symfony\Component\Console\Command\HelpCommand::class,
Illuminate\Console\Scheduling\ScheduleRunCommand::class, Illuminate\Console\Scheduling\ScheduleRunCommand::class,
Illuminate\Console\Scheduling\ScheduleListCommand::class,
Illuminate\Console\Scheduling\ScheduleFinishCommand::class, Illuminate\Console\Scheduling\ScheduleFinishCommand::class,
Illuminate\Foundation\Console\VendorPublishCommand::class, Illuminate\Foundation\Console\VendorPublishCommand::class,
LaravelZero\Framework\Commands\StubPublishCommand::class,
], ],
/* /*

View File

@@ -1,13 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false" <phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
backupStaticAttributes="false" xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php" bootstrap="vendor/autoload.php"
colors="true" colors="true"
convertErrorsToExceptions="true" >
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<testsuites> <testsuites>
<testsuite name="Feature"> <testsuite name="Feature">
<directory suffix="Test.php">./tests/Feature</directory> <directory suffix="Test.php">./tests/Feature</directory>
@@ -16,9 +12,9 @@
<directory suffix="Test.php">./tests/Unit</directory> <directory suffix="Test.php">./tests/Unit</directory>
</testsuite> </testsuite>
</testsuites> </testsuites>
<coverage processUncoveredFiles="true"> <source>
<include> <include>
<directory suffix=".php">./app</directory> <directory suffix=".php">./app</directory>
</include> </include>
</coverage> </source>
</phpunit> </phpunit>

View File

@@ -3,15 +3,14 @@
namespace Tests; namespace Tests;
use Illuminate\Contracts\Console\Kernel; use Illuminate\Contracts\Console\Kernel;
use Illuminate\Foundation\Application;
trait CreatesApplication trait CreatesApplication
{ {
/** /**
* Creates the application. * Creates the application.
*
* @return \Illuminate\Foundation\Application
*/ */
public function createApplication() public function createApplication(): Application
{ {
$app = require __DIR__.'/../bootstrap/app.php'; $app = require __DIR__.'/../bootstrap/app.php';

View File

@@ -1,7 +0,0 @@
<?php
test('inspiring command', function () {
$this->artisan('inspiring')
->expectsOutput('Simplicity is the ultimate sophistication.')
->assertExitCode(0);
});

View File

@@ -1,3 +1,45 @@
<?php <?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'); 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
{
// ..
}