diff --git a/stiebeleltron/integrationpluginstiebeleltron.cpp b/stiebeleltron/integrationpluginstiebeleltron.cpp index e772758..46c1c13 100644 --- a/stiebeleltron/integrationpluginstiebeleltron.cpp +++ b/stiebeleltron/integrationpluginstiebeleltron.cpp @@ -1,128 +1,357 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -* -* 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 . -* -* 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 -* -* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + * + * 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 . + * + * 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 "integrationpluginstiebeleltron.h" -#include "network/networkdevicediscovery.h" #include "hardwaremanager.h" +#include "network/networkdevicediscovery.h" #include "plugininfo.h" -IntegrationPluginStiebelEltron::IntegrationPluginStiebelEltron() -{ +IntegrationPluginStiebelEltron::IntegrationPluginStiebelEltron() {} -} - -void IntegrationPluginStiebelEltron::discoverThings(ThingDiscoveryInfo *info) -{ +void IntegrationPluginStiebelEltron::discoverThings(ThingDiscoveryInfo *info) { if (!hardwareManager()->networkDeviceDiscovery()->available()) { - qCWarning(dcStiebelEltron()) << "The network discovery is not available on this platform."; - info->finish(Thing::ThingErrorUnsupportedFeature, QT_TR_NOOP("The network device discovery is not available.")); + qCWarning(dcStiebelEltron()) + << "The network discovery is not available on this platform."; + info->finish( + Thing::ThingErrorUnsupportedFeature, + QT_TR_NOOP("The network device discovery is not available.")); return; } - NetworkDeviceDiscoveryReply *discoveryReply = hardwareManager()->networkDeviceDiscovery()->discover(); - connect(discoveryReply, &NetworkDeviceDiscoveryReply::finished, this, [=](){ - foreach (const NetworkDeviceInfo &networkDeviceInfo, discoveryReply->networkDeviceInfos()) { + NetworkDeviceDiscoveryReply *discoveryReply = + hardwareManager()->networkDeviceDiscovery()->discover(); + connect( + discoveryReply, &NetworkDeviceDiscoveryReply::finished, this, [=]() { + foreach (const NetworkDeviceInfo &networkDeviceInfo, + discoveryReply->networkDeviceInfos()) { + qCDebug(dcStiebelEltron()) << "Found" << networkDeviceInfo; - qCDebug(dcStiebelEltron()) << "Found" << networkDeviceInfo; + QString title; + if (networkDeviceInfo.hostName().isEmpty()) { + title = networkDeviceInfo.address().toString(); + } else { + title = networkDeviceInfo.hostName() + " (" + + networkDeviceInfo.address().toString() + ")"; + } - QString title; - if (networkDeviceInfo.hostName().isEmpty()) { - title = networkDeviceInfo.address().toString(); - } else { - title = networkDeviceInfo.hostName() + " (" + networkDeviceInfo.address().toString() + ")"; + QString description; + if (networkDeviceInfo.macAddressManufacturer().isEmpty()) { + description = networkDeviceInfo.macAddress(); + } else { + description = networkDeviceInfo.macAddress() + " (" + + networkDeviceInfo.macAddressManufacturer() + + ")"; + } + + ThingDescriptor descriptor(stiebelEltronThingClassId, title, + description); + ParamList params; + params << Param(stiebelEltronThingIpAddressParamTypeId, + networkDeviceInfo.address().toString()); + params << Param(stiebelEltronThingMacAddressParamTypeId, + networkDeviceInfo.macAddress()); + descriptor.setParams(params); + + // Check if we already have set up this device + Things existingThings = myThings().filterByParam( + stiebelEltronThingMacAddressParamTypeId, + networkDeviceInfo.macAddress()); + if (existingThings.count() == 1) { + qCDebug(dcStiebelEltron()) + << "This connection already exists in the system:" + << networkDeviceInfo; + descriptor.setThingId(existingThings.first()->id()); + } + + info->addThingDescriptor(descriptor); } - QString description; - if (networkDeviceInfo.macAddressManufacturer().isEmpty()) { - description = networkDeviceInfo.macAddress(); - } else { - description = networkDeviceInfo.macAddress() + " (" + networkDeviceInfo.macAddressManufacturer() + ")"; - } - - ThingDescriptor descriptor(stiebelEltronThingClassId, title, description); - ParamList params; - params << Param(stiebelEltronThingIpAddressParamTypeId, networkDeviceInfo.address().toString()); - params << Param(stiebelEltronThingMacAddressParamTypeId, networkDeviceInfo.macAddress()); - descriptor.setParams(params); - - // Check if we already have set up this device - Things existingThings = myThings().filterByParam(stiebelEltronThingMacAddressParamTypeId, networkDeviceInfo.macAddress()); - if (existingThings.count() == 1) { - qCDebug(dcStiebelEltron()) << "This connection already exists in the system:" << networkDeviceInfo; - descriptor.setThingId(existingThings.first()->id()); - } - - info->addThingDescriptor(descriptor); - } - - info->finish(Thing::ThingErrorNoError); - }); + info->finish(Thing::ThingErrorNoError); + }); } -void IntegrationPluginStiebelEltron::startMonitoringAutoThings() -{ +void IntegrationPluginStiebelEltron::startMonitoringAutoThings() {} -} - -void IntegrationPluginStiebelEltron::setupThing(ThingSetupInfo *info) -{ +void IntegrationPluginStiebelEltron::setupThing(ThingSetupInfo *info) { Thing *thing = info->thing(); qCDebug(dcStiebelEltron()) << "Setup" << thing << thing->params(); if (thing->thingClassId() == stiebelEltronThingClassId) { + QHostAddress address( + thing->paramValue(stiebelEltronThingIpAddressParamTypeId) + .toString()); + quint16 port = + thing->paramValue(stiebelEltronThingPortParamTypeId).toUInt(); + quint16 slaveId = + thing->paramValue(stiebelEltronThingSlaveIdParamTypeId).toUInt(); - QHostAddress address(thing->paramValue(stiebelEltronThingIpAddressParamTypeId).toString()); - quint16 port = thing->paramValue(stiebelEltronThingPortParamTypeId).toUInt(); - quint16 slaveId = thing->paramValue(stiebelEltronThingSlaveIdParamTypeId).toUInt(); + StiebelEltronModbusConnection *connection = + new StiebelEltronModbusConnection(address, port, slaveId, this); - StiebelEltronModbusConnection *connection = new StiebelEltronModbusConnection(address, port, slaveId, this); + connect( + connection, &StiebelEltronModbusConnection::connectionStateChanged, + this, [thing, connection](bool status) { + qCDebug(dcStiebelEltron()) + << "Connected changed to" << status << "for" << thing; + if (status) { + connection->update(); + } - connection->connectDevice(); + thing->setStateValue(stiebelEltronConnectedStateTypeId, status); + }); + connect(connection, + &StiebelEltronModbusConnection::outdoorTemperatureChanged, this, + [thing](float outdoorTemperature) { + qCDebug(dcStiebelEltron()) + << thing << "outdoor temperature changed" + << outdoorTemperature << "°C"; + thing->setStateValue( + stiebelEltronOutdoorTemperatureStateTypeId, + outdoorTemperature); + }); + + connect( + connection, &StiebelEltronModbusConnection::flowTemperatureChanged, + this, [thing](float flowTemperature) { + qCDebug(dcStiebelEltron()) + << thing << "flow temperature changed" << flowTemperature + << "°C"; + thing->setStateValue(stiebelEltronFlowTemperatureStateTypeId, + flowTemperature); + }); + + connect(connection, + &StiebelEltronModbusConnection::hotWaterTemperatureChanged, + this, [thing](float hotWaterTemperature) { + qCDebug(dcStiebelEltron()) + << thing << "hot water temperature changed" + << hotWaterTemperature << "°C"; + thing->setStateValue( + stiebelEltronHotWaterTemperatureStateTypeId, + hotWaterTemperature); + }); + connect(connection, + &StiebelEltronModbusConnection::storageTankTemperatureChanged, + this, [thing](float storageTankTemperature) { + qCDebug(dcStiebelEltron()) + << thing << "Storage tank temperature changed" + << storageTankTemperature << "°C"; + thing->setStateValue( + stiebelEltronStorageTankTemperatureStateTypeId, + storageTankTemperature); + }); + connect(connection, + &StiebelEltronModbusConnection::returnTemperatureChanged, this, + [thing](float returnTemperature) { + qCDebug(dcStiebelEltron()) + << thing << "return temperature changed" + << returnTemperature << "°C"; + thing->setStateValue( + stiebelEltronReturnTemperatureStateTypeId, + returnTemperature); + }); + connect( + connection, &StiebelEltronModbusConnection::heatingEnergyChanged, + this, [thing](quint32 heatingEnergy) { + // kWh and MWh of energy are stored in two registers an read as + // an uint32. The following arithmetic splits the uint32 into + // two uint16 and sums up the MWh and kWh values. + quint32 correctedEnergy = + (heatingEnergy >> 16) + (heatingEnergy & 0xFFFF) * 1000; + qCDebug(dcStiebelEltron()) << thing << "Heating energy changed" + << correctedEnergy << "kWh"; + thing->setStateValue(stiebelEltronHeatingEnergyStateTypeId, + correctedEnergy); + }); + connect(connection, + &StiebelEltronModbusConnection::hotWaterEnergyChanged, this, + [thing](quint32 hotWaterEnergy) { + // see comment in heatingEnergyChanged + quint32 correctedEnergy = (hotWaterEnergy >> 16) + + (hotWaterEnergy & 0xFFFF) * 1000; + qCDebug(dcStiebelEltron()) + << thing << "Hot Water energy changed" + << correctedEnergy << "kWh"; + thing->setStateValue(stiebelEltronHotWaterEnergyStateTypeId, + correctedEnergy); + }); + connect(connection, + &StiebelEltronModbusConnection::consumedEnergyHeatingChanged, + this, [thing](quint32 consumedEnergyHeatingEnergy) { + // see comment in heatingEnergyChanged + quint32 correctedEnergy = + (consumedEnergyHeatingEnergy >> 16) + + (consumedEnergyHeatingEnergy & 0xFFFF) * 1000; + qCDebug(dcStiebelEltron()) + << thing << "Consumed energy Heating changed" + << correctedEnergy << "kWh"; + thing->setStateValue( + stiebelEltronConsumedEnergyHeatingStateTypeId, + correctedEnergy); + }); + connect(connection, + &StiebelEltronModbusConnection::consumedEnergyHotWaterChanged, + this, [thing](quint32 consumedEnergyHotWaterEnergy) { + // see comment in heatingEnergyChanged + quint32 correctedEnergy = + (consumedEnergyHotWaterEnergy >> 16) + + (consumedEnergyHotWaterEnergy & 0xFFFF) * 1000; + qCDebug(dcStiebelEltron()) + << thing << "Consumed energy hot water changed" + << correctedEnergy << "kWh"; + thing->setStateValue( + stiebelEltronConsumedEnergyHotWaterStateTypeId, + correctedEnergy); + }); + + connect( + connection, &StiebelEltronModbusConnection::operatingModeChanged, + this, + [thing]( + StiebelEltronModbusConnection::OperatingMode operatingMode) { + qCDebug(dcStiebelEltron()) + << thing << "operating mode changed " << operatingMode; + switch (operatingMode) { + case StiebelEltronModbusConnection::OperatingModeEmergency: + thing->setStateValue( + stiebelEltronOperatingModeStateTypeId, "Emergency"); + break; + case StiebelEltronModbusConnection::OperatingModeStandby: + thing->setStateValue( + stiebelEltronOperatingModeStateTypeId, "Standby"); + break; + case StiebelEltronModbusConnection::OperatingModeProgram: + thing->setStateValue( + stiebelEltronOperatingModeStateTypeId, "Program"); + break; + case StiebelEltronModbusConnection::OperatingModeComfort: + thing->setStateValue( + stiebelEltronOperatingModeStateTypeId, "Comfort"); + break; + case StiebelEltronModbusConnection::OperatingModeEco: + thing->setStateValue( + stiebelEltronOperatingModeStateTypeId, "Eco"); + break; + case StiebelEltronModbusConnection::OperatingModeHotWater: + thing->setStateValue( + stiebelEltronOperatingModeStateTypeId, "Hot water"); + break; + } + }); + connect(connection, &StiebelEltronModbusConnection::systemStatusChanged, + this, [thing](uint16_t systemStatus) { + qCDebug(dcStiebelEltron()) + << thing << "System status changed " << systemStatus; + + thing->setStateValue(stiebelEltronPumpOneStateTypeId, + systemStatus & (1 << 0)); + + thing->setStateValue(stiebelEltronPumpTwoStateTypeId, + systemStatus & (1 << 1)); + thing->setStateValue(stiebelEltronHeatingUpStateTypeId, + systemStatus & (1 << 2)); + + thing->setStateValue(stiebelEltronAuxHeatingStateTypeId, + systemStatus & (1 << 3)); + thing->setStateValue(stiebelEltronHeatingStateTypeId, + systemStatus & (1 << 4)); + thing->setStateValue(stiebelEltronHotWaterStateTypeId, + systemStatus & (1 << 5)); + thing->setStateValue(stiebelEltronCompressorStateTypeId, + systemStatus & (1 << 6)); + thing->setStateValue(stiebelEltronSummerModeStateTypeId, + systemStatus & (1 << 7)); + thing->setStateValue(stiebelEltronCoolingModeStateTypeId, + systemStatus & (1 << 8)); + thing->setStateValue(stiebelEltronDefrostingStateTypeId, + systemStatus & (1 << 9)); + thing->setStateValue(stiebelEltronSilentModeStateTypeId, + systemStatus & (1 << 10)); + thing->setStateValue(stiebelEltronPowerStateTypeId, + systemStatus & (1 << 11)); + }); + + connect( + connection, &StiebelEltronModbusConnection::sgReadyStateChanged, + this, + [thing](StiebelEltronModbusConnection::SmartGridState + smartGridState) { + qCDebug(dcStiebelEltron()) + << thing << "SG Ready activation changed" << smartGridState; + switch (smartGridState) { + case StiebelEltronModbusConnection::SmartGridStateModeOne: + thing->setStateValue( + stiebelEltronSgReadyModeStateTypeId, "Mode 1"); + break; + case StiebelEltronModbusConnection::SmartGridStateModeTwo: + thing->setStateValue( + stiebelEltronSgReadyModeStateTypeId, "Mode 2"); + break; + case StiebelEltronModbusConnection::SmartGridStateModeThree: + thing->setStateValue( + stiebelEltronSgReadyModeStateTypeId, "Mode 3"); + break; + case StiebelEltronModbusConnection::SmartGridStateModeFour: + thing->setStateValue( + stiebelEltronSgReadyModeStateTypeId, "Mode 4"); + break; + } + }); + connect(connection, + &StiebelEltronModbusConnection::sgReadyActiveChanged, this, + [thing](bool smartGridActive) { + qCDebug(dcStiebelEltron()) + << thing << "SG Ready activation changed" + << smartGridActive; + thing->setStateValue(stiebelEltronSgReadyActiveStateTypeId, + smartGridActive); + }); m_connections.insert(thing, connection); + connection->connectDevice(); + info->finish(Thing::ThingErrorNoError); } - - } -void IntegrationPluginStiebelEltron::postSetupThing(Thing *thing) -{ +void IntegrationPluginStiebelEltron::postSetupThing(Thing *thing) { if (thing->thingClassId() == stiebelEltronThingClassId) { if (!m_pluginTimer) { qCDebug(dcStiebelEltron()) << "Starting plugin timer..."; - m_pluginTimer = hardwareManager()->pluginTimerManager()->registerTimer(10); + m_pluginTimer = + hardwareManager()->pluginTimerManager()->registerTimer(10); connect(m_pluginTimer, &PluginTimer::timeout, this, [this] { - foreach (StiebelEltronModbusConnection *connection, m_connections) { + foreach (StiebelEltronModbusConnection *connection, + m_connections) { if (connection->connected()) { connection->update(); } @@ -134,9 +363,9 @@ void IntegrationPluginStiebelEltron::postSetupThing(Thing *thing) } } -void IntegrationPluginStiebelEltron::thingRemoved(Thing *thing) -{ - if (thing->thingClassId() == stiebelEltronThingClassId && m_connections.contains(thing)) { +void IntegrationPluginStiebelEltron::thingRemoved(Thing *thing) { + if (thing->thingClassId() == stiebelEltronThingClassId && + m_connections.contains(thing)) { m_connections.take(thing)->deleteLater(); } @@ -146,9 +375,56 @@ void IntegrationPluginStiebelEltron::thingRemoved(Thing *thing) } } -void IntegrationPluginStiebelEltron::executeAction(ThingActionInfo *info) -{ - info->finish(Thing::ThingErrorNoError); +void IntegrationPluginStiebelEltron::executeAction(ThingActionInfo *info) { + Thing *thing = info->thing(); + StiebelEltronModbusConnection *connection = m_connections.value(thing); + + + + if (!connection->connected()) { + qCWarning(dcStiebelEltron()) << "Could not execute action. The modbus connection is currently not available."; + info->finish(Thing::ThingErrorHardwareNotAvailable); + return; + } + + // Got this from StiebelEltron plugin, not sure if necessary + if (thing->thingClassId() != stiebelEltronThingClassId) { + info->finish(Thing::ThingErrorNoError); + } + + if (info->action().actionTypeId() == stiebelEltronSgReadyActiveActionTypeId) { + bool sgReadyActiveBool = info->action().paramValue(stiebelEltronSgReadyActiveActionSgReadyActiveParamTypeId).toBool(); + qCDebug(dcStiebelEltron()) << "Execute action" << info->action().actionTypeId().toString() << info->action().params(); + qCDebug(dcStiebelEltron()) << "Value: " << sgReadyActiveBool; + + QModbusReply *reply = connection->setSgReadyActive(sgReadyActiveBool); + if (!reply) { + qCWarning(dcStiebelEltron()) << "Execute action failed because the reply could not be created."; + info->finish(Thing::ThingErrorHardwareFailure); + return; + } + + + connect(reply, &QModbusReply::finished, reply, &QModbusReply::deleteLater); + connect(reply, &QModbusReply::finished, info, [info, reply, sgReadyActiveBool]{ + if (reply->error() != QModbusDevice::NoError) { + qCWarning(dcStiebelEltron()) << "Set SG ready activation finished with error" << reply->errorString(); + info->finish(Thing::ThingErrorHardwareFailure); + return; + } + + + qCDebug(dcStiebelEltron()) << "Execute action finished successfully" << info->action().actionTypeId().toString() << info->action().params(); + info->thing()->setStateValue(stiebelEltronSgReadyActiveStateTypeId, sgReadyActiveBool); + info->finish(Thing::ThingErrorNoError); + }); + + connect(reply, &QModbusReply::errorOccurred, this, [reply] (QModbusDevice::Error error){ + qCWarning(dcStiebelEltron()) << "Modbus reply error occurred while execute action" << error << reply->errorString(); + emit reply->finished(); // To make sure it will be deleted + }); + } + + info->finish(Thing::ThingErrorNoError); } - diff --git a/stiebeleltron/integrationpluginstiebeleltron.json b/stiebeleltron/integrationpluginstiebeleltron.json index d7ae4e2..58e3088 100644 --- a/stiebeleltron/integrationpluginstiebeleltron.json +++ b/stiebeleltron/integrationpluginstiebeleltron.json @@ -57,7 +57,7 @@ "cached": false }, { - "id": "d6475acb-3a15-401b-8bad-8610eb056bf7", + "id": "1ec958c8-7bf1-469e-b35e-b71fa2099e91", "name": "flowTemperature", "displayName": "Flow temperature", "displayNameEvent": "Flow temperature changed", @@ -76,32 +76,261 @@ "defaultValue": 0, "suggestLogging": true }, + { - "id": "7d474fb5-aa37-4f21-8166-b20f5bf84fb4", - "name": "sgReadyMode", - "displayName": "Smart grid mode", - "displayNameEvent": "Smart grid mode changed", - "displayNameAction": "Set smart grid mode", - "type": "QString", - "possibleValues": [ - "Off", - "Low", - "Standard", - "High" - ], - "writable": true, - "defaultValue": "Standard", + "id": "e86cbac5-c2c3-4fcf-8caa-dbfc0df2584d", + "name": "outdoorTemperature", + "displayName": "Outdoor temperature", + "displayNameEvent": "Outdoor temperature changed", + "unit": "DegreeCelsius", + "type": "double", + "defaultValue": 0, "suggestLogging": true }, { - "id": "f4abbd8d-14d6-4294-9b63-411a9721f946", - "name": "totalEnergy", - "displayName": "Total energy", - "displayNameEvent": "Total energy changed", + "id": "27c56897-75f1-45af-9a14-b0620053d2d2", + "name": "hotWaterTemperature", + "displayName": "Hot water temperature", + "displayNameEvent": "Hot water changed", + "unit": "DegreeCelsius", "type": "double", - "unit": "KiloWattHour", "defaultValue": 0, "suggestLogging": true + }, + { + "id": "5833ceb6-5e7c-437b-a44a-e9f5eb42b6ac", + "name": "sourceTemperature", + "displayName": "Source temperature", + "displayNameEvent": "Source temperature changed", + "unit": "DegreeCelsius", + "type": "double", + "defaultValue": 0, + "suggestLogging": true + }, + { + "id": "d1959819-9e56-47f7-b619-a393ce50738a", + "name": "roomTemperature1", + "displayName": "Room temperature 1", + "displayNameEvent": "Room temperature 1 changed", + "unit": "DegreeCelsius", + "type": "double", + "defaultValue": 0, + "suggestLogging": true + }, + { + "id": "04ac741c-5277-4806-be73-576a164ecb46", + "name": "roomTemperature2", + "displayName": "Room temperature 1", + "displayNameEvent": "Room temperature changed", + "unit": "DegreeCelsius", + "type": "double", + "defaultValue": 0, + "suggestLogging": true + }, + { + "id": "43dd25b3-8782-4faa-a9e0-2fb10892fa0c", + "name": "storageTankTemperature", + "displayName": "Storage tank temperature", + "displayNameEvent": "Storage tank temperature changed", + "unit": "DegreeCelsius", + "type": "double", + "defaultValue": 0, + "suggestLogging": true + }, + { + "id": "d0597f21-2c0e-4db6-92e0-4a3b66474f87", + "name": "heatingEnergy", + "displayName": "Heating energy", + "displayNameEvent": "Heating energy changed", + "unit": "KiloWattHour", + "type": "uint", + "defaultValue": 0, + "suggestLogging": true + }, + { + "id": "9761060e-f364-466e-8661-d28f01b862fc", + "name": "hotWaterEnergy", + "displayName": "Hot water energy", + "displayNameEvent": "Hot water energy changed", + "unit": "KiloWattHour", + "type": "uint", + "defaultValue": 0, + "suggestLogging": true + }, + { + "id": "11f91606-d550-4918-9fca-69e3303389c8", + "name": "consumedEnergyHotWater", + "displayName": "Consumed energy hot water", + "displayNameEvent": "Consumed energy hot water changed", + "unit": "KiloWattHour", + "type": "uint", + "defaultValue": 0, + "suggestLogging": true + }, + { + "id": "6816dfef-3f54-4bf1-b0d5-641f06785991", + "name": "consumedEnergyHeating", + "displayName": "Consumed energy heating", + "displayNameEvent": "Consumed energy heating changed", + "unit": "KiloWattHour", + "type": "uint", + "defaultValue": 0, + "suggestLogging": true + }, + { + "id": "932cc41e-53ae-48ae-baa2-6f385f5aa791", + "name": "operatingMode", + "displayName": "Operating mode", + "displayNameEvent": "Operating mode changed", + "displayNameAction": "Set operating mode", + "type": "QString", + "possibleValues": [ + "Emergency", + "Standby", + "Program", + "Comfort", + "Eco", + "Hot water" + ], + "writable": false, + "defaultValue": "Standby", + "suggestLogging": true + }, + { + "id": "0ad36f3e-96ff-49d0-8b12-b8c6fed1bf4b", + "name": "pumpOne", + "displayName": "Pump 1", + "displayNameEvent": "Pump 1 status changed", + "type": "bool", + "defaultValue": false, + "suggestLogging": true + }, + { + "id": "1c211fb2-da78-41ad-b7d0-e404141a3dd5", + "name": "pumpTwo", + "displayName": "Pump 2", + "displayNameEvent": "Pump 2 status changed", + "type": "bool", + "defaultValue": false, + "suggestLogging": true + }, + { + "id": "ad0b8df8-1eaa-409d-b5e2-a76d7c17c2b9", + "name": "heatingUp", + "displayName": "Heating up", + "displayNameEvent": "Heating up status changed", + "type": "bool", + "defaultValue": false, + "suggestLogging": true + }, + { + "id": "44d5f18b-0389-4a7d-9cb8-f760ce06814e", + "name": "auxHeating", + "displayName": "Electric auxiliary heating", + "displayNameEvent": "Electric auxiliary heating status changed", + "type": "bool", + "defaultValue": false, + "suggestLogging": true + }, + { + "id": "3e44e580-f515-47ae-984b-109b507a5db2", + "name": "heating", + "displayName": "Heating mode", + "displayNameEvent": "Heating mode status changed", + "type": "bool", + "defaultValue": false, + "suggestLogging": true + }, + { + "id": "b6338cdb-863e-4191-adc4-bc6da5a67351", + "name": "hotWater", + "displayName": "Hot water mode", + "displayNameEvent": "Hot water mode status changed", + "type": "bool", + "defaultValue": false, + "suggestLogging": true + }, + { + "id": "c957cef8-b3a7-4626-ab95-db5439fbdf7f", + "name": "compressor", + "displayName": "Compressor", + "displayNameEvent": "Compressor status changed", + "type": "bool", + "defaultValue": false, + "suggestLogging": true + }, + { + "id": "7a287cfb-9088-4aad-a991-3e43714dc64e", + "name": "summerMode", + "displayName": "Summer mode", + "displayNameEvent": "Sommer mode status changed", + "type": "bool", + "defaultValue": false, + "suggestLogging": true + }, + { + "id": "1bfd99ee-1477-4f70-8717-a3a2930b137f", + "name": "coolingMode", + "displayName": "Cooling mode", + "displayNameEvent": "Cooling mode status changed", + "type": "bool", + "defaultValue": false, + "suggestLogging": true + }, + { + "id": "5c47d9bb-66de-48aa-b90e-caa3ca8d44a5", + "name": "defrosting", + "displayName": "Defrosting mode", + "displayNameEvent": "Defrosting mode status changed", + "type": "bool", + "defaultValue": false, + "suggestLogging": true + }, + { + "id": "047fcb7d-9080-4b45-9a6e-5060fa43f7c2", + "name": "silentMode", + "displayName": "Silent mode", + "displayNameEvent": "Silent mode status changed", + "type": "bool", + "defaultValue": false, + "suggestLogging": true + }, + { + "id": "d77a30d9-98f7-40ec-bc55-77c547f24145", + "name": "power", + "displayName": "Power", + "displayNameEvent": "Power status changed", + "type": "bool", + "defaultValue": false, + "suggestLogging": true + }, + { + "id": "798458bb-d38e-4028-880a-6dcba409a2f5", + "name": "sgReadyActive", + "displayName": "SG Ready enabled", + "displayNameEvent": "SG Ready activation changed", + "displayNameAction": "Switch SG Ready on/off", + "type": "bool", + "writable": true, + "defaultValue": false, + "suggestLogging": true + }, + { + "id": "7d474fb5-aa37-4f21-8166-b20f5bf84fb4", + "name": "sgReadyMode", + "displayName": "SG Ready mode", + "displayNameEvent": "SG Ready mode changed", + "displayNameAction": "Set SG Ready mode", + "type": "QString", + "possibleValues": [ + "Mode 1", + "Mode 2", + "Mode 3", + "Mode 4" + ], + "writable": true, + "defaultValue": "Mode 3", + "suggestLogging": true } ], "actionTypes": [ ] diff --git a/stiebeleltron/stiebel-eltron-registers.json b/stiebeleltron/stiebel-eltron-registers.json index cdcc2ed..6fd0877 100644 --- a/stiebeleltron/stiebel-eltron-registers.json +++ b/stiebeleltron/stiebel-eltron-registers.json @@ -1,19 +1,331 @@ { "protocol": "TCP", "endianness": "BigEndian", + "enums": [ + { + "name": "OperatingMode", + "values": [ + { + "key": "Emergency", + "value": 0 + }, + { + "key": "Standby", + "value": 1 + }, + { + "key": "Program", + "value": 2 + }, + { + "key": "Comfort", + "value": 3 + }, + { + "key": "Eco", + "value": 4 + }, + { + "key": "HotWater", + "value": 5 + } + ] + }, + { + "name": "SmartGridState", + "values": [ + { + "key": "ModeOne", + "value": 1 + }, + { + "key": "ModeTwo", + "value": 2 + }, + { + "key": "ModeThree", + "value": 3 + }, + { + "key": "ModeFour", + "value": 4 + } + ] + } + ], "registers": [ { "id": "outdoorTemperature", - "address": 507, + "address": 506, "size": 1, "type": "int16", "registerType": "inputRegister", "readSchedule": "update", "description": "Outdoor temperature", "staticScaleFactor": -1, + "defaultValue": 0, + "unit": "°C", + "access": "RO" + }, + { + "id": "flowTemperature", + "address": 514, + "size": 1, + "type": "int16", + "registerType": "inputRegister", + "readSchedule": "update", + "description": "Flow temperature", + "staticScaleFactor": -1, + "defaultValue": 0, + "unit": "°C", + "access": "RO" + }, + { + "id": "hotWaterTemperature", + "address": 521, + "size": 1, + "type": "uint16", + "registerType": "inputRegister", + "readSchedule": "update", + "description": "Hot water temperature", + "staticScaleFactor": -1, "defaultValue": "0", "unit": "°C", "access": "RO" + }, + { + "id": "hotGasTemperature1", + "address": 543, + "size": 1, + "type": "uint16", + "registerType": "inputRegister", + "readSchedule": "update", + "description": "Hot gas temperature HP 1", + "staticScaleFactor": -1, + "defaultValue": "0", + "unit": "°C", + "access": "RO" + }, + { + "id": "hotGasTemperature2", + "address": 550, + "size": 1, + "type": "uint16", + "registerType": "inputRegister", + "readSchedule": "update", + "description": "Hot gas temperature HP 2", + "staticScaleFactor": -1, + "defaultValue": "0", + "unit": "°C", + "access": "RO" + }, + { + "id": "SourceTemperature", + "address": 562, + "size": 1, + "type": "uint16", + "registerType": "inputRegister", + "readSchedule": "update", + "description": "Source temperature", + "staticScaleFactor": -1, + "defaultValue": "0", + "unit": "°C", + "access": "RO" + }, + { + "id": "roomTemperatureFEK", + "address": 502, + "size": 1, + "type": "uint16", + "registerType": "inputRegister", + "readSchedule": "update", + "description": "Room temperature FEK", + "staticScaleFactor": -1, + "defaultValue": "0", + "unit": "°C", + "access": "RO" + }, + { + "id": "returnTemperature", + "address": 515, + "size": 1, + "type": "int16", + "registerType": "inputRegister", + "readSchedule": "update", + "description": "Return temperature", + "staticScaleFactor": -1, + "defaultValue": 0, + "unit": "°C", + "access": "RO" + }, + { + "id": "solarCollectorTemperature", + "address": 527, + "size": 1, + "type": "uint16", + "registerType": "inputRegister", + "readSchedule": "update", + "description": "Solar collector temperature", + "staticScaleFactor": -1, + "defaultValue": "0", + "unit": "°C", + "access": "RO" + }, + { + "id": "solarStorageTankTemperature", + "address": 528, + "size": 1, + "type": "uint16", + "registerType": "inputRegister", + "readSchedule": "update", + "description": "Solar storage tank temperature", + "staticScaleFactor": -1, + "defaultValue": "0", + "unit": "°C", + "access": "RO" + }, + { + "id": "storageTankTemperature", + "address": 517, + "size": 1, + "type": "uint16", + "registerType": "inputRegister", + "readSchedule": "update", + "description": "Storage tank temperature", + "staticScaleFactor": -1, + "defaultValue": "0", + "unit": "°C", + "access": "RO" + }, + { + "id": "externalHeatSourceTemperature", + "address": 530, + "size": 1, + "type": "uint16", + "registerType": "inputRegister", + "readSchedule": "update", + "description": "External heat source temperature", + "staticScaleFactor": -1, + "defaultValue": "0", + "unit": "°C", + "access": "RO" + }, + { + "id": "heatingEnergy", + "address": 3501, + "size": 2, + "type": "uint32", + "registerType": "inputRegister", + "readSchedule": "update", + "defaultValue": "0", + "unit": "kWh", + "description": "Heating energy", + "access": "RO" + }, + { + "id": "hotWaterEnergy", + "address": 3504, + "size": 2, + "type": "uint32", + "registerType": "inputRegister", + "readSchedule": "update", + "defaultValue": "0", + "unit": "kWh", + "description": "Hot water energy", + "access": "RO" + }, + { + "id": "consumedEnergyHeating", + "address": 3511, + "size": 2, + "type": "uint32", + "registerType": "inputRegister", + "readSchedule": "update", + "defaultValue": "0", + "unit": "kWh", + "description": "Consumed energy heating", + "access": "RO" + }, + { + "id": "consumedEnergyHotWater", + "address": 3514, + "size": 2, + "type": "uint32", + "registerType": "inputRegister", + "readSchedule": "update", + "defaultValue": "0", + "unit": "kWh", + "description": "Consumed energy hot water", + "access": "RO" + }, + { + "id": "operatingMode", + "address": 1500, + "size": 1, + "type": "uint16", + "enum": "OperatingMode", + "registerType": "holdingRegister", + "readSchedule": "update", + "description": "Operating mode", + "defaultValue": "OperatingModeStandby", + "access": "RO" + }, + { + "id": "systemStatus", + "address": 2500, + "size": 1, + "type": "uint16", + "registerType": "inputRegister", + "readSchedule": "update", + "description": "System status", + "defaultValue": 0, + "access": "RO" + }, + { + "id": "sgReadyState", + "address": 5000, + "size": 1, + "type": "uint16", + "enum": "SmartGridState", + "registerType": "inputRegister", + "readSchedule": "update", + "description": "Smart grid status", + "defaultValue": "SmartGridStateModeTwo", + "access": "RO" + }, + { + "id": "sgReadyActive", + "address": 4000, + "size": 1, + "type": "uint16", + "registerType": "holdingRegister", + "readSchedule": "update", + "description": "SG ready active", + "defaultValue": 0, + "access": "RW" + }, + { + "id": "sgReadyInputOne", + "address": 4001, + "size": 1, + "type": "uint16", + "registerType": "holdingRegister", + "readSchedule": "update", + "description": "SG Ready Input 1", + "defaultValue": 0, + "access": "RW" + }, + { + "id": "sgReadyInputTwo", + "address": 4002, + "size": 1, + "type": "uint16", + "registerType": "holdingRegister", + "readSchedule": "update", + "description": "SG Read Input 2", + "defaultValue": 0, + "access": "RW" } + ] -} \ No newline at end of file +} diff --git a/stiebeleltron/stiebeleltronmodbusconnection.cpp b/stiebeleltron/stiebeleltronmodbusconnection.cpp index 15bd8e5..a7bc246 100644 --- a/stiebeleltron/stiebeleltronmodbusconnection.cpp +++ b/stiebeleltron/stiebeleltronmodbusconnection.cpp @@ -46,6 +46,138 @@ float StiebelEltronModbusConnection::outdoorTemperature() const return m_outdoorTemperature; } +float StiebelEltronModbusConnection::flowTemperature() const +{ + return m_flowTemperature; +} + +float StiebelEltronModbusConnection::hotWaterTemperature() const +{ + return m_hotWaterTemperature; +} + +float StiebelEltronModbusConnection::hotGasTemperature1() const +{ + return m_hotGasTemperature1; +} + +float StiebelEltronModbusConnection::hotGasTemperature2() const +{ + return m_hotGasTemperature2; +} + +float StiebelEltronModbusConnection::SourceTemperature() const +{ + return m_SourceTemperature; +} + +float StiebelEltronModbusConnection::roomTemperatureFEK() const +{ + return m_roomTemperatureFEK; +} + +float StiebelEltronModbusConnection::returnTemperature() const +{ + return m_returnTemperature; +} + +float StiebelEltronModbusConnection::solarCollectorTemperature() const +{ + return m_solarCollectorTemperature; +} + +float StiebelEltronModbusConnection::solarStorageTankTemperature() const +{ + return m_solarStorageTankTemperature; +} + +float StiebelEltronModbusConnection::storageTankTemperature() const +{ + return m_storageTankTemperature; +} + +float StiebelEltronModbusConnection::externalHeatSourceTemperature() const +{ + return m_externalHeatSourceTemperature; +} + +quint32 StiebelEltronModbusConnection::heatingEnergy() const +{ + return m_heatingEnergy; +} + +quint32 StiebelEltronModbusConnection::hotWaterEnergy() const +{ + return m_hotWaterEnergy; +} + +quint32 StiebelEltronModbusConnection::consumedEnergyHeating() const +{ + return m_consumedEnergyHeating; +} + +quint32 StiebelEltronModbusConnection::consumedEnergyHotWater() const +{ + return m_consumedEnergyHotWater; +} + +StiebelEltronModbusConnection::OperatingMode StiebelEltronModbusConnection::operatingMode() const +{ + return m_operatingMode; +} + +quint16 StiebelEltronModbusConnection::systemStatus() const +{ + return m_systemStatus; +} + +StiebelEltronModbusConnection::SmartGridState StiebelEltronModbusConnection::sgReadyState() const +{ + return m_sgReadyState; +} + +quint16 StiebelEltronModbusConnection::sgReadyActive() const +{ + return m_sgReadyActive; +} + +QModbusReply *StiebelEltronModbusConnection::setSgReadyActive(quint16 sgReadyActive) +{ + QVector values = ModbusDataUtils::convertFromUInt16(sgReadyActive); + qCDebug(dcStiebelEltronModbusConnection()) << "--> Write \"SG ready active\" register:" << 4000 << "size:" << 1 << values; + QModbusDataUnit request = QModbusDataUnit(QModbusDataUnit::RegisterType::HoldingRegisters, 4000, values.count()); + request.setValues(values); + return sendWriteRequest(request, m_slaveId); +} + +quint16 StiebelEltronModbusConnection::sgReadyInputOne() const +{ + return m_sgReadyInputOne; +} + +QModbusReply *StiebelEltronModbusConnection::setSgReadyInputOne(quint16 sgReadyInputOne) +{ + QVector values = ModbusDataUtils::convertFromUInt16(sgReadyInputOne); + qCDebug(dcStiebelEltronModbusConnection()) << "--> Write \"SG Ready Input 1\" register:" << 4001 << "size:" << 1 << values; + QModbusDataUnit request = QModbusDataUnit(QModbusDataUnit::RegisterType::HoldingRegisters, 4001, values.count()); + request.setValues(values); + return sendWriteRequest(request, m_slaveId); +} + +quint16 StiebelEltronModbusConnection::sgReadyInputTwo() const +{ + return m_sgReadyInputTwo; +} + +QModbusReply *StiebelEltronModbusConnection::setSgReadyInputTwo(quint16 sgReadyInputTwo) +{ + QVector values = ModbusDataUtils::convertFromUInt16(sgReadyInputTwo); + qCDebug(dcStiebelEltronModbusConnection()) << "--> Write \"SG Read Input 2\" register:" << 4002 << "size:" << 1 << values; + QModbusDataUnit request = QModbusDataUnit(QModbusDataUnit::RegisterType::HoldingRegisters, 4002, values.count()); + request.setValues(values); + return sendWriteRequest(request, m_slaveId); +} + void StiebelEltronModbusConnection::initialize() { // No init registers defined. Nothing to be done and we are finished. @@ -55,12 +187,33 @@ void StiebelEltronModbusConnection::initialize() void StiebelEltronModbusConnection::update() { updateOutdoorTemperature(); + updateFlowTemperature(); + updateHotWaterTemperature(); + updateHotGasTemperature1(); + updateHotGasTemperature2(); + updateSourceTemperature(); + updateRoomTemperatureFEK(); + updateReturnTemperature(); + updateSolarCollectorTemperature(); + updateSolarStorageTankTemperature(); + updateStorageTankTemperature(); + updateExternalHeatSourceTemperature(); + updateHeatingEnergy(); + updateHotWaterEnergy(); + updateConsumedEnergyHeating(); + updateConsumedEnergyHotWater(); + updateOperatingMode(); + updateSystemStatus(); + updateSgReadyState(); + updateSgReadyActive(); + updateSgReadyInputOne(); + updateSgReadyInputTwo(); } void StiebelEltronModbusConnection::updateOutdoorTemperature() { - // Update registers from Flow - qCDebug(dcStiebelEltronModbusConnection()) << "--> Read \"Flow\" register:" << 507 << "size:" << 1; + // Update registers from Outdoor temperature + qCDebug(dcStiebelEltronModbusConnection()) << "--> Read \"Outdoor temperature\" register:" << 506 << "size:" << 1; QModbusReply *reply = readOutdoorTemperature(); if (reply) { if (!reply->isFinished()) { @@ -69,7 +222,7 @@ void StiebelEltronModbusConnection::updateOutdoorTemperature() if (reply->error() == QModbusDevice::NoError) { const QModbusDataUnit unit = reply->result(); const QVector values = unit.values(); - qCDebug(dcStiebelEltronModbusConnection()) << "<-- Response from \"Flow\" register" << 507 << "size:" << 1 << values; + qCDebug(dcStiebelEltronModbusConnection()) << "<-- Response from \"Outdoor temperature\" register" << 506 << "size:" << 1 << values; float receivedOutdoorTemperature = ModbusDataUtils::convertToInt16(values) * 1.0 * pow(10, -1); if (m_outdoorTemperature != receivedOutdoorTemperature) { m_outdoorTemperature = receivedOutdoorTemperature; @@ -79,20 +232,839 @@ void StiebelEltronModbusConnection::updateOutdoorTemperature() }); connect(reply, &QModbusReply::errorOccurred, this, [this, reply] (QModbusDevice::Error error){ - qCWarning(dcStiebelEltronModbusConnection()) << "Modbus reply error occurred while updating \"Flow\" registers from" << hostAddress().toString() << error << reply->errorString(); + qCWarning(dcStiebelEltronModbusConnection()) << "Modbus reply error occurred while updating \"Outdoor temperature\" registers from" << hostAddress().toString() << error << reply->errorString(); emit reply->finished(); // To make sure it will be deleted }); } else { delete reply; // Broadcast reply returns immediatly } } else { - qCWarning(dcStiebelEltronModbusConnection()) << "Error occurred while reading \"Flow\" registers from" << hostAddress().toString() << errorString(); + qCWarning(dcStiebelEltronModbusConnection()) << "Error occurred while reading \"Outdoor temperature\" registers from" << hostAddress().toString() << errorString(); + } +} + +void StiebelEltronModbusConnection::updateFlowTemperature() +{ + // Update registers from Flow temperature + qCDebug(dcStiebelEltronModbusConnection()) << "--> Read \"Flow temperature\" register:" << 514 << "size:" << 1; + QModbusReply *reply = readFlowTemperature(); + if (reply) { + if (!reply->isFinished()) { + connect(reply, &QModbusReply::finished, reply, &QModbusReply::deleteLater); + connect(reply, &QModbusReply::finished, this, [this, reply](){ + if (reply->error() == QModbusDevice::NoError) { + const QModbusDataUnit unit = reply->result(); + const QVector values = unit.values(); + qCDebug(dcStiebelEltronModbusConnection()) << "<-- Response from \"Flow temperature\" register" << 514 << "size:" << 1 << values; + float receivedFlowTemperature = ModbusDataUtils::convertToInt16(values) * 1.0 * pow(10, -1); + if (m_flowTemperature != receivedFlowTemperature) { + m_flowTemperature = receivedFlowTemperature; + emit flowTemperatureChanged(m_flowTemperature); + } + } + }); + + connect(reply, &QModbusReply::errorOccurred, this, [this, reply] (QModbusDevice::Error error){ + qCWarning(dcStiebelEltronModbusConnection()) << "Modbus reply error occurred while updating \"Flow temperature\" registers from" << hostAddress().toString() << error << reply->errorString(); + emit reply->finished(); // To make sure it will be deleted + }); + } else { + delete reply; // Broadcast reply returns immediatly + } + } else { + qCWarning(dcStiebelEltronModbusConnection()) << "Error occurred while reading \"Flow temperature\" registers from" << hostAddress().toString() << errorString(); + } +} + +void StiebelEltronModbusConnection::updateHotWaterTemperature() +{ + // Update registers from Hot water temperature + qCDebug(dcStiebelEltronModbusConnection()) << "--> Read \"Hot water temperature\" register:" << 521 << "size:" << 1; + QModbusReply *reply = readHotWaterTemperature(); + if (reply) { + if (!reply->isFinished()) { + connect(reply, &QModbusReply::finished, reply, &QModbusReply::deleteLater); + connect(reply, &QModbusReply::finished, this, [this, reply](){ + if (reply->error() == QModbusDevice::NoError) { + const QModbusDataUnit unit = reply->result(); + const QVector values = unit.values(); + qCDebug(dcStiebelEltronModbusConnection()) << "<-- Response from \"Hot water temperature\" register" << 521 << "size:" << 1 << values; + float receivedHotWaterTemperature = ModbusDataUtils::convertToUInt16(values) * 1.0 * pow(10, -1); + if (m_hotWaterTemperature != receivedHotWaterTemperature) { + m_hotWaterTemperature = receivedHotWaterTemperature; + emit hotWaterTemperatureChanged(m_hotWaterTemperature); + } + } + }); + + connect(reply, &QModbusReply::errorOccurred, this, [this, reply] (QModbusDevice::Error error){ + qCWarning(dcStiebelEltronModbusConnection()) << "Modbus reply error occurred while updating \"Hot water temperature\" registers from" << hostAddress().toString() << error << reply->errorString(); + emit reply->finished(); // To make sure it will be deleted + }); + } else { + delete reply; // Broadcast reply returns immediatly + } + } else { + qCWarning(dcStiebelEltronModbusConnection()) << "Error occurred while reading \"Hot water temperature\" registers from" << hostAddress().toString() << errorString(); + } +} + +void StiebelEltronModbusConnection::updateHotGasTemperature1() +{ + // Update registers from Hot gas temperature HP 1 + qCDebug(dcStiebelEltronModbusConnection()) << "--> Read \"Hot gas temperature HP 1\" register:" << 543 << "size:" << 1; + QModbusReply *reply = readHotGasTemperature1(); + if (reply) { + if (!reply->isFinished()) { + connect(reply, &QModbusReply::finished, reply, &QModbusReply::deleteLater); + connect(reply, &QModbusReply::finished, this, [this, reply](){ + if (reply->error() == QModbusDevice::NoError) { + const QModbusDataUnit unit = reply->result(); + const QVector values = unit.values(); + qCDebug(dcStiebelEltronModbusConnection()) << "<-- Response from \"Hot gas temperature HP 1\" register" << 543 << "size:" << 1 << values; + float receivedHotGasTemperature1 = ModbusDataUtils::convertToUInt16(values) * 1.0 * pow(10, -1); + if (m_hotGasTemperature1 != receivedHotGasTemperature1) { + m_hotGasTemperature1 = receivedHotGasTemperature1; + emit hotGasTemperature1Changed(m_hotGasTemperature1); + } + } + }); + + connect(reply, &QModbusReply::errorOccurred, this, [this, reply] (QModbusDevice::Error error){ + qCWarning(dcStiebelEltronModbusConnection()) << "Modbus reply error occurred while updating \"Hot gas temperature HP 1\" registers from" << hostAddress().toString() << error << reply->errorString(); + emit reply->finished(); // To make sure it will be deleted + }); + } else { + delete reply; // Broadcast reply returns immediatly + } + } else { + qCWarning(dcStiebelEltronModbusConnection()) << "Error occurred while reading \"Hot gas temperature HP 1\" registers from" << hostAddress().toString() << errorString(); + } +} + +void StiebelEltronModbusConnection::updateHotGasTemperature2() +{ + // Update registers from Hot gas temperature HP 2 + qCDebug(dcStiebelEltronModbusConnection()) << "--> Read \"Hot gas temperature HP 2\" register:" << 550 << "size:" << 1; + QModbusReply *reply = readHotGasTemperature2(); + if (reply) { + if (!reply->isFinished()) { + connect(reply, &QModbusReply::finished, reply, &QModbusReply::deleteLater); + connect(reply, &QModbusReply::finished, this, [this, reply](){ + if (reply->error() == QModbusDevice::NoError) { + const QModbusDataUnit unit = reply->result(); + const QVector values = unit.values(); + qCDebug(dcStiebelEltronModbusConnection()) << "<-- Response from \"Hot gas temperature HP 2\" register" << 550 << "size:" << 1 << values; + float receivedHotGasTemperature2 = ModbusDataUtils::convertToUInt16(values) * 1.0 * pow(10, -1); + if (m_hotGasTemperature2 != receivedHotGasTemperature2) { + m_hotGasTemperature2 = receivedHotGasTemperature2; + emit hotGasTemperature2Changed(m_hotGasTemperature2); + } + } + }); + + connect(reply, &QModbusReply::errorOccurred, this, [this, reply] (QModbusDevice::Error error){ + qCWarning(dcStiebelEltronModbusConnection()) << "Modbus reply error occurred while updating \"Hot gas temperature HP 2\" registers from" << hostAddress().toString() << error << reply->errorString(); + emit reply->finished(); // To make sure it will be deleted + }); + } else { + delete reply; // Broadcast reply returns immediatly + } + } else { + qCWarning(dcStiebelEltronModbusConnection()) << "Error occurred while reading \"Hot gas temperature HP 2\" registers from" << hostAddress().toString() << errorString(); + } +} + +void StiebelEltronModbusConnection::updateSourceTemperature() +{ + // Update registers from Source temperature + qCDebug(dcStiebelEltronModbusConnection()) << "--> Read \"Source temperature\" register:" << 562 << "size:" << 1; + QModbusReply *reply = readSourceTemperature(); + if (reply) { + if (!reply->isFinished()) { + connect(reply, &QModbusReply::finished, reply, &QModbusReply::deleteLater); + connect(reply, &QModbusReply::finished, this, [this, reply](){ + if (reply->error() == QModbusDevice::NoError) { + const QModbusDataUnit unit = reply->result(); + const QVector values = unit.values(); + qCDebug(dcStiebelEltronModbusConnection()) << "<-- Response from \"Source temperature\" register" << 562 << "size:" << 1 << values; + float receivedSourceTemperature = ModbusDataUtils::convertToUInt16(values) * 1.0 * pow(10, -1); + if (m_SourceTemperature != receivedSourceTemperature) { + m_SourceTemperature = receivedSourceTemperature; + emit SourceTemperatureChanged(m_SourceTemperature); + } + } + }); + + connect(reply, &QModbusReply::errorOccurred, this, [this, reply] (QModbusDevice::Error error){ + qCWarning(dcStiebelEltronModbusConnection()) << "Modbus reply error occurred while updating \"Source temperature\" registers from" << hostAddress().toString() << error << reply->errorString(); + emit reply->finished(); // To make sure it will be deleted + }); + } else { + delete reply; // Broadcast reply returns immediatly + } + } else { + qCWarning(dcStiebelEltronModbusConnection()) << "Error occurred while reading \"Source temperature\" registers from" << hostAddress().toString() << errorString(); + } +} + +void StiebelEltronModbusConnection::updateRoomTemperatureFEK() +{ + // Update registers from Room temperature FEK + qCDebug(dcStiebelEltronModbusConnection()) << "--> Read \"Room temperature FEK\" register:" << 502 << "size:" << 1; + QModbusReply *reply = readRoomTemperatureFEK(); + if (reply) { + if (!reply->isFinished()) { + connect(reply, &QModbusReply::finished, reply, &QModbusReply::deleteLater); + connect(reply, &QModbusReply::finished, this, [this, reply](){ + if (reply->error() == QModbusDevice::NoError) { + const QModbusDataUnit unit = reply->result(); + const QVector values = unit.values(); + qCDebug(dcStiebelEltronModbusConnection()) << "<-- Response from \"Room temperature FEK\" register" << 502 << "size:" << 1 << values; + float receivedRoomTemperatureFEK = ModbusDataUtils::convertToUInt16(values) * 1.0 * pow(10, -1); + if (m_roomTemperatureFEK != receivedRoomTemperatureFEK) { + m_roomTemperatureFEK = receivedRoomTemperatureFEK; + emit roomTemperatureFEKChanged(m_roomTemperatureFEK); + } + } + }); + + connect(reply, &QModbusReply::errorOccurred, this, [this, reply] (QModbusDevice::Error error){ + qCWarning(dcStiebelEltronModbusConnection()) << "Modbus reply error occurred while updating \"Room temperature FEK\" registers from" << hostAddress().toString() << error << reply->errorString(); + emit reply->finished(); // To make sure it will be deleted + }); + } else { + delete reply; // Broadcast reply returns immediatly + } + } else { + qCWarning(dcStiebelEltronModbusConnection()) << "Error occurred while reading \"Room temperature FEK\" registers from" << hostAddress().toString() << errorString(); + } +} + +void StiebelEltronModbusConnection::updateReturnTemperature() +{ + // Update registers from Return temperature + qCDebug(dcStiebelEltronModbusConnection()) << "--> Read \"Return temperature\" register:" << 515 << "size:" << 1; + QModbusReply *reply = readReturnTemperature(); + if (reply) { + if (!reply->isFinished()) { + connect(reply, &QModbusReply::finished, reply, &QModbusReply::deleteLater); + connect(reply, &QModbusReply::finished, this, [this, reply](){ + if (reply->error() == QModbusDevice::NoError) { + const QModbusDataUnit unit = reply->result(); + const QVector values = unit.values(); + qCDebug(dcStiebelEltronModbusConnection()) << "<-- Response from \"Return temperature\" register" << 515 << "size:" << 1 << values; + float receivedReturnTemperature = ModbusDataUtils::convertToInt16(values) * 1.0 * pow(10, -1); + if (m_returnTemperature != receivedReturnTemperature) { + m_returnTemperature = receivedReturnTemperature; + emit returnTemperatureChanged(m_returnTemperature); + } + } + }); + + connect(reply, &QModbusReply::errorOccurred, this, [this, reply] (QModbusDevice::Error error){ + qCWarning(dcStiebelEltronModbusConnection()) << "Modbus reply error occurred while updating \"Return temperature\" registers from" << hostAddress().toString() << error << reply->errorString(); + emit reply->finished(); // To make sure it will be deleted + }); + } else { + delete reply; // Broadcast reply returns immediatly + } + } else { + qCWarning(dcStiebelEltronModbusConnection()) << "Error occurred while reading \"Return temperature\" registers from" << hostAddress().toString() << errorString(); + } +} + +void StiebelEltronModbusConnection::updateSolarCollectorTemperature() +{ + // Update registers from Solar collector temperature + qCDebug(dcStiebelEltronModbusConnection()) << "--> Read \"Solar collector temperature\" register:" << 527 << "size:" << 1; + QModbusReply *reply = readSolarCollectorTemperature(); + if (reply) { + if (!reply->isFinished()) { + connect(reply, &QModbusReply::finished, reply, &QModbusReply::deleteLater); + connect(reply, &QModbusReply::finished, this, [this, reply](){ + if (reply->error() == QModbusDevice::NoError) { + const QModbusDataUnit unit = reply->result(); + const QVector values = unit.values(); + qCDebug(dcStiebelEltronModbusConnection()) << "<-- Response from \"Solar collector temperature\" register" << 527 << "size:" << 1 << values; + float receivedSolarCollectorTemperature = ModbusDataUtils::convertToUInt16(values) * 1.0 * pow(10, -1); + if (m_solarCollectorTemperature != receivedSolarCollectorTemperature) { + m_solarCollectorTemperature = receivedSolarCollectorTemperature; + emit solarCollectorTemperatureChanged(m_solarCollectorTemperature); + } + } + }); + + connect(reply, &QModbusReply::errorOccurred, this, [this, reply] (QModbusDevice::Error error){ + qCWarning(dcStiebelEltronModbusConnection()) << "Modbus reply error occurred while updating \"Solar collector temperature\" registers from" << hostAddress().toString() << error << reply->errorString(); + emit reply->finished(); // To make sure it will be deleted + }); + } else { + delete reply; // Broadcast reply returns immediatly + } + } else { + qCWarning(dcStiebelEltronModbusConnection()) << "Error occurred while reading \"Solar collector temperature\" registers from" << hostAddress().toString() << errorString(); + } +} + +void StiebelEltronModbusConnection::updateSolarStorageTankTemperature() +{ + // Update registers from Solar storage tank temperature + qCDebug(dcStiebelEltronModbusConnection()) << "--> Read \"Solar storage tank temperature\" register:" << 528 << "size:" << 1; + QModbusReply *reply = readSolarStorageTankTemperature(); + if (reply) { + if (!reply->isFinished()) { + connect(reply, &QModbusReply::finished, reply, &QModbusReply::deleteLater); + connect(reply, &QModbusReply::finished, this, [this, reply](){ + if (reply->error() == QModbusDevice::NoError) { + const QModbusDataUnit unit = reply->result(); + const QVector values = unit.values(); + qCDebug(dcStiebelEltronModbusConnection()) << "<-- Response from \"Solar storage tank temperature\" register" << 528 << "size:" << 1 << values; + float receivedSolarStorageTankTemperature = ModbusDataUtils::convertToUInt16(values) * 1.0 * pow(10, -1); + if (m_solarStorageTankTemperature != receivedSolarStorageTankTemperature) { + m_solarStorageTankTemperature = receivedSolarStorageTankTemperature; + emit solarStorageTankTemperatureChanged(m_solarStorageTankTemperature); + } + } + }); + + connect(reply, &QModbusReply::errorOccurred, this, [this, reply] (QModbusDevice::Error error){ + qCWarning(dcStiebelEltronModbusConnection()) << "Modbus reply error occurred while updating \"Solar storage tank temperature\" registers from" << hostAddress().toString() << error << reply->errorString(); + emit reply->finished(); // To make sure it will be deleted + }); + } else { + delete reply; // Broadcast reply returns immediatly + } + } else { + qCWarning(dcStiebelEltronModbusConnection()) << "Error occurred while reading \"Solar storage tank temperature\" registers from" << hostAddress().toString() << errorString(); + } +} + +void StiebelEltronModbusConnection::updateStorageTankTemperature() +{ + // Update registers from Storage tank temperature + qCDebug(dcStiebelEltronModbusConnection()) << "--> Read \"Storage tank temperature\" register:" << 517 << "size:" << 1; + QModbusReply *reply = readStorageTankTemperature(); + if (reply) { + if (!reply->isFinished()) { + connect(reply, &QModbusReply::finished, reply, &QModbusReply::deleteLater); + connect(reply, &QModbusReply::finished, this, [this, reply](){ + if (reply->error() == QModbusDevice::NoError) { + const QModbusDataUnit unit = reply->result(); + const QVector values = unit.values(); + qCDebug(dcStiebelEltronModbusConnection()) << "<-- Response from \"Storage tank temperature\" register" << 517 << "size:" << 1 << values; + float receivedStorageTankTemperature = ModbusDataUtils::convertToUInt16(values) * 1.0 * pow(10, -1); + if (m_storageTankTemperature != receivedStorageTankTemperature) { + m_storageTankTemperature = receivedStorageTankTemperature; + emit storageTankTemperatureChanged(m_storageTankTemperature); + } + } + }); + + connect(reply, &QModbusReply::errorOccurred, this, [this, reply] (QModbusDevice::Error error){ + qCWarning(dcStiebelEltronModbusConnection()) << "Modbus reply error occurred while updating \"Storage tank temperature\" registers from" << hostAddress().toString() << error << reply->errorString(); + emit reply->finished(); // To make sure it will be deleted + }); + } else { + delete reply; // Broadcast reply returns immediatly + } + } else { + qCWarning(dcStiebelEltronModbusConnection()) << "Error occurred while reading \"Storage tank temperature\" registers from" << hostAddress().toString() << errorString(); + } +} + +void StiebelEltronModbusConnection::updateExternalHeatSourceTemperature() +{ + // Update registers from External heat source temperature + qCDebug(dcStiebelEltronModbusConnection()) << "--> Read \"External heat source temperature\" register:" << 530 << "size:" << 1; + QModbusReply *reply = readExternalHeatSourceTemperature(); + if (reply) { + if (!reply->isFinished()) { + connect(reply, &QModbusReply::finished, reply, &QModbusReply::deleteLater); + connect(reply, &QModbusReply::finished, this, [this, reply](){ + if (reply->error() == QModbusDevice::NoError) { + const QModbusDataUnit unit = reply->result(); + const QVector values = unit.values(); + qCDebug(dcStiebelEltronModbusConnection()) << "<-- Response from \"External heat source temperature\" register" << 530 << "size:" << 1 << values; + float receivedExternalHeatSourceTemperature = ModbusDataUtils::convertToUInt16(values) * 1.0 * pow(10, -1); + if (m_externalHeatSourceTemperature != receivedExternalHeatSourceTemperature) { + m_externalHeatSourceTemperature = receivedExternalHeatSourceTemperature; + emit externalHeatSourceTemperatureChanged(m_externalHeatSourceTemperature); + } + } + }); + + connect(reply, &QModbusReply::errorOccurred, this, [this, reply] (QModbusDevice::Error error){ + qCWarning(dcStiebelEltronModbusConnection()) << "Modbus reply error occurred while updating \"External heat source temperature\" registers from" << hostAddress().toString() << error << reply->errorString(); + emit reply->finished(); // To make sure it will be deleted + }); + } else { + delete reply; // Broadcast reply returns immediatly + } + } else { + qCWarning(dcStiebelEltronModbusConnection()) << "Error occurred while reading \"External heat source temperature\" registers from" << hostAddress().toString() << errorString(); + } +} + +void StiebelEltronModbusConnection::updateHeatingEnergy() +{ + // Update registers from Heating energy + qCDebug(dcStiebelEltronModbusConnection()) << "--> Read \"Heating energy\" register:" << 3501 << "size:" << 2; + QModbusReply *reply = readHeatingEnergy(); + if (reply) { + if (!reply->isFinished()) { + connect(reply, &QModbusReply::finished, reply, &QModbusReply::deleteLater); + connect(reply, &QModbusReply::finished, this, [this, reply](){ + if (reply->error() == QModbusDevice::NoError) { + const QModbusDataUnit unit = reply->result(); + const QVector values = unit.values(); + qCDebug(dcStiebelEltronModbusConnection()) << "<-- Response from \"Heating energy\" register" << 3501 << "size:" << 2 << values; + quint32 receivedHeatingEnergy = ModbusDataUtils::convertToUInt32(values, ModbusDataUtils::ByteOrderBigEndian); + if (m_heatingEnergy != receivedHeatingEnergy) { + m_heatingEnergy = receivedHeatingEnergy; + emit heatingEnergyChanged(m_heatingEnergy); + } + } + }); + + connect(reply, &QModbusReply::errorOccurred, this, [this, reply] (QModbusDevice::Error error){ + qCWarning(dcStiebelEltronModbusConnection()) << "Modbus reply error occurred while updating \"Heating energy\" registers from" << hostAddress().toString() << error << reply->errorString(); + emit reply->finished(); // To make sure it will be deleted + }); + } else { + delete reply; // Broadcast reply returns immediatly + } + } else { + qCWarning(dcStiebelEltronModbusConnection()) << "Error occurred while reading \"Heating energy\" registers from" << hostAddress().toString() << errorString(); + } +} + +void StiebelEltronModbusConnection::updateHotWaterEnergy() +{ + // Update registers from Hot water energy + qCDebug(dcStiebelEltronModbusConnection()) << "--> Read \"Hot water energy\" register:" << 3504 << "size:" << 2; + QModbusReply *reply = readHotWaterEnergy(); + if (reply) { + if (!reply->isFinished()) { + connect(reply, &QModbusReply::finished, reply, &QModbusReply::deleteLater); + connect(reply, &QModbusReply::finished, this, [this, reply](){ + if (reply->error() == QModbusDevice::NoError) { + const QModbusDataUnit unit = reply->result(); + const QVector values = unit.values(); + qCDebug(dcStiebelEltronModbusConnection()) << "<-- Response from \"Hot water energy\" register" << 3504 << "size:" << 2 << values; + quint32 receivedHotWaterEnergy = ModbusDataUtils::convertToUInt32(values, ModbusDataUtils::ByteOrderBigEndian); + if (m_hotWaterEnergy != receivedHotWaterEnergy) { + m_hotWaterEnergy = receivedHotWaterEnergy; + emit hotWaterEnergyChanged(m_hotWaterEnergy); + } + } + }); + + connect(reply, &QModbusReply::errorOccurred, this, [this, reply] (QModbusDevice::Error error){ + qCWarning(dcStiebelEltronModbusConnection()) << "Modbus reply error occurred while updating \"Hot water energy\" registers from" << hostAddress().toString() << error << reply->errorString(); + emit reply->finished(); // To make sure it will be deleted + }); + } else { + delete reply; // Broadcast reply returns immediatly + } + } else { + qCWarning(dcStiebelEltronModbusConnection()) << "Error occurred while reading \"Hot water energy\" registers from" << hostAddress().toString() << errorString(); + } +} + +void StiebelEltronModbusConnection::updateConsumedEnergyHeating() +{ + // Update registers from Consumed energy heating + qCDebug(dcStiebelEltronModbusConnection()) << "--> Read \"Consumed energy heating\" register:" << 3511 << "size:" << 2; + QModbusReply *reply = readConsumedEnergyHeating(); + if (reply) { + if (!reply->isFinished()) { + connect(reply, &QModbusReply::finished, reply, &QModbusReply::deleteLater); + connect(reply, &QModbusReply::finished, this, [this, reply](){ + if (reply->error() == QModbusDevice::NoError) { + const QModbusDataUnit unit = reply->result(); + const QVector values = unit.values(); + qCDebug(dcStiebelEltronModbusConnection()) << "<-- Response from \"Consumed energy heating\" register" << 3511 << "size:" << 2 << values; + quint32 receivedConsumedEnergyHeating = ModbusDataUtils::convertToUInt32(values, ModbusDataUtils::ByteOrderBigEndian); + if (m_consumedEnergyHeating != receivedConsumedEnergyHeating) { + m_consumedEnergyHeating = receivedConsumedEnergyHeating; + emit consumedEnergyHeatingChanged(m_consumedEnergyHeating); + } + } + }); + + connect(reply, &QModbusReply::errorOccurred, this, [this, reply] (QModbusDevice::Error error){ + qCWarning(dcStiebelEltronModbusConnection()) << "Modbus reply error occurred while updating \"Consumed energy heating\" registers from" << hostAddress().toString() << error << reply->errorString(); + emit reply->finished(); // To make sure it will be deleted + }); + } else { + delete reply; // Broadcast reply returns immediatly + } + } else { + qCWarning(dcStiebelEltronModbusConnection()) << "Error occurred while reading \"Consumed energy heating\" registers from" << hostAddress().toString() << errorString(); + } +} + +void StiebelEltronModbusConnection::updateConsumedEnergyHotWater() +{ + // Update registers from Consumed energy hot water + qCDebug(dcStiebelEltronModbusConnection()) << "--> Read \"Consumed energy hot water\" register:" << 3514 << "size:" << 2; + QModbusReply *reply = readConsumedEnergyHotWater(); + if (reply) { + if (!reply->isFinished()) { + connect(reply, &QModbusReply::finished, reply, &QModbusReply::deleteLater); + connect(reply, &QModbusReply::finished, this, [this, reply](){ + if (reply->error() == QModbusDevice::NoError) { + const QModbusDataUnit unit = reply->result(); + const QVector values = unit.values(); + qCDebug(dcStiebelEltronModbusConnection()) << "<-- Response from \"Consumed energy hot water\" register" << 3514 << "size:" << 2 << values; + quint32 receivedConsumedEnergyHotWater = ModbusDataUtils::convertToUInt32(values, ModbusDataUtils::ByteOrderBigEndian); + if (m_consumedEnergyHotWater != receivedConsumedEnergyHotWater) { + m_consumedEnergyHotWater = receivedConsumedEnergyHotWater; + emit consumedEnergyHotWaterChanged(m_consumedEnergyHotWater); + } + } + }); + + connect(reply, &QModbusReply::errorOccurred, this, [this, reply] (QModbusDevice::Error error){ + qCWarning(dcStiebelEltronModbusConnection()) << "Modbus reply error occurred while updating \"Consumed energy hot water\" registers from" << hostAddress().toString() << error << reply->errorString(); + emit reply->finished(); // To make sure it will be deleted + }); + } else { + delete reply; // Broadcast reply returns immediatly + } + } else { + qCWarning(dcStiebelEltronModbusConnection()) << "Error occurred while reading \"Consumed energy hot water\" registers from" << hostAddress().toString() << errorString(); + } +} + +void StiebelEltronModbusConnection::updateOperatingMode() +{ + // Update registers from Operating mode + qCDebug(dcStiebelEltronModbusConnection()) << "--> Read \"Operating mode\" register:" << 1500 << "size:" << 1; + QModbusReply *reply = readOperatingMode(); + if (reply) { + if (!reply->isFinished()) { + connect(reply, &QModbusReply::finished, reply, &QModbusReply::deleteLater); + connect(reply, &QModbusReply::finished, this, [this, reply](){ + if (reply->error() == QModbusDevice::NoError) { + const QModbusDataUnit unit = reply->result(); + const QVector values = unit.values(); + qCDebug(dcStiebelEltronModbusConnection()) << "<-- Response from \"Operating mode\" register" << 1500 << "size:" << 1 << values; + OperatingMode receivedOperatingMode = static_cast(ModbusDataUtils::convertToUInt16(values)); + if (m_operatingMode != receivedOperatingMode) { + m_operatingMode = receivedOperatingMode; + emit operatingModeChanged(m_operatingMode); + } + } + }); + + connect(reply, &QModbusReply::errorOccurred, this, [this, reply] (QModbusDevice::Error error){ + qCWarning(dcStiebelEltronModbusConnection()) << "Modbus reply error occurred while updating \"Operating mode\" registers from" << hostAddress().toString() << error << reply->errorString(); + emit reply->finished(); // To make sure it will be deleted + }); + } else { + delete reply; // Broadcast reply returns immediatly + } + } else { + qCWarning(dcStiebelEltronModbusConnection()) << "Error occurred while reading \"Operating mode\" registers from" << hostAddress().toString() << errorString(); + } +} + +void StiebelEltronModbusConnection::updateSystemStatus() +{ + // Update registers from System status + qCDebug(dcStiebelEltronModbusConnection()) << "--> Read \"System status\" register:" << 2500 << "size:" << 1; + QModbusReply *reply = readSystemStatus(); + if (reply) { + if (!reply->isFinished()) { + connect(reply, &QModbusReply::finished, reply, &QModbusReply::deleteLater); + connect(reply, &QModbusReply::finished, this, [this, reply](){ + if (reply->error() == QModbusDevice::NoError) { + const QModbusDataUnit unit = reply->result(); + const QVector values = unit.values(); + qCDebug(dcStiebelEltronModbusConnection()) << "<-- Response from \"System status\" register" << 2500 << "size:" << 1 << values; + quint16 receivedSystemStatus = ModbusDataUtils::convertToUInt16(values); + if (m_systemStatus != receivedSystemStatus) { + m_systemStatus = receivedSystemStatus; + emit systemStatusChanged(m_systemStatus); + } + } + }); + + connect(reply, &QModbusReply::errorOccurred, this, [this, reply] (QModbusDevice::Error error){ + qCWarning(dcStiebelEltronModbusConnection()) << "Modbus reply error occurred while updating \"System status\" registers from" << hostAddress().toString() << error << reply->errorString(); + emit reply->finished(); // To make sure it will be deleted + }); + } else { + delete reply; // Broadcast reply returns immediatly + } + } else { + qCWarning(dcStiebelEltronModbusConnection()) << "Error occurred while reading \"System status\" registers from" << hostAddress().toString() << errorString(); + } +} + +void StiebelEltronModbusConnection::updateSgReadyState() +{ + // Update registers from Smart grid status + qCDebug(dcStiebelEltronModbusConnection()) << "--> Read \"Smart grid status\" register:" << 5000 << "size:" << 1; + QModbusReply *reply = readSgReadyState(); + if (reply) { + if (!reply->isFinished()) { + connect(reply, &QModbusReply::finished, reply, &QModbusReply::deleteLater); + connect(reply, &QModbusReply::finished, this, [this, reply](){ + if (reply->error() == QModbusDevice::NoError) { + const QModbusDataUnit unit = reply->result(); + const QVector values = unit.values(); + qCDebug(dcStiebelEltronModbusConnection()) << "<-- Response from \"Smart grid status\" register" << 5000 << "size:" << 1 << values; + SmartGridState receivedSgReadyState = static_cast(ModbusDataUtils::convertToUInt16(values)); + if (m_sgReadyState != receivedSgReadyState) { + m_sgReadyState = receivedSgReadyState; + emit sgReadyStateChanged(m_sgReadyState); + } + } + }); + + connect(reply, &QModbusReply::errorOccurred, this, [this, reply] (QModbusDevice::Error error){ + qCWarning(dcStiebelEltronModbusConnection()) << "Modbus reply error occurred while updating \"Smart grid status\" registers from" << hostAddress().toString() << error << reply->errorString(); + emit reply->finished(); // To make sure it will be deleted + }); + } else { + delete reply; // Broadcast reply returns immediatly + } + } else { + qCWarning(dcStiebelEltronModbusConnection()) << "Error occurred while reading \"Smart grid status\" registers from" << hostAddress().toString() << errorString(); + } +} + +void StiebelEltronModbusConnection::updateSgReadyActive() +{ + // Update registers from SG ready active + qCDebug(dcStiebelEltronModbusConnection()) << "--> Read \"SG ready active\" register:" << 4000 << "size:" << 1; + QModbusReply *reply = readSgReadyActive(); + if (reply) { + if (!reply->isFinished()) { + connect(reply, &QModbusReply::finished, reply, &QModbusReply::deleteLater); + connect(reply, &QModbusReply::finished, this, [this, reply](){ + if (reply->error() == QModbusDevice::NoError) { + const QModbusDataUnit unit = reply->result(); + const QVector values = unit.values(); + qCDebug(dcStiebelEltronModbusConnection()) << "<-- Response from \"SG ready active\" register" << 4000 << "size:" << 1 << values; + quint16 receivedSgReadyActive = ModbusDataUtils::convertToUInt16(values); + if (m_sgReadyActive != receivedSgReadyActive) { + m_sgReadyActive = receivedSgReadyActive; + emit sgReadyActiveChanged(m_sgReadyActive); + } + } + }); + + connect(reply, &QModbusReply::errorOccurred, this, [this, reply] (QModbusDevice::Error error){ + qCWarning(dcStiebelEltronModbusConnection()) << "Modbus reply error occurred while updating \"SG ready active\" registers from" << hostAddress().toString() << error << reply->errorString(); + emit reply->finished(); // To make sure it will be deleted + }); + } else { + delete reply; // Broadcast reply returns immediatly + } + } else { + qCWarning(dcStiebelEltronModbusConnection()) << "Error occurred while reading \"SG ready active\" registers from" << hostAddress().toString() << errorString(); + } +} + +void StiebelEltronModbusConnection::updateSgReadyInputOne() +{ + // Update registers from SG Ready Input 1 + qCDebug(dcStiebelEltronModbusConnection()) << "--> Read \"SG Ready Input 1\" register:" << 4001 << "size:" << 1; + QModbusReply *reply = readSgReadyInputOne(); + if (reply) { + if (!reply->isFinished()) { + connect(reply, &QModbusReply::finished, reply, &QModbusReply::deleteLater); + connect(reply, &QModbusReply::finished, this, [this, reply](){ + if (reply->error() == QModbusDevice::NoError) { + const QModbusDataUnit unit = reply->result(); + const QVector values = unit.values(); + qCDebug(dcStiebelEltronModbusConnection()) << "<-- Response from \"SG Ready Input 1\" register" << 4001 << "size:" << 1 << values; + quint16 receivedSgReadyInputOne = ModbusDataUtils::convertToUInt16(values); + if (m_sgReadyInputOne != receivedSgReadyInputOne) { + m_sgReadyInputOne = receivedSgReadyInputOne; + emit sgReadyInputOneChanged(m_sgReadyInputOne); + } + } + }); + + connect(reply, &QModbusReply::errorOccurred, this, [this, reply] (QModbusDevice::Error error){ + qCWarning(dcStiebelEltronModbusConnection()) << "Modbus reply error occurred while updating \"SG Ready Input 1\" registers from" << hostAddress().toString() << error << reply->errorString(); + emit reply->finished(); // To make sure it will be deleted + }); + } else { + delete reply; // Broadcast reply returns immediatly + } + } else { + qCWarning(dcStiebelEltronModbusConnection()) << "Error occurred while reading \"SG Ready Input 1\" registers from" << hostAddress().toString() << errorString(); + } +} + +void StiebelEltronModbusConnection::updateSgReadyInputTwo() +{ + // Update registers from SG Read Input 2 + qCDebug(dcStiebelEltronModbusConnection()) << "--> Read \"SG Read Input 2\" register:" << 4002 << "size:" << 1; + QModbusReply *reply = readSgReadyInputTwo(); + if (reply) { + if (!reply->isFinished()) { + connect(reply, &QModbusReply::finished, reply, &QModbusReply::deleteLater); + connect(reply, &QModbusReply::finished, this, [this, reply](){ + if (reply->error() == QModbusDevice::NoError) { + const QModbusDataUnit unit = reply->result(); + const QVector values = unit.values(); + qCDebug(dcStiebelEltronModbusConnection()) << "<-- Response from \"SG Read Input 2\" register" << 4002 << "size:" << 1 << values; + quint16 receivedSgReadyInputTwo = ModbusDataUtils::convertToUInt16(values); + if (m_sgReadyInputTwo != receivedSgReadyInputTwo) { + m_sgReadyInputTwo = receivedSgReadyInputTwo; + emit sgReadyInputTwoChanged(m_sgReadyInputTwo); + } + } + }); + + connect(reply, &QModbusReply::errorOccurred, this, [this, reply] (QModbusDevice::Error error){ + qCWarning(dcStiebelEltronModbusConnection()) << "Modbus reply error occurred while updating \"SG Read Input 2\" registers from" << hostAddress().toString() << error << reply->errorString(); + emit reply->finished(); // To make sure it will be deleted + }); + } else { + delete reply; // Broadcast reply returns immediatly + } + } else { + qCWarning(dcStiebelEltronModbusConnection()) << "Error occurred while reading \"SG Read Input 2\" registers from" << hostAddress().toString() << errorString(); } } QModbusReply *StiebelEltronModbusConnection::readOutdoorTemperature() { - QModbusDataUnit request = QModbusDataUnit(QModbusDataUnit::RegisterType::InputRegisters, 507, 1); + QModbusDataUnit request = QModbusDataUnit(QModbusDataUnit::RegisterType::InputRegisters, 506, 1); + return sendReadRequest(request, m_slaveId); +} + +QModbusReply *StiebelEltronModbusConnection::readFlowTemperature() +{ + QModbusDataUnit request = QModbusDataUnit(QModbusDataUnit::RegisterType::InputRegisters, 514, 1); + return sendReadRequest(request, m_slaveId); +} + +QModbusReply *StiebelEltronModbusConnection::readHotWaterTemperature() +{ + QModbusDataUnit request = QModbusDataUnit(QModbusDataUnit::RegisterType::InputRegisters, 521, 1); + return sendReadRequest(request, m_slaveId); +} + +QModbusReply *StiebelEltronModbusConnection::readHotGasTemperature1() +{ + QModbusDataUnit request = QModbusDataUnit(QModbusDataUnit::RegisterType::InputRegisters, 543, 1); + return sendReadRequest(request, m_slaveId); +} + +QModbusReply *StiebelEltronModbusConnection::readHotGasTemperature2() +{ + QModbusDataUnit request = QModbusDataUnit(QModbusDataUnit::RegisterType::InputRegisters, 550, 1); + return sendReadRequest(request, m_slaveId); +} + +QModbusReply *StiebelEltronModbusConnection::readSourceTemperature() +{ + QModbusDataUnit request = QModbusDataUnit(QModbusDataUnit::RegisterType::InputRegisters, 562, 1); + return sendReadRequest(request, m_slaveId); +} + +QModbusReply *StiebelEltronModbusConnection::readRoomTemperatureFEK() +{ + QModbusDataUnit request = QModbusDataUnit(QModbusDataUnit::RegisterType::InputRegisters, 502, 1); + return sendReadRequest(request, m_slaveId); +} + +QModbusReply *StiebelEltronModbusConnection::readReturnTemperature() +{ + QModbusDataUnit request = QModbusDataUnit(QModbusDataUnit::RegisterType::InputRegisters, 515, 1); + return sendReadRequest(request, m_slaveId); +} + +QModbusReply *StiebelEltronModbusConnection::readSolarCollectorTemperature() +{ + QModbusDataUnit request = QModbusDataUnit(QModbusDataUnit::RegisterType::InputRegisters, 527, 1); + return sendReadRequest(request, m_slaveId); +} + +QModbusReply *StiebelEltronModbusConnection::readSolarStorageTankTemperature() +{ + QModbusDataUnit request = QModbusDataUnit(QModbusDataUnit::RegisterType::InputRegisters, 528, 1); + return sendReadRequest(request, m_slaveId); +} + +QModbusReply *StiebelEltronModbusConnection::readStorageTankTemperature() +{ + QModbusDataUnit request = QModbusDataUnit(QModbusDataUnit::RegisterType::InputRegisters, 517, 1); + return sendReadRequest(request, m_slaveId); +} + +QModbusReply *StiebelEltronModbusConnection::readExternalHeatSourceTemperature() +{ + QModbusDataUnit request = QModbusDataUnit(QModbusDataUnit::RegisterType::InputRegisters, 530, 1); + return sendReadRequest(request, m_slaveId); +} + +QModbusReply *StiebelEltronModbusConnection::readHeatingEnergy() +{ + QModbusDataUnit request = QModbusDataUnit(QModbusDataUnit::RegisterType::InputRegisters, 3501, 2); + return sendReadRequest(request, m_slaveId); +} + +QModbusReply *StiebelEltronModbusConnection::readHotWaterEnergy() +{ + QModbusDataUnit request = QModbusDataUnit(QModbusDataUnit::RegisterType::InputRegisters, 3504, 2); + return sendReadRequest(request, m_slaveId); +} + +QModbusReply *StiebelEltronModbusConnection::readConsumedEnergyHeating() +{ + QModbusDataUnit request = QModbusDataUnit(QModbusDataUnit::RegisterType::InputRegisters, 3511, 2); + return sendReadRequest(request, m_slaveId); +} + +QModbusReply *StiebelEltronModbusConnection::readConsumedEnergyHotWater() +{ + QModbusDataUnit request = QModbusDataUnit(QModbusDataUnit::RegisterType::InputRegisters, 3514, 2); + return sendReadRequest(request, m_slaveId); +} + +QModbusReply *StiebelEltronModbusConnection::readOperatingMode() +{ + QModbusDataUnit request = QModbusDataUnit(QModbusDataUnit::RegisterType::HoldingRegisters, 1500, 1); + return sendReadRequest(request, m_slaveId); +} + +QModbusReply *StiebelEltronModbusConnection::readSystemStatus() +{ + QModbusDataUnit request = QModbusDataUnit(QModbusDataUnit::RegisterType::InputRegisters, 2500, 1); + return sendReadRequest(request, m_slaveId); +} + +QModbusReply *StiebelEltronModbusConnection::readSgReadyState() +{ + QModbusDataUnit request = QModbusDataUnit(QModbusDataUnit::RegisterType::InputRegisters, 5000, 1); + return sendReadRequest(request, m_slaveId); +} + +QModbusReply *StiebelEltronModbusConnection::readSgReadyActive() +{ + QModbusDataUnit request = QModbusDataUnit(QModbusDataUnit::RegisterType::HoldingRegisters, 4000, 1); + return sendReadRequest(request, m_slaveId); +} + +QModbusReply *StiebelEltronModbusConnection::readSgReadyInputOne() +{ + QModbusDataUnit request = QModbusDataUnit(QModbusDataUnit::RegisterType::HoldingRegisters, 4001, 1); + return sendReadRequest(request, m_slaveId); +} + +QModbusReply *StiebelEltronModbusConnection::readSgReadyInputTwo() +{ + QModbusDataUnit request = QModbusDataUnit(QModbusDataUnit::RegisterType::HoldingRegisters, 4002, 1); return sendReadRequest(request, m_slaveId); } @@ -107,7 +1079,28 @@ void StiebelEltronModbusConnection::verifyInitFinished() QDebug operator<<(QDebug debug, StiebelEltronModbusConnection *stiebelEltronModbusConnection) { debug.nospace().noquote() << "StiebelEltronModbusConnection(" << stiebelEltronModbusConnection->hostAddress().toString() << ":" << stiebelEltronModbusConnection->port() << ")" << "\n"; - debug.nospace().noquote() << " - Flow:" << stiebelEltronModbusConnection->outdoorTemperature() << " [°C]" << "\n"; + debug.nospace().noquote() << " - Outdoor temperature:" << stiebelEltronModbusConnection->outdoorTemperature() << " [°C]" << "\n"; + debug.nospace().noquote() << " - Flow temperature:" << stiebelEltronModbusConnection->flowTemperature() << " [°C]" << "\n"; + debug.nospace().noquote() << " - Hot water temperature:" << stiebelEltronModbusConnection->hotWaterTemperature() << " [°C]" << "\n"; + debug.nospace().noquote() << " - Hot gas temperature HP 1:" << stiebelEltronModbusConnection->hotGasTemperature1() << " [°C]" << "\n"; + debug.nospace().noquote() << " - Hot gas temperature HP 2:" << stiebelEltronModbusConnection->hotGasTemperature2() << " [°C]" << "\n"; + debug.nospace().noquote() << " - Source temperature:" << stiebelEltronModbusConnection->SourceTemperature() << " [°C]" << "\n"; + debug.nospace().noquote() << " - Room temperature FEK:" << stiebelEltronModbusConnection->roomTemperatureFEK() << " [°C]" << "\n"; + debug.nospace().noquote() << " - Return temperature:" << stiebelEltronModbusConnection->returnTemperature() << " [°C]" << "\n"; + debug.nospace().noquote() << " - Solar collector temperature:" << stiebelEltronModbusConnection->solarCollectorTemperature() << " [°C]" << "\n"; + debug.nospace().noquote() << " - Solar storage tank temperature:" << stiebelEltronModbusConnection->solarStorageTankTemperature() << " [°C]" << "\n"; + debug.nospace().noquote() << " - Storage tank temperature:" << stiebelEltronModbusConnection->storageTankTemperature() << " [°C]" << "\n"; + debug.nospace().noquote() << " - External heat source temperature:" << stiebelEltronModbusConnection->externalHeatSourceTemperature() << " [°C]" << "\n"; + debug.nospace().noquote() << " - Heating energy:" << stiebelEltronModbusConnection->heatingEnergy() << " [kWh]" << "\n"; + debug.nospace().noquote() << " - Hot water energy:" << stiebelEltronModbusConnection->hotWaterEnergy() << " [kWh]" << "\n"; + debug.nospace().noquote() << " - Consumed energy heating:" << stiebelEltronModbusConnection->consumedEnergyHeating() << " [kWh]" << "\n"; + debug.nospace().noquote() << " - Consumed energy hot water:" << stiebelEltronModbusConnection->consumedEnergyHotWater() << " [kWh]" << "\n"; + debug.nospace().noquote() << " - Operating mode:" << stiebelEltronModbusConnection->operatingMode() << "\n"; + debug.nospace().noquote() << " - System status:" << stiebelEltronModbusConnection->systemStatus() << "\n"; + debug.nospace().noquote() << " - Smart grid status:" << stiebelEltronModbusConnection->sgReadyState() << "\n"; + debug.nospace().noquote() << " - SG ready active:" << stiebelEltronModbusConnection->sgReadyActive() << "\n"; + debug.nospace().noquote() << " - SG Ready Input 1:" << stiebelEltronModbusConnection->sgReadyInputOne() << "\n"; + debug.nospace().noquote() << " - SG Read Input 2:" << stiebelEltronModbusConnection->sgReadyInputTwo() << "\n"; return debug.quote().space(); } diff --git a/stiebeleltron/stiebeleltronmodbusconnection.h b/stiebeleltron/stiebeleltronmodbusconnection.h index 942beb6..d6a793e 100644 --- a/stiebeleltron/stiebeleltronmodbusconnection.h +++ b/stiebeleltron/stiebeleltronmodbusconnection.h @@ -41,30 +41,219 @@ class StiebelEltronModbusConnection : public ModbusTCPMaster Q_OBJECT public: enum Registers { - RegisterOutdoorTemperature = 507 + RegisterRoomTemperatureFEK = 502, + RegisterOutdoorTemperature = 506, + RegisterFlowTemperature = 514, + RegisterReturnTemperature = 515, + RegisterStorageTankTemperature = 517, + RegisterHotWaterTemperature = 521, + RegisterSolarCollectorTemperature = 527, + RegisterSolarStorageTankTemperature = 528, + RegisterExternalHeatSourceTemperature = 530, + RegisterHotGasTemperature1 = 543, + RegisterHotGasTemperature2 = 550, + RegisterSourceTemperature = 562, + RegisterOperatingMode = 1500, + RegisterSystemStatus = 2500, + RegisterHeatingEnergy = 3501, + RegisterHotWaterEnergy = 3504, + RegisterConsumedEnergyHeating = 3511, + RegisterConsumedEnergyHotWater = 3514, + RegisterSgReadyActive = 4000, + RegisterSgReadyInputOne = 4001, + RegisterSgReadyInputTwo = 4002, + RegisterSgReadyState = 5000 }; Q_ENUM(Registers) + enum OperatingMode { + OperatingModeEmergency = 0, + OperatingModeStandby = 1, + OperatingModeProgram = 2, + OperatingModeComfort = 3, + OperatingModeEco = 4, + OperatingModeHotWater = 5 + }; + Q_ENUM(OperatingMode) + + enum SmartGridState { + SmartGridStateModeOne = 1, + SmartGridStateModeTwo = 2, + SmartGridStateModeThree = 3, + SmartGridStateModeFour = 4 + }; + Q_ENUM(SmartGridState) + explicit StiebelEltronModbusConnection(const QHostAddress &hostAddress, uint port, quint16 slaveId, QObject *parent = nullptr); ~StiebelEltronModbusConnection() = default; - /* Flow [°C] - Address: 507, Size: 1 */ + /* Outdoor temperature [°C] - Address: 506, Size: 1 */ float outdoorTemperature() const; + /* Flow temperature [°C] - Address: 514, Size: 1 */ + float flowTemperature() const; + + /* Hot water temperature [°C] - Address: 521, Size: 1 */ + float hotWaterTemperature() const; + + /* Hot gas temperature HP 1 [°C] - Address: 543, Size: 1 */ + float hotGasTemperature1() const; + + /* Hot gas temperature HP 2 [°C] - Address: 550, Size: 1 */ + float hotGasTemperature2() const; + + /* Source temperature [°C] - Address: 562, Size: 1 */ + float SourceTemperature() const; + + /* Room temperature FEK [°C] - Address: 502, Size: 1 */ + float roomTemperatureFEK() const; + + /* Return temperature [°C] - Address: 515, Size: 1 */ + float returnTemperature() const; + + /* Solar collector temperature [°C] - Address: 527, Size: 1 */ + float solarCollectorTemperature() const; + + /* Solar storage tank temperature [°C] - Address: 528, Size: 1 */ + float solarStorageTankTemperature() const; + + /* Storage tank temperature [°C] - Address: 517, Size: 1 */ + float storageTankTemperature() const; + + /* External heat source temperature [°C] - Address: 530, Size: 1 */ + float externalHeatSourceTemperature() const; + + /* Heating energy [kWh] - Address: 3501, Size: 2 */ + quint32 heatingEnergy() const; + + /* Hot water energy [kWh] - Address: 3504, Size: 2 */ + quint32 hotWaterEnergy() const; + + /* Consumed energy heating [kWh] - Address: 3511, Size: 2 */ + quint32 consumedEnergyHeating() const; + + /* Consumed energy hot water [kWh] - Address: 3514, Size: 2 */ + quint32 consumedEnergyHotWater() const; + + /* Operating mode - Address: 1500, Size: 1 */ + OperatingMode operatingMode() const; + + /* System status - Address: 2500, Size: 1 */ + quint16 systemStatus() const; + + /* Smart grid status - Address: 5000, Size: 1 */ + SmartGridState sgReadyState() const; + + /* SG ready active - Address: 4000, Size: 1 */ + quint16 sgReadyActive() const; + QModbusReply *setSgReadyActive(quint16 sgReadyActive); + + /* SG Ready Input 1 - Address: 4001, Size: 1 */ + quint16 sgReadyInputOne() const; + QModbusReply *setSgReadyInputOne(quint16 sgReadyInputOne); + + /* SG Read Input 2 - Address: 4002, Size: 1 */ + quint16 sgReadyInputTwo() const; + QModbusReply *setSgReadyInputTwo(quint16 sgReadyInputTwo); + virtual void initialize(); virtual void update(); void updateOutdoorTemperature(); + void updateFlowTemperature(); + void updateHotWaterTemperature(); + void updateHotGasTemperature1(); + void updateHotGasTemperature2(); + void updateSourceTemperature(); + void updateRoomTemperatureFEK(); + void updateReturnTemperature(); + void updateSolarCollectorTemperature(); + void updateSolarStorageTankTemperature(); + void updateStorageTankTemperature(); + void updateExternalHeatSourceTemperature(); + void updateHeatingEnergy(); + void updateHotWaterEnergy(); + void updateConsumedEnergyHeating(); + void updateConsumedEnergyHotWater(); + void updateOperatingMode(); + void updateSystemStatus(); + void updateSgReadyState(); + void updateSgReadyActive(); + void updateSgReadyInputOne(); + void updateSgReadyInputTwo(); signals: void initializationFinished(); void outdoorTemperatureChanged(float outdoorTemperature); + void flowTemperatureChanged(float flowTemperature); + void hotWaterTemperatureChanged(float hotWaterTemperature); + void hotGasTemperature1Changed(float hotGasTemperature1); + void hotGasTemperature2Changed(float hotGasTemperature2); + void SourceTemperatureChanged(float SourceTemperature); + void roomTemperatureFEKChanged(float roomTemperatureFEK); + void returnTemperatureChanged(float returnTemperature); + void solarCollectorTemperatureChanged(float solarCollectorTemperature); + void solarStorageTankTemperatureChanged(float solarStorageTankTemperature); + void storageTankTemperatureChanged(float storageTankTemperature); + void externalHeatSourceTemperatureChanged(float externalHeatSourceTemperature); + void heatingEnergyChanged(quint32 heatingEnergy); + void hotWaterEnergyChanged(quint32 hotWaterEnergy); + void consumedEnergyHeatingChanged(quint32 consumedEnergyHeating); + void consumedEnergyHotWaterChanged(quint32 consumedEnergyHotWater); + void operatingModeChanged(OperatingMode operatingMode); + void systemStatusChanged(quint16 systemStatus); + void sgReadyStateChanged(SmartGridState sgReadyState); + void sgReadyActiveChanged(quint16 sgReadyActive); + void sgReadyInputOneChanged(quint16 sgReadyInputOne); + void sgReadyInputTwoChanged(quint16 sgReadyInputTwo); protected: QModbusReply *readOutdoorTemperature(); + QModbusReply *readFlowTemperature(); + QModbusReply *readHotWaterTemperature(); + QModbusReply *readHotGasTemperature1(); + QModbusReply *readHotGasTemperature2(); + QModbusReply *readSourceTemperature(); + QModbusReply *readRoomTemperatureFEK(); + QModbusReply *readReturnTemperature(); + QModbusReply *readSolarCollectorTemperature(); + QModbusReply *readSolarStorageTankTemperature(); + QModbusReply *readStorageTankTemperature(); + QModbusReply *readExternalHeatSourceTemperature(); + QModbusReply *readHeatingEnergy(); + QModbusReply *readHotWaterEnergy(); + QModbusReply *readConsumedEnergyHeating(); + QModbusReply *readConsumedEnergyHotWater(); + QModbusReply *readOperatingMode(); + QModbusReply *readSystemStatus(); + QModbusReply *readSgReadyState(); + QModbusReply *readSgReadyActive(); + QModbusReply *readSgReadyInputOne(); + QModbusReply *readSgReadyInputTwo(); float m_outdoorTemperature = 0; + float m_flowTemperature = 0; + float m_hotWaterTemperature = 0; + float m_hotGasTemperature1 = 0; + float m_hotGasTemperature2 = 0; + float m_SourceTemperature = 0; + float m_roomTemperatureFEK = 0; + float m_returnTemperature = 0; + float m_solarCollectorTemperature = 0; + float m_solarStorageTankTemperature = 0; + float m_storageTankTemperature = 0; + float m_externalHeatSourceTemperature = 0; + quint32 m_heatingEnergy = 0; + quint32 m_hotWaterEnergy = 0; + quint32 m_consumedEnergyHeating = 0; + quint32 m_consumedEnergyHotWater = 0; + OperatingMode m_operatingMode = OperatingModeStandby; + quint16 m_systemStatus = 0; + SmartGridState m_sgReadyState = SmartGridStateModeTwo; + quint16 m_sgReadyActive = 0; + quint16 m_sgReadyInputOne = 0; + quint16 m_sgReadyInputTwo = 0; private: quint16 m_slaveId = 1; @@ -72,6 +261,7 @@ private: void verifyInitFinished(); + }; QDebug operator<<(QDebug debug, StiebelEltronModbusConnection *stiebelEltronModbusConnection);