Makeshift version to debug nymea app (issue #443)
Furthermore: Modbus registers defined according to heat pump manual (RegisterList in idm.h) The plugin presently just delivers a hard-coded value of 24.5 for the outside temperature for testing.
This commit is contained in:
parent
d59a1407a8
commit
534322b534
39
idm/idm.cpp
39
idm/idm.cpp
@ -34,10 +34,45 @@ Idm::Idm(const QHostAddress &address, QObject *parent) :
|
|||||||
QObject(parent),
|
QObject(parent),
|
||||||
m_hostAddress(address)
|
m_hostAddress(address)
|
||||||
{
|
{
|
||||||
|
/* qCDebug(dcIdm()) << "Creating Idm with addr: " << address; */
|
||||||
|
|
||||||
m_modbusMaster = new ModbusTCPMaster(address, 502, this);
|
m_modbusMaster = new ModbusTCPMaster(address, 502, this);
|
||||||
|
|
||||||
|
connect(m_modbusMaster, &ModbusTCPMaster::receivedHoldingRegister, this, &Idm::onReceivedHoldingRegister);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Idm::getOutsideTemperature()
|
Idm::~Idm()
|
||||||
{
|
{
|
||||||
m_modbusMaster->
|
if (m_modbusMaster) {
|
||||||
|
delete m_modbusMaster;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double Idm::getOutsideTemperature()
|
||||||
|
{
|
||||||
|
//m_modbusMaster->
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Idm::onReceivedHoldingRegister(int slaveAddress, int modbusRegister, const QVector<quint16> &value)
|
||||||
|
{
|
||||||
|
/* qCDebug(dcIdm()) << "Idm::onReceivedHoldingRegister"; */
|
||||||
|
|
||||||
|
Q_UNUSED(slaveAddress);
|
||||||
|
Q_UNUSED(modbusRegister);
|
||||||
|
Q_UNUSED(value);
|
||||||
|
|
||||||
|
IdmInfo *info = new IdmInfo;
|
||||||
|
info->m_outsideTemperature = 24.3;
|
||||||
|
|
||||||
|
emit statusUpdated(info);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Idm::onRequestStatus()
|
||||||
|
{
|
||||||
|
/* Reading a total of 16 bytes, starting from address 1000.
|
||||||
|
* This covers the following parameters:
|
||||||
|
* */
|
||||||
|
m_modbusMaster->readHoldingRegister(0xff, RegisterList::OutsideTemperature, 16);
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
96
idm/idm.h
96
idm/idm.h
@ -35,13 +35,16 @@
|
|||||||
|
|
||||||
#include "../modbus/modbustcpmaster.h"
|
#include "../modbus/modbustcpmaster.h"
|
||||||
|
|
||||||
|
#include "idminfo.h"
|
||||||
|
|
||||||
class Idm : public QObject
|
class Idm : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit Idm(const QHostAddress &address, QObject *parent = nullptr);
|
explicit Idm(const QHostAddress &address, QObject *parent = nullptr);
|
||||||
void getOutsideTemperature();
|
~Idm();
|
||||||
void getCurrentFaultNumber();
|
double getOutsideTemperature();
|
||||||
|
//void getCurrentFaultNumber();
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -54,51 +57,66 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
enum RegisterList {
|
enum RegisterList {
|
||||||
OutsideTemperature = 1000,
|
/* The following modbus addresses are according to the manual
|
||||||
MeanOutsideTemperature = 1002,
|
* Modbus TCP Navigatorregelung 2.0 pages 13-31.
|
||||||
CurrentFaultNumber = 1004,
|
* Comments at the end of each line give their original name
|
||||||
OperationModeSystem = 1005,
|
* in the German manual. */
|
||||||
SmartGridStatus = 1006,
|
OutsideTemperature = 1000, // Außentemperatur (B31)
|
||||||
HeatStorageTemperature = 1008,
|
MeanOutsideTemperature = 1002, // Gemittelte Außentemperature
|
||||||
ColdStorageTemperature = 1010,
|
CurrentFaultNumber = 1004, // Aktuelle Störungsnummer
|
||||||
DrinkingWaterHeaterTempBelow = 1012,
|
OperationModeSystem = 1005, // Betriebsart System
|
||||||
DrinkingWaterHeaterTempAbove = 1014,
|
SmartGridStatus = 1006, // Smart Grid Status
|
||||||
HotWaterTapTemperature = 1030,
|
HeatStorageTemperature = 1008, // Wärmespeichertemperatur (B38)
|
||||||
TargetHotWaterTemperature = 1032,
|
ColdStorageTemperature = 1010, // Kältespeichertemperatur (B40)
|
||||||
HeatPumpOperatingMode = 1090,
|
DrinkingWaterHeaterTempBottom = 1012, // Trinkwassererwärmertmp. unten (B41)
|
||||||
SummationFaultHeatPump = 1099,
|
DrinkingWaterHeaterTempTop = 1014, // Trinkwassererwärmertmp. oben (B48)
|
||||||
Humiditysensor = 1392,
|
HotWaterTapTemperature = 1030, // Warmwasserzapftemperatur (B42)
|
||||||
ExternalOutsideTemperature = 1690,
|
TargetHotWaterTemperature = 1032, // Warmwasser-Solltemperatur
|
||||||
ExternalHumidity = 1692,
|
HeatPumpOperatingMode = 1090, // Betriebsart Wärmepumpe
|
||||||
ExternalRequestTemperatureHeating = 1694, //Externe Anforderungstemperatur Heizen
|
SummationFaultHeatPump = 1099, // Summenstörung Wärepumpe
|
||||||
|
Humiditysensor = 1392, // Feuchtesensor
|
||||||
|
ExternalOutsideTemperature = 1690, // Externe Außentemperatur
|
||||||
|
ExternalHumidity = 1692, // Externe Feuchte
|
||||||
|
ExternalRequestTemperatureHeating = 1694, // Externe Anforderungstemperatur Heizen
|
||||||
ExternalRequestTemperatureCooling = 1695, // Externe Anforderungstemperatur Kühlen
|
ExternalRequestTemperatureCooling = 1695, // Externe Anforderungstemperatur Kühlen
|
||||||
HeatingRequirement = 1710
|
HeatingRequirement = 1710, // Anforderung Heizen
|
||||||
CoolingRequirement = 1711,
|
CoolingRequirement = 1711, // Anforderung Kühlen
|
||||||
HotWaterChargingRequirement = 1712, // Anforderung Warmwasserladung
|
HotWaterChargingRequirement = 1712, // Anforderung Warmwasserladung
|
||||||
//Wärmemenge Heizen
|
HeatQuantityHeating = 1750, // Wärmemenge Heizen
|
||||||
//Wärmemenge Kühlen,
|
HeatQuantityCooling = 1752, // Wärmemenge Kühlen
|
||||||
//Wärmemenge Warmwasser,
|
HeatQuantityHotWater = 1754, // Wärmemenge Warmwasser
|
||||||
//Wärmemenge Abtauung,
|
HeatQuantityDefrosting = 1756, // Wärmemenge Abtauung
|
||||||
//Wärmemenge Passive Kühlung,
|
HeatQuantityPassiveCooling = 1758, // Wärmemenge Passive Kühlung,
|
||||||
//Wärmemenge Solar,
|
HeatQuantityPhotovolatics = 1760, // Wärmemenge Solar
|
||||||
//Wärmemenge Elektroheizeinsatz,
|
HeatQuantityHeatingElemetn = 1762, // Wärmemenge Elektroheizeinsatz,
|
||||||
Momentanleistung
|
CurrentPower = 1790, // Momentanleistung
|
||||||
SolarKollektortemperatur
|
CurrentPowerSolar = 1792, // MomentanleistungSolar
|
||||||
SolarKollektorrücklauftemperatur
|
SolarCollectorTemperature = 1850, // SolarKollektortemperatur (B73)
|
||||||
SolarLadetemperatur
|
SolarCollectorReturnTemperature = 1852, // SolarKollektorruecklauftemperatur (B75)
|
||||||
MomentanleistungSolar,
|
SolarChargeTemperature = 1854, // SolarLadetemperatur (B74)
|
||||||
SolarOperatingMode =
|
SolarOperatingMode = 1856, // Betriebsart Solar
|
||||||
ISCModus = 1874,
|
ISCMode = 1875, // ISCModus
|
||||||
AcknowledgeFaultMessages = 1999, // Störmeldungen quittieren
|
AcknowledgeFaultMessages = 1999, // Störmeldungen quittieren
|
||||||
Aktueller PV-Überschuss
|
CurrentPhotovoltaicsSurplus = 74, // Aktueller PV-Überschuss
|
||||||
Aktueller PV Produktion
|
CurrentPhotovoltaicsProduction = 78, // Aktueller PV Produktion
|
||||||
Aktuelle Leistungsaufnahme Wärmepumpe
|
CurrentPowerConsumption = 4122, // Aktuelle Leistungsaufnahme Wärmepumpe
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Note: This class only requires one IP address and one
|
||||||
|
* TCP Modbus connection. Multiple devices are managed
|
||||||
|
* within the IntegrationPluginIdm class. */
|
||||||
QHostAddress m_hostAddress;
|
QHostAddress m_hostAddress;
|
||||||
ModbusTCPMaster *m_modbusMaster = nullptr;
|
ModbusTCPMaster *m_modbusMaster = nullptr;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
void statusUpdated(IdmInfo *info);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void onRequestStatus();
|
||||||
|
|
||||||
|
// only public for debugging!
|
||||||
|
public slots:
|
||||||
|
void onReceivedHoldingRegister(int slaveAddress, int modbusRegister, const QVector<quint16> &value);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -11,5 +11,6 @@ SOURCES += \
|
|||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
idm.h \
|
idm.h \
|
||||||
|
idminfo.h \
|
||||||
integrationpluginidm.h \
|
integrationpluginidm.h \
|
||||||
../modbus/modbustcpmaster.h \
|
../modbus/modbustcpmaster.h \
|
||||||
|
|||||||
49
idm/idminfo.h
Normal file
49
idm/idminfo.h
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
|
*
|
||||||
|
* Copyright 2013 - 2020, 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 IDMINFO_H
|
||||||
|
#define IDMINFO_H
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
struct IdmInfo {
|
||||||
|
bool m_connected;
|
||||||
|
bool m_power;
|
||||||
|
double m_roomTemperature;
|
||||||
|
double m_outsideTemperature;
|
||||||
|
double m_waterTemperature;
|
||||||
|
double m_targetRoomTemperature;
|
||||||
|
double m_targetWaterTemperature;
|
||||||
|
QString m_mode;
|
||||||
|
bool m_error;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
@ -31,10 +31,24 @@
|
|||||||
#include "integrationpluginidm.h"
|
#include "integrationpluginidm.h"
|
||||||
#include "plugininfo.h"
|
#include "plugininfo.h"
|
||||||
|
|
||||||
|
IntegrationPluginIdm::IntegrationPluginIdm()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void IntegrationPluginIdm::discoverThings(ThingDiscoveryInfo *info)
|
void IntegrationPluginIdm::discoverThings(ThingDiscoveryInfo *info)
|
||||||
{
|
{
|
||||||
if (info->thingClassId() == navigator2ThingClassId) {
|
if (info->thingClassId() == navigator2ThingClassId) {
|
||||||
//TODO add discovery method
|
// TODO Is a discovery method actually needed?
|
||||||
|
// The plugin has a parameter for the IP address
|
||||||
|
|
||||||
|
QString description = "Navigator 2";
|
||||||
|
ThingDescriptor descriptor(info->thingClassId(), "", description);
|
||||||
|
info->addThingDescriptor(descriptor);
|
||||||
|
|
||||||
|
// Just report no error for now, until the above question
|
||||||
|
// is clarified
|
||||||
|
info->finish(Thing::ThingErrorNoError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,22 +60,38 @@ void IntegrationPluginIdm::setupThing(ThingSetupInfo *info)
|
|||||||
QHostAddress hostAddress = QHostAddress(thing->paramValue(navigator2ThingIpAddressParamTypeId).toString());
|
QHostAddress hostAddress = QHostAddress(thing->paramValue(navigator2ThingIpAddressParamTypeId).toString());
|
||||||
Idm *idm = new Idm(hostAddress, this);
|
Idm *idm = new Idm(hostAddress, this);
|
||||||
m_idmConnections.insert(thing, idm);
|
m_idmConnections.insert(thing, idm);
|
||||||
|
m_idmInfos.insert(thing, info);
|
||||||
|
|
||||||
|
info->finish(Thing::ThingErrorNoError);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void IntegrationPluginIdm::postSetupThing(Thing *thing)
|
void IntegrationPluginIdm::postSetupThing(Thing *thing)
|
||||||
{
|
{
|
||||||
|
if (!m_refreshTimer) {
|
||||||
|
m_refreshTimer = hardwareManager()->pluginTimerManager()->registerTimer(10);
|
||||||
|
connect(m_refreshTimer, &PluginTimer::timeout, this, &IntegrationPluginIdm::onRefreshTimer);
|
||||||
|
}
|
||||||
|
|
||||||
if (thing->thingClassId() == navigator2ThingClassId) {
|
if (thing->thingClassId() == navigator2ThingClassId) {
|
||||||
Idm *idm = m_idmConnections.value(thing);
|
Idm *idm = m_idmConnections.value(thing);
|
||||||
|
|
||||||
|
connect(idm, &Idm::statusUpdated, this, &IntegrationPluginIdm::onStatusUpdated);
|
||||||
|
|
||||||
|
qCDebug(dcIdm()) << "Thing set up, calling update";
|
||||||
|
update(thing);
|
||||||
|
|
||||||
|
thing->setStateValue(navigator2ConnectedStateTypeId, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void IntegrationPluginIdm::thingRemoved(Thing *thing)
|
void IntegrationPluginIdm::thingRemoved(Thing *thing)
|
||||||
{
|
{
|
||||||
if (m_idmConnections.contains(thing))
|
if (m_idmConnections.contains(thing)) {
|
||||||
m_idmConnections.take(thing)->deleteLater();
|
m_idmConnections.take(thing)->deleteLater();
|
||||||
|
m_idmInfos.take(thing)->deleteLater();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void IntegrationPluginIdm::executeAction(ThingActionInfo *info)
|
void IntegrationPluginIdm::executeAction(ThingActionInfo *info)
|
||||||
@ -78,3 +108,58 @@ void IntegrationPluginIdm::executeAction(ThingActionInfo *info)
|
|||||||
Q_ASSERT_X(false, "executeAction", QString("Unhandled thingClassId: %1").arg(thing->thingClassId().toString()).toUtf8());
|
Q_ASSERT_X(false, "executeAction", QString("Unhandled thingClassId: %1").arg(thing->thingClassId().toString()).toUtf8());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void IntegrationPluginIdm::update(Thing *thing)
|
||||||
|
{
|
||||||
|
if (thing->thingClassId() == navigator2ThingClassId) {
|
||||||
|
qCDebug(dcIdm()) << "Updating thing";
|
||||||
|
|
||||||
|
Idm *idm = m_idmConnections.value(thing);
|
||||||
|
Q_UNUSED(idm);
|
||||||
|
|
||||||
|
QVector<quint16> val{};
|
||||||
|
|
||||||
|
idm->onReceivedHoldingRegister(0, 1021, val);
|
||||||
|
//idm->onRequestStatus();
|
||||||
|
|
||||||
|
//idm->readHoldingRegister(0xff, RegisterList::OutsideTemperature);
|
||||||
|
if (m_idmInfos.contains(thing)) {
|
||||||
|
ThingSetupInfo *info = m_idmInfos.take(thing);
|
||||||
|
info->finish(Thing::ThingErrorNoError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void IntegrationPluginIdm::onStatusUpdated(IdmInfo *info)
|
||||||
|
{
|
||||||
|
if (!info)
|
||||||
|
return;
|
||||||
|
|
||||||
|
qCDebug(dcIdm()) << "Received status from heat pump";
|
||||||
|
|
||||||
|
Idm *idm = static_cast<Idm *>(sender());
|
||||||
|
Thing *thing = m_idmConnections.key(idm);
|
||||||
|
|
||||||
|
if (!thing)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* Received a structure holding the status info of the
|
||||||
|
* heat pump. Update the thing states with the individual fields. */
|
||||||
|
thing->setStateValue(navigator2ConnectedStateTypeId, info->m_connected);
|
||||||
|
thing->setStateValue(navigator2PowerStateTypeId, info->m_power);
|
||||||
|
thing->setStateValue(navigator2TemperatureStateTypeId, info->m_roomTemperature);
|
||||||
|
thing->setStateValue(navigator2OutsideAirTemperatureStateTypeId, info->m_outsideTemperature);
|
||||||
|
thing->setStateValue(navigator2WaterTemperatureStateTypeId, info->m_waterTemperature);
|
||||||
|
thing->setStateValue(navigator2TargetTemperatureStateTypeId, info->m_targetRoomTemperature);
|
||||||
|
thing->setStateValue(navigator2TargetWaterTemperatureStateTypeId, info->m_targetWaterTemperature);
|
||||||
|
thing->setStateValue(navigator2ModeStateTypeId, info->m_mode);
|
||||||
|
thing->setStateValue(navigator2ErrorStateTypeId, info->m_error);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IntegrationPluginIdm::onRefreshTimer()
|
||||||
|
{
|
||||||
|
foreach (Thing *thing, myThings().filterByThingClassId(navigator2ThingClassId)) {
|
||||||
|
update(thing);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@ -38,6 +38,7 @@
|
|||||||
|
|
||||||
#include <QUuid>
|
#include <QUuid>
|
||||||
|
|
||||||
|
|
||||||
class IntegrationPluginIdm: public IntegrationPlugin
|
class IntegrationPluginIdm: public IntegrationPlugin
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -54,6 +55,7 @@ public:
|
|||||||
void postSetupThing(Thing *thing) override;
|
void postSetupThing(Thing *thing) override;
|
||||||
void thingRemoved(Thing *thing) override;
|
void thingRemoved(Thing *thing) override;
|
||||||
void executeAction(ThingActionInfo *info) override;
|
void executeAction(ThingActionInfo *info) override;
|
||||||
|
void update(Thing *thing);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
@ -87,10 +89,13 @@ private:
|
|||||||
|
|
||||||
PluginTimer *m_refreshTimer = nullptr;
|
PluginTimer *m_refreshTimer = nullptr;
|
||||||
QHash<Thing *, Idm *> m_idmConnections;
|
QHash<Thing *, Idm *> m_idmConnections;
|
||||||
|
QHash<Thing *, ThingSetupInfo *> m_idmInfos;
|
||||||
QHash<QUuid, ThingActionInfo *> m_asyncActions;
|
QHash<QUuid, ThingActionInfo *> m_asyncActions;
|
||||||
|
|
||||||
private slots:
|
|
||||||
void onRefreshTimer();
|
void onRefreshTimer();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void onStatusUpdated(IdmInfo *info);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // INTEGRATIONPLUGINIDM_H
|
#endif // INTEGRATIONPLUGINIDM_H
|
||||||
|
|||||||
@ -12,7 +12,7 @@
|
|||||||
"name": "navigator2",
|
"name": "navigator2",
|
||||||
"displayName": "Navigator 2.0",
|
"displayName": "Navigator 2.0",
|
||||||
"id": "1c95ac91-4eca-4cbf-b0f4-d60d35d069ed",
|
"id": "1c95ac91-4eca-4cbf-b0f4-d60d35d069ed",
|
||||||
"createMethods": ["Discovery"],
|
"createMethods": ["User","Discovery"],
|
||||||
"interfaces": ["heating", "temperaturesensor", "connectable"],
|
"interfaces": ["heating", "temperaturesensor", "connectable"],
|
||||||
"paramTypes": [
|
"paramTypes": [
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user