Merge PR #489: New Plugin: Simple heat pump
commit
8126f0c4e0
|
|
@ -976,6 +976,22 @@ Description: nymea.io plugin for simulated devices
|
|||
This package will install the nymea.io plugin for simulated devices
|
||||
|
||||
|
||||
Package: nymea-plugin-simpleheatpump
|
||||
Architecture: any
|
||||
Depends: ${shlibs:Depends},
|
||||
${misc:Depends},
|
||||
libnymea-gpio,
|
||||
nymea-plugins-translations,
|
||||
Description: nymea.io plugin for simple heat pumps
|
||||
The nymea daemon is a plugin based IoT (Internet of Things) server. The
|
||||
server works like a translator for devices, things and services and
|
||||
allows them to interact.
|
||||
With the powerful rule engine you are able to connect any device available
|
||||
in the system and create individual scenes and behaviors for your environment.
|
||||
.
|
||||
This package will install the nymea.io plugin for simple heat pumps
|
||||
|
||||
|
||||
Package: nymea-plugin-somfytahoma
|
||||
Architecture: any
|
||||
Depends: ${shlibs:Depends},
|
||||
|
|
@ -1356,6 +1372,7 @@ Depends: nymea-plugin-boblight,
|
|||
nymea-plugin-remotessh,
|
||||
nymea-plugin-serialportcommander,
|
||||
nymea-plugin-systemmonitor,
|
||||
nymea-plugin-simpleheatpump,
|
||||
nymea-plugin-onewire,
|
||||
nymea-plugin-dynatrace,
|
||||
Description: Meta package for nymea makers, tinkerers and hackers plugins.
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
usr/lib/@DEB_HOST_MULTIARCH@/nymea/plugins/libnymea_integrationpluginsimpleheatpump.so
|
||||
|
|
@ -56,6 +56,7 @@ PLUGIN_DIRS = \
|
|||
serialportcommander \
|
||||
sgready \
|
||||
simulation \
|
||||
simpleheatpump \
|
||||
sma \
|
||||
somfytahoma \
|
||||
sonos \
|
||||
|
|
|
|||
|
|
@ -0,0 +1,4 @@
|
|||
# Simple heat pump
|
||||
|
||||
Control heat pumps offering a simple relay interface for boosting the energy consumption when cheap or self produced energy is available.
|
||||
|
||||
|
|
@ -0,0 +1,141 @@
|
|||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
*
|
||||
* Copyright 2013 - 2021, nymea GmbH
|
||||
* Contact: contact@nymea.io
|
||||
*
|
||||
* This file is part of nymea.
|
||||
* This project including source code and documentation is protected by
|
||||
* copyright law, and remains the property of nymea GmbH. All rights, including
|
||||
* reproduction, publication, editing and translation, are reserved. The use of
|
||||
* this project is subject to the terms of a license agreement to be concluded
|
||||
* with nymea GmbH in accordance with the terms of use of nymea GmbH, available
|
||||
* under https://nymea.io/license
|
||||
*
|
||||
* GNU Lesser General Public License Usage
|
||||
* Alternatively, this project may be redistributed and/or modified under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation; version 3. This project 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this project. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For any further details and any questions please contact us under
|
||||
* contact@nymea.io or see our FAQ/Licensing Information on
|
||||
* https://nymea.io/license/faq
|
||||
*
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
#include "integrationpluginsimpleheatpump.h"
|
||||
#include "plugininfo.h"
|
||||
|
||||
IntegrationPluginSimpleHeatpump::IntegrationPluginSimpleHeatpump()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void IntegrationPluginSimpleHeatpump::init()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void IntegrationPluginSimpleHeatpump::discoverThings(ThingDiscoveryInfo *info)
|
||||
{
|
||||
// Check if GPIOs are available on this platform
|
||||
if (!Gpio::isAvailable()) {
|
||||
qCWarning(dcSimpleHeatPump()) << "There are no GPIOs available on this plattform";
|
||||
//: Error discovering GPIOs
|
||||
return info->finish(Thing::ThingErrorHardwareNotAvailable, QT_TR_NOOP("No GPIOs available on this system."));
|
||||
}
|
||||
|
||||
// FIXME: provide once system configurations are loaded
|
||||
|
||||
info->finish(Thing::ThingErrorNoError);
|
||||
}
|
||||
|
||||
void IntegrationPluginSimpleHeatpump::setupThing(ThingSetupInfo *info)
|
||||
{
|
||||
Thing *thing = info->thing();
|
||||
qCDebug(dcSimpleHeatPump()) << "Setup" << thing->name() << thing->params();
|
||||
|
||||
if (thing->thingClassId() == simpleHeatPumpInterfaceThingClassId) {
|
||||
// Check if GPIOs are available on this platform
|
||||
if (!Gpio::isAvailable()) {
|
||||
qCWarning(dcSimpleHeatPump()) << "There are no GPIOs available on this plattform";
|
||||
//: Error set up GPIOs
|
||||
return info->finish(Thing::ThingErrorHardwareNotAvailable, QT_TR_NOOP("No GPIOs found on this system."));
|
||||
}
|
||||
|
||||
int gpioNumber = thing->paramValue(simpleHeatPumpInterfaceThingGpioNumberParamTypeId).toInt();
|
||||
bool initialValue = thing->stateValue(simpleHeatPumpInterfacePowerStateTypeId).toBool();
|
||||
|
||||
if (gpioNumber < 0) {
|
||||
qCWarning(dcSimpleHeatPump()) << "Invalid GPIO number" << gpioNumber;
|
||||
info->finish(Thing::ThingErrorInvalidParameter);
|
||||
return;
|
||||
}
|
||||
|
||||
Gpio *gpio = new Gpio(gpioNumber, this);
|
||||
if (!gpio->exportGpio()) {
|
||||
qCWarning(dcSimpleHeatPump()) << "Could not export gpio" << gpioNumber;
|
||||
gpio->deleteLater();
|
||||
return info->finish(Thing::ThingErrorHardwareFailure, QT_TR_NOOP("Failed to set up the GPIO interface."));
|
||||
}
|
||||
|
||||
if (!gpio->setDirection(Gpio::DirectionOutput)) {
|
||||
qCWarning(dcSimpleHeatPump()) << "Failed to configure gpio" << gpioNumber << "as output";
|
||||
gpio->deleteLater();
|
||||
return info->finish(Thing::ThingErrorHardwareFailure, QT_TR_NOOP("Failed to set up the GPIO interface."));
|
||||
}
|
||||
|
||||
// Set the pin to the initial value
|
||||
if (!gpio->setValue(initialValue ? Gpio::ValueHigh : Gpio::ValueLow)) {
|
||||
qCWarning(dcSimpleHeatPump()) << "Failed to set initially value" << initialValue << "for gpio" << gpioNumber;
|
||||
gpio->deleteLater();
|
||||
return info->finish(Thing::ThingErrorHardwareFailure, QT_TR_NOOP("Failed to set up the GPIO interface."));
|
||||
}
|
||||
|
||||
m_gpios.insert(thing, gpio);
|
||||
info->finish(Thing::ThingErrorNoError);
|
||||
}
|
||||
}
|
||||
|
||||
void IntegrationPluginSimpleHeatpump::postSetupThing(Thing *thing)
|
||||
{
|
||||
Q_UNUSED(thing)
|
||||
}
|
||||
|
||||
void IntegrationPluginSimpleHeatpump::thingRemoved(Thing *thing)
|
||||
{
|
||||
if (m_gpios.contains(thing)) {
|
||||
delete m_gpios.take(thing);
|
||||
}
|
||||
}
|
||||
|
||||
void IntegrationPluginSimpleHeatpump::executeAction(ThingActionInfo *info)
|
||||
{
|
||||
Thing *thing = info->thing();
|
||||
|
||||
if (thing->thingClassId() == simpleHeatPumpInterfaceThingClassId) {
|
||||
Gpio *gpio = m_gpios.value(info->thing());
|
||||
if (!gpio) {
|
||||
qCWarning(dcSimpleHeatPump()) << "Failed to execute action. There is no GPIO available for" << thing;
|
||||
info->finish(Thing::ThingErrorHardwareNotAvailable);
|
||||
return;
|
||||
}
|
||||
|
||||
if (info->action().actionTypeId() == simpleHeatPumpInterfacePowerActionTypeId) {
|
||||
bool heatPumpEnabled = info->action().paramValue(simpleHeatPumpInterfacePowerActionPowerParamTypeId).toBool();
|
||||
if (!gpio->setValue(heatPumpEnabled ? Gpio::ValueHigh : Gpio::ValueLow)) {
|
||||
qCWarning(dcSimpleHeatPump()) << "Failed to set the power for" << thing << "to" << heatPumpEnabled;
|
||||
info->finish(Thing::ThingErrorHardwareFailure);
|
||||
return;
|
||||
}
|
||||
|
||||
thing->setStateValue(simpleHeatPumpInterfacePowerStateTypeId, heatPumpEnabled);
|
||||
info->finish(Thing::ThingErrorNoError);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
*
|
||||
* Copyright 2013 - 2021, nymea GmbH
|
||||
* Contact: contact@nymea.io
|
||||
*
|
||||
* This file is part of nymea.
|
||||
* This project including source code and documentation is protected by
|
||||
* copyright law, and remains the property of nymea GmbH. All rights, including
|
||||
* reproduction, publication, editing and translation, are reserved. The use of
|
||||
* this project is subject to the terms of a license agreement to be concluded
|
||||
* with nymea GmbH in accordance with the terms of use of nymea GmbH, available
|
||||
* under https://nymea.io/license
|
||||
*
|
||||
* GNU Lesser General Public License Usage
|
||||
* Alternatively, this project may be redistributed and/or modified under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation; version 3. This project 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this project. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* For any further details and any questions please contact us under
|
||||
* contact@nymea.io or see our FAQ/Licensing Information on
|
||||
* https://nymea.io/license/faq
|
||||
*
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
#ifndef INTEGRATIONPLUGINSIMPLEHEATPUMP_H
|
||||
#define INTEGRATIONPLUGINSIMPLEHEATPUMP_H
|
||||
|
||||
#include "integrations/integrationplugin.h"
|
||||
|
||||
#include <gpio.h>
|
||||
|
||||
class IntegrationPluginSimpleHeatpump : public IntegrationPlugin
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PLUGIN_METADATA(IID "io.nymea.IntegrationPlugin" FILE "integrationpluginsimpleheatpump.json")
|
||||
Q_INTERFACES(IntegrationPlugin)
|
||||
|
||||
public:
|
||||
explicit IntegrationPluginSimpleHeatpump();
|
||||
|
||||
void init() override;
|
||||
void discoverThings(ThingDiscoveryInfo *info) override;
|
||||
void setupThing(ThingSetupInfo *info) override;
|
||||
void postSetupThing(Thing *thing) override;
|
||||
void thingRemoved(Thing *thing) override;
|
||||
void executeAction(ThingActionInfo *info) override;
|
||||
|
||||
private:
|
||||
QHash<Thing *, Gpio *> m_gpios;
|
||||
|
||||
};
|
||||
|
||||
#endif // INTEGRATIONPLUGINSIMPLEHEATPUMP_H
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
{
|
||||
"name": "SimpleHeatPump",
|
||||
"displayName": "Simple heat pump",
|
||||
"id": "6e99e657-7fd6-4c5f-b321-62656c00e1d6",
|
||||
"vendors": [
|
||||
{
|
||||
"name": "nymea",
|
||||
"displayName": "nymea",
|
||||
"id": "2062d64d-3232-433c-88bc-0d33c0ba2ba6",
|
||||
"thingClasses": [
|
||||
{
|
||||
"id": "bc553762-c842-422e-888f-6824aad099fb",
|
||||
"name": "simpleHeatPumpInterface",
|
||||
"displayName": "Simple heat pump interface",
|
||||
"createMethods": ["user"],
|
||||
"interfaces": [ "simpleheatpump" ],
|
||||
"settingsTypes": [
|
||||
],
|
||||
"paramTypes": [
|
||||
{
|
||||
"id": "b97d03d9-35ce-445d-903e-b1e3857006ce",
|
||||
"name": "gpioNumber",
|
||||
"displayName": "GPIO number",
|
||||
"type": "int",
|
||||
"defaultValue": -1
|
||||
}
|
||||
],
|
||||
"stateTypes": [
|
||||
{
|
||||
"id": "f8bccedf-5eb2-49a0-b892-c398dbd6a18d",
|
||||
"name": "power",
|
||||
"displayName": "Heat pump enabled",
|
||||
"displayNameEvent": "Heat pump power changed",
|
||||
"displayNameAction": "Enable/Disable heat pump power",
|
||||
"type": "bool",
|
||||
"writable": true,
|
||||
"defaultValue": false,
|
||||
"cached": true,
|
||||
"ioType": "digitalOutput",
|
||||
"suggestLogging": true
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"title": "Simple heat pump",
|
||||
"tagline": "Control heat pumps offering a simple relay interface for boosting the energy consumption when cheap or self produced energy is available.",
|
||||
"icon": "",
|
||||
"stability": "community",
|
||||
"offline": true,
|
||||
"technologies": [
|
||||
],
|
||||
"categories": [
|
||||
"heating"
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
include(../plugins.pri)
|
||||
|
||||
PKGCONFIG += nymea-gpio
|
||||
|
||||
SOURCES += \
|
||||
integrationpluginsimpleheatpump.cpp
|
||||
|
||||
HEADERS += \
|
||||
integrationpluginsimpleheatpump.h
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.1">
|
||||
<context>
|
||||
<name>IntegrationPluginSimpleHeatpump</name>
|
||||
<message>
|
||||
<location filename="../integrationpluginsimpleheatpump.cpp" line="50"/>
|
||||
<source>No GPIOs available on this system.</source>
|
||||
<extracomment>Error discovering GPIOs</extracomment>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../integrationpluginsimpleheatpump.cpp" line="68"/>
|
||||
<source>No GPIOs found on this system.</source>
|
||||
<extracomment>Error set up GPIOs</extracomment>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../integrationpluginsimpleheatpump.cpp" line="84"/>
|
||||
<location filename="../integrationpluginsimpleheatpump.cpp" line="90"/>
|
||||
<location filename="../integrationpluginsimpleheatpump.cpp" line="97"/>
|
||||
<source>Failed to set up the GPIO interface.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>SimpleHeatPump</name>
|
||||
<message>
|
||||
<location filename="../../../build-nymea-plugins-Desktop-Debug/simpleheatpump/plugininfo.h" line="34"/>
|
||||
<source>Boost production</source>
|
||||
<extracomment>The name of the ActionType ({f8bccedf-5eb2-49a0-b892-c398dbd6a18d}) of ThingClass simpleHeatPumpInterface</extracomment>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../../build-nymea-plugins-Desktop-Debug/simpleheatpump/plugininfo.h" line="37"/>
|
||||
<source>Boost production changed</source>
|
||||
<extracomment>The name of the EventType ({f8bccedf-5eb2-49a0-b892-c398dbd6a18d}) of ThingClass simpleHeatPumpInterface</extracomment>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../../build-nymea-plugins-Desktop-Debug/simpleheatpump/plugininfo.h" line="40"/>
|
||||
<location filename="../../../build-nymea-plugins-Desktop-Debug/simpleheatpump/plugininfo.h" line="43"/>
|
||||
<location filename="../../../build-nymea-plugins-Desktop-Debug/simpleheatpump/plugininfo.h" line="46"/>
|
||||
<source>Boost production enabled</source>
|
||||
<extracomment>The name of the ParamType (ThingClass: simpleHeatPumpInterface, ActionType: boost, ID: {f8bccedf-5eb2-49a0-b892-c398dbd6a18d})
|
||||
----------
|
||||
The name of the ParamType (ThingClass: simpleHeatPumpInterface, EventType: boost, ID: {f8bccedf-5eb2-49a0-b892-c398dbd6a18d})
|
||||
----------
|
||||
The name of the StateType ({f8bccedf-5eb2-49a0-b892-c398dbd6a18d}) of ThingClass simpleHeatPumpInterface</extracomment>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../../build-nymea-plugins-Desktop-Debug/simpleheatpump/plugininfo.h" line="49"/>
|
||||
<source>GPIO number</source>
|
||||
<extracomment>The name of the ParamType (ThingClass: simpleHeatPumpInterface, Type: thing, ID: {b97d03d9-35ce-445d-903e-b1e3857006ce})</extracomment>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../../build-nymea-plugins-Desktop-Debug/simpleheatpump/plugininfo.h" line="52"/>
|
||||
<source>Simple heat pump</source>
|
||||
<extracomment>The name of the plugin SimpleHeatPump ({6e99e657-7fd6-4c5f-b321-62656c00e1d6})</extracomment>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../../build-nymea-plugins-Desktop-Debug/simpleheatpump/plugininfo.h" line="55"/>
|
||||
<source>Simple heat pump interface</source>
|
||||
<extracomment>The name of the ThingClass ({bc553762-c842-422e-888f-6824aad099fb})</extracomment>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../../build-nymea-plugins-Desktop-Debug/simpleheatpump/plugininfo.h" line="58"/>
|
||||
<source>nymea</source>
|
||||
<extracomment>The name of the vendor ({2062d64d-3232-433c-88bc-0d33c0ba2ba6})</extracomment>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
||||
Loading…
Reference in New Issue