etm-powersync-plugins/openmeteo/integrationpluginopenmeteo.h

67 lines
2.3 KiB
C++

// SPDX-License-Identifier: GPL-3.0-or-later
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* Copyright (C) 2026, ETM-Schurig SARL
*
* This file is part of etm-powersync-plugins.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#ifndef INTEGRATIONPLUGINOPENMETEO_H
#define INTEGRATIONPLUGINOPENMETEO_H
#include <integrations/integrationplugin.h>
#include <plugintimer.h>
class IntegrationPluginOpenMeteo : public IntegrationPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "io.nymea.IntegrationPlugin" FILE "integrationpluginopenmeteo.json")
Q_INTERFACES(IntegrationPlugin)
public:
explicit IntegrationPluginOpenMeteo();
void init() override;
void setupThing(ThingSetupInfo *info) override;
void executeAction(ThingActionInfo *info) override;
void thingRemoved(Thing *thing) override;
private:
PluginTimer *m_pluginTimer = nullptr;
// Refresh dispatch
void refresh(Thing *thing);
// Site (parent): two requests — forecast (Meteo-France) + satellite observation (MTG)
void updateSiteForecast(Thing *thing);
void updateSiteSatellite(Thing *thing);
// PV plane (child): one GTI request, using the parent site coordinates
void updatePlane(Thing *thing);
// WMO weather_code -> weatherCondition enum value (with -day/-night via isDay)
QString weatherConditionFromCode(int code, bool isDay) const;
QString weatherDescriptionFromCode(int code) const;
// Helper: resolve the site coordinates for a thing (site itself, or a plane's parent)
bool resolveCoordinates(Thing *thing, double &latitude, double &longitude) const;
};
#endif // INTEGRATIONPLUGINOPENMETEO_H