Compare commits
16 Commits
upgrade-10
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
231014566a | ||
|
|
9ffdea3702 | ||
|
|
4cb82af4c1 | ||
|
|
7145396ca5 | ||
|
|
a4e7450cfd | ||
|
|
6f66e00145 | ||
|
|
8a15050614 | ||
|
|
1002ab7847 | ||
|
|
829a802ce1 | ||
|
|
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@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,98 +92,118 @@ 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');
|
||||
$this->debug('fetch outTemp');
|
||||
$outdoorTemp = $this->getData($ecowitt, 'list.tempf.list.tempf');
|
||||
|
||||
// Feels Like in C
|
||||
$this->debug('fetch outdoor temp gust');
|
||||
$outdoorTempGust = $this->getData($ecowitt, 'list.tempf.list.sendible_temp');
|
||||
$this->debug('fetch outTempApp');
|
||||
$outdoorTempApp = $this->getData($ecowitt, 'list.tempf.list.apparent_temp');
|
||||
|
||||
// Dew Point in C
|
||||
$this->debug('collecting: Dew Point in C');
|
||||
$outdoorDewTemp = $this->getData($ecowitt, 'list.tempf.list.drew_temp');
|
||||
$this->debug('fetch dewpoint');
|
||||
$outdoorTempDew = $this->getData($ecowitt, 'list.tempf.list.drew_temp'); // yes ecowitt calls it drew_temp :)
|
||||
|
||||
// humidity in %
|
||||
$this->debug('collecting: humidity in %');
|
||||
$this->debug('fetch outHumidity %');
|
||||
$outdoorHumidity = $this->getData($ecowitt, 'list.humidity.list.humidity');
|
||||
|
||||
// temp indoor in C
|
||||
$this->debug('collecting: temp indoor in C');
|
||||
$this->debug('fetch inTemp');
|
||||
$indoorTemp = $this->getData($ecowitt, 'list.tempinf.list.tempinf');
|
||||
|
||||
// humidityin in %
|
||||
$this->debug('collecting: humidityin in %');
|
||||
$indoorHumidity = $this->getData($ecowitt, 'list.humidity.list.humidity');
|
||||
$this->debug('fetch inHumidityin %');
|
||||
$indoorHumidity = $this->getData($ecowitt, 'list.humidityin.list.humidityin');
|
||||
|
||||
// solar in lx -- Solar and UVI
|
||||
$this->debug('collecting: solar in lx -- Solar and UVI');
|
||||
$solarradiation = $this->getData($ecowitt, 'list.solarradiation.list.solarradiation');
|
||||
$this->debug('fetch solar radiation');
|
||||
$solarRadiation = $this->getData($ecowitt, 'list.so_uv.list.solarradiation');
|
||||
|
||||
// uv
|
||||
$this->debug('collecting: uv');
|
||||
$uvi = $this->getData($ecowitt, 'list.uv.list.uv');
|
||||
$this->debug('fetch uv index');
|
||||
$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');
|
||||
$rainRateH = $this->getData($ecowitt, 'list.rain.list.rainratein');
|
||||
$this->debug('fetch rainratein');
|
||||
$rainRateIn = $this->getData($ecowitt, 'list.rain.list.rainratein');
|
||||
|
||||
// daily rainrate total mm/hr
|
||||
$this->debug('collecting: daily rainrate total mm/hr');
|
||||
$rainRateDaily = $this->getData($ecowitt, 'list.rain.list.dailyrainin');
|
||||
$this->debug('fetch dailyrainin');
|
||||
$dailyRainIn = $this->getData($ecowitt, 'list.rain.list.dailyrainin');
|
||||
|
||||
// wind_speed in m/s
|
||||
$this->debug('collecting: wind_speed in m/s');
|
||||
$windspeed = $this->getData($ecowitt, 'list.wind_speed.list.windspeedmph');
|
||||
$this->debug('fetch windspeedmph (kmh)');
|
||||
$windSpeed = $this->getData($ecowitt, 'list.wind.list.windspeedmph'); // this key is called mph but units in data struct is kmh :/
|
||||
|
||||
// windGust
|
||||
$this->debug('collecting: windGust');
|
||||
$windGust = $this->getData($ecowitt, 'list.wind_speed.list.windgustmph');
|
||||
$this->debug('fetch windgustmph (kmh)');
|
||||
$windGust = $this->getData($ecowitt, 'list.wind.list.windgustmph'); // wind gust key called mph but units in data struct is kmh
|
||||
|
||||
// winddir in degree
|
||||
$this->debug('collecting: winddir in degree');
|
||||
$windir = $this->getData($ecowitt, 'list.winddir.list.winddir');
|
||||
$this->debug('fetch winddir');
|
||||
$windDir = $this->getData($ecowitt, 'list.wind.list.winddir');
|
||||
|
||||
// pressure relative in hPa
|
||||
$this->debug('collecting: pressure relative in hPa');
|
||||
$this->debug('fetch baromrelin');
|
||||
$pressureRel = $this->getData($ecowitt, 'list.pressure.list.baromrelin');
|
||||
|
||||
// pressure absolute in hPa
|
||||
$this->debug('collecting: pressure absolute in hPa');
|
||||
$this->debug('fetch baromabsin');
|
||||
$pressureAbs = $this->getData($ecowitt, 'list.pressure.list.baromabsin');
|
||||
|
||||
foreach ($outdoorTemp as $date => $temp) {
|
||||
if (! $temp) {
|
||||
$this->debug('Skipping a bogus index');
|
||||
|
||||
continue;
|
||||
}
|
||||
$this->debug('unpacking $temp: '.$temp);
|
||||
$tmp = [
|
||||
'date_and_time' => $date, // %Y-%m-%d %H:%M:%S
|
||||
'temp_out' => $temp, // degree
|
||||
'temp_out_gust' => data_get($outdoorTempGust, $date), // degree
|
||||
'temp_out_dew' => data_get($outdoorDewTemp, $date), // degree
|
||||
'humid_out' => data_get($outdoorHumidity, $date), // percent
|
||||
'temp_in' => data_get($indoorTemp, $date), // degree
|
||||
'humid_in' => data_get($indoorHumidity, $date), // percent
|
||||
'rad' => data_get($solarradiation, $date), // lx
|
||||
'time' => $date, // %Y-%m-%d %H:%M:%S
|
||||
|
||||
'outTemp' => $temp, // degree
|
||||
'outTempApp' => data_get($outdoorTempApp, $date), // degree
|
||||
'dewpoint' => data_get($outdoorTempDew, $date), // degree
|
||||
'outHumidity' => data_get($outdoorHumidity, $date), // percent
|
||||
|
||||
'inTemp' => data_get($indoorTemp, $date), // degree
|
||||
'inHumidity' => data_get($indoorHumidity, $date), // percent
|
||||
|
||||
'radiation' => data_get($solarRadiation, $date), // lx
|
||||
'uv' => data_get($uvi, $date),
|
||||
'rain' => data_get($rainRateH, // mm
|
||||
|
||||
'rain_rate' => data_get($rainRateIn, // mm
|
||||
$date
|
||||
),
|
||||
'rain_daily' => data_get($rainRateDaily, $date), // mm
|
||||
'wind' => data_get($windspeed, // m_per_second
|
||||
'rain_daily' => data_get($dailyRainIn, $date), // mm
|
||||
|
||||
'wind_speed' => data_get($windSpeed, // m_per_second
|
||||
$date
|
||||
),
|
||||
'wind_gust' => data_get($windGust, $date), // m_per_second
|
||||
'wind_dir' => data_get($windir, $date), // degree_compass
|
||||
'pressure_rel' => data_get($pressureRel, $date), // hPa
|
||||
'windGust' => data_get($windGust, $date), // m_per_second
|
||||
'windDir' => data_get($windDir, $date), // degree_compass
|
||||
|
||||
'pressure_abs' => data_get($pressureAbs, $date), // hPa
|
||||
'pressure_rel' => data_get($pressureRel, $date),
|
||||
];
|
||||
$outputData[] = $tmp;
|
||||
}
|
||||
$startDate = $startDate->addDay()->startOfDay();
|
||||
} while ( $startDate->lte($endDate) );
|
||||
|
||||
$this->export(getcwd() . "/ecowitt_{$deviceId}.csv", $outputData);
|
||||
} while ($startDate->lte($endDate));
|
||||
|
||||
$outFile = getcwd()."/export_ecowitt_{$deviceId}.csv";
|
||||
$this->export($outFile, $outputData);
|
||||
$this->debug('exported to output file: '.$outFile);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -191,6 +212,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 +239,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 +249,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 +261,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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
18
box.json
18
box.json
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"chmod": "0755",
|
||||
"directories": [
|
||||
"app",
|
||||
"bootstrap",
|
||||
"config",
|
||||
"vendor"
|
||||
],
|
||||
"files": [
|
||||
"composer.json"
|
||||
],
|
||||
"exclude-composer-files": false,
|
||||
"compression": "GZ",
|
||||
"compactors": [
|
||||
"KevinGH\\Box\\Compactor\\Php",
|
||||
"KevinGH\\Box\\Compactor\\Json"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
],
|
||||
"require": {
|
||||
"php": "^8.1",
|
||||
"guzzlehttp/guzzle": "^7.5",
|
||||
"illuminate/http": "^10.0",
|
||||
"laravel-zero/framework": "^10.0.2",
|
||||
"nunomaduro/termwind": "^1.15.1"
|
||||
},
|
||||
|
||||
1317
composer.lock
generated
1317
composer.lock
generated
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user