// 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 RELAYADAPTER_H #define RELAYADAPTER_H #include "adapters/iloadapter.h" #include // Relay-based adapter for DHW tanks and simple heat pumps. // // Maps the power setpoint to a binary on/off relay action. // A nominal power (watts) is used to report currentPowerW() when the relay is on. class RelayAdapter : public ILoadAdapter { Q_OBJECT public: explicit RelayAdapter(ThingManager *thingManager, const ThingId &thingId, LoadRole role, double nominalPowerW = 2000.0, QObject *parent = nullptr); QString adapterId() const override; LoadRole role() const override; ThingId thingId() const override; void applyPower(double targetPowerW) override; void testConnection() override; double currentPowerW() const override; bool isReachable() const override; private: void setPower(bool on); ThingManager *m_thingManager = nullptr; Thing *m_thing = nullptr; LoadRole m_role; double m_nominalPowerW; bool m_relayOn = false; }; #endif // RELAYADAPTER_H