// SPDX-License-Identifier: GPL-3.0-or-later /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright (C) 2013 - 2024, nymea GmbH * Copyright (C) 2024 - 2025, chargebyte austria GmbH * * This file is part of nymea-energy-plugin-nymea. * * nymea-energy-plugin-nymea.s 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. * * nymea-energy-plugin-nymea.s 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 nymea-energy-plugin-nymea. If not, see . * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #ifndef MANUALSLOTCONFIG_H #define MANUALSLOTCONFIG_H #include #include #include #include #include #include "flexibleload.h" // Configuration for one manually-defined scheduling slot. // Used exclusively by ManualStrategy. // // When repeating = true, the config recurs weekly based on the day-of-week // and time-of-day derived from start/end. Overnight slots (e.g. Mon 22:00 // → Tue 06:00) are handled correctly. struct ManualSlotConfig { QDateTime start; QDateTime end; QMap powerAllocations; // LoadSource → Watts QString label; // user-visible name, e.g. "Recharge VE nuit" bool repeating = false; QDateTime expiresAt; // optional — slot is ignored after this time bool isNull() const { return !start.isValid(); } bool isExpired() const; // Returns true if slotStart falls within this config's time window. // Returns false when isExpired() — use matchesSlotIgnoreExpiry() to detect // "would have matched but is expired". bool matchesSlot(const QDateTime &slotStart) const; bool matchesSlotIgnoreExpiry(const QDateTime &slotStart) const; QVariantMap toJson() const; static ManualSlotConfig fromJson(const QVariantMap &map); }; Q_DECLARE_METATYPE(ManualSlotConfig) // Helpers for serialising powerAllocations map. // Keys used in JSON: "ev", "battery", "dhw", "heatpump", "feedin" QString manualSlotAllocationKey(LoadSource source); LoadSource manualSlotSourceFromKey(const QString &key); #endif // MANUALSLOTCONFIG_H