feat: NetatmoClient with token rotation, OpenMeteoClient, LiveSource, netatmo-init

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
2026-09-11 14:45:54 +02:00
co-authored by Claude Fable 5.1
parent dababbd1f2
commit 4250fa5abf
9 changed files with 551 additions and 6 deletions
+35
View File
@@ -0,0 +1,35 @@
<?php
declare(strict_types=1);
namespace Weerscherm;
/** Open-Meteo dagverwachting. Gratis voor niet-commercieel gebruik, geen API-key. */
final class OpenMeteoClient
{
private const URL = 'https://api.open-meteo.com/v1/forecast';
public function __construct(private readonly HttpClient $http)
{
}
/** @return array<string, mixed> het "daily"-blok */
public function dailyForecast(float $lat, float $lon, string $timezone): array
{
$res = $this->http->get(self::URL, [
'latitude' => $lat,
'longitude' => $lon,
'daily' => 'weather_code,temperature_2m_max,temperature_2m_min,precipitation_sum,precipitation_probability_max',
'timezone' => $timezone,
'forecast_days' => 6,
]);
if ($res->status !== 200) {
throw new UpstreamException("Open-Meteo: HTTP {$res->status}");
}
$json = $res->json();
if (!is_array($json['daily'] ?? null)) {
throw new UpstreamException('Open-Meteo: geen daily-blok in antwoord');
}
return $json['daily'];
}
}