Filter by hostname and fix Readme

master
l.heizinger 2022-02-22 10:13:31 +01:00 committed by Simon Stürz
parent 5d3163911d
commit 3d3269b6e7
2 changed files with 79 additions and 101 deletions

View File

@ -12,7 +12,7 @@ Make sure the ISG firmware is up to date to ensure the Modbus/TCP connection is
## Requirements ## Requirements
* The package 'nymea-plugin-stiebeleltron' must be installed * The package `nymea-plugin-stiebeleltron` must be installed
* Both devices must be in the same local area network. * Both devices must be in the same local area network.
* Modbus enabled (may conflict with an installed SMA EMI). * Modbus enabled (may conflict with an installed SMA EMI).

View File

@ -1,6 +1,6 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* Copyright 2013 - 2021, nymea GmbH, Consolinno Energy GmbH, L. Heizinger * Copyright 2013 - 2021, nymea GmbH, Consolinno Energy GmbH, L. Heizinger
* Contact: contact@nymea.io * Contact: contact@nymea.io
* *
* This file is part of nymea. * This file is part of nymea.
@ -44,8 +44,7 @@ void IntegrationPluginStiebelEltron::discoverThings(ThingDiscoveryInfo *info) {
return; return;
} }
NetworkDeviceDiscoveryReply *discoveryReply = NetworkDeviceDiscoveryReply *discoveryReply = hardwareManager()->networkDeviceDiscovery()->discover();
hardwareManager()->networkDeviceDiscovery()->discover();
connect(discoveryReply, &NetworkDeviceDiscoveryReply::finished, this, [=]() { connect(discoveryReply, &NetworkDeviceDiscoveryReply::finished, this, [=]() {
foreach (const NetworkDeviceInfo &networkDeviceInfo, discoveryReply->networkDeviceInfos()) { foreach (const NetworkDeviceInfo &networkDeviceInfo, discoveryReply->networkDeviceInfos()) {
qCDebug(dcStiebelEltron()) << "Found" << networkDeviceInfo; qCDebug(dcStiebelEltron()) << "Found" << networkDeviceInfo;
@ -54,29 +53,27 @@ void IntegrationPluginStiebelEltron::discoverThings(ThingDiscoveryInfo *info) {
if (networkDeviceInfo.hostName().isEmpty()) { if (networkDeviceInfo.hostName().isEmpty()) {
title = networkDeviceInfo.address().toString(); title = networkDeviceInfo.address().toString();
} else { } else {
title = networkDeviceInfo.hostName() + " (" + if (!networkDeviceInfo.hostName().contains("StiebelEltronISG")) continue;
networkDeviceInfo.address().toString() + ")"; title = networkDeviceInfo.hostName() + " (" + networkDeviceInfo.address().toString() + ")";
} }
QString description; QString description;
if (networkDeviceInfo.macAddressManufacturer().isEmpty()) { if (networkDeviceInfo.macAddressManufacturer().isEmpty()) {
description = networkDeviceInfo.macAddress(); description = networkDeviceInfo.macAddress();
} else { } else {
description = networkDeviceInfo.macAddress() + " (" + description =
networkDeviceInfo.macAddressManufacturer() + ")"; networkDeviceInfo.macAddress() + " (" + networkDeviceInfo.macAddressManufacturer() + ")";
} }
ThingDescriptor descriptor(stiebelEltronThingClassId, title, description); ThingDescriptor descriptor(stiebelEltronThingClassId, title, description);
ParamList params; ParamList params;
params << Param(stiebelEltronThingIpAddressParamTypeId, params << Param(stiebelEltronThingIpAddressParamTypeId, networkDeviceInfo.address().toString());
networkDeviceInfo.address().toString()); params << Param(stiebelEltronThingMacAddressParamTypeId, networkDeviceInfo.macAddress());
params << Param(stiebelEltronThingMacAddressParamTypeId,
networkDeviceInfo.macAddress());
descriptor.setParams(params); descriptor.setParams(params);
// Check if we already have set up this device // Check if we already have set up this device
Things existingThings = myThings().filterByParam( Things existingThings = myThings().filterByParam(stiebelEltronThingMacAddressParamTypeId,
stiebelEltronThingMacAddressParamTypeId, networkDeviceInfo.macAddress()); networkDeviceInfo.macAddress());
if (existingThings.count() == 1) { if (existingThings.count() == 1) {
qCDebug(dcStiebelEltron()) qCDebug(dcStiebelEltron())
<< "This connection already exists in the system:" << networkDeviceInfo; << "This connection already exists in the system:" << networkDeviceInfo;
@ -106,8 +103,7 @@ void IntegrationPluginStiebelEltron::setupThing(ThingSetupInfo *info) {
connect(connection, &StiebelEltronModbusConnection::connectionStateChanged, this, connect(connection, &StiebelEltronModbusConnection::connectionStateChanged, this,
[thing, connection](bool status) { [thing, connection](bool status) {
qCDebug(dcStiebelEltron()) qCDebug(dcStiebelEltron()) << "Connected changed to" << status << "for" << thing;
<< "Connected changed to" << status << "for" << thing;
if (status) { if (status) {
connection->update(); connection->update();
} }
@ -119,8 +115,7 @@ void IntegrationPluginStiebelEltron::setupThing(ThingSetupInfo *info) {
[thing](float outdoorTemperature) { [thing](float outdoorTemperature) {
qCDebug(dcStiebelEltron()) qCDebug(dcStiebelEltron())
<< thing << "outdoor temperature changed" << outdoorTemperature << "°C"; << thing << "outdoor temperature changed" << outdoorTemperature << "°C";
thing->setStateValue(stiebelEltronOutdoorTemperatureStateTypeId, thing->setStateValue(stiebelEltronOutdoorTemperatureStateTypeId, outdoorTemperature);
outdoorTemperature);
}); });
connect(connection, &StiebelEltronModbusConnection::flowTemperatureChanged, this, connect(connection, &StiebelEltronModbusConnection::flowTemperatureChanged, this,
@ -134,14 +129,13 @@ void IntegrationPluginStiebelEltron::setupThing(ThingSetupInfo *info) {
[thing](float hotWaterTemperature) { [thing](float hotWaterTemperature) {
qCDebug(dcStiebelEltron()) qCDebug(dcStiebelEltron())
<< thing << "hot water temperature changed" << hotWaterTemperature << "°C"; << thing << "hot water temperature changed" << hotWaterTemperature << "°C";
thing->setStateValue(stiebelEltronHotWaterTemperatureStateTypeId, thing->setStateValue(stiebelEltronHotWaterTemperatureStateTypeId, hotWaterTemperature);
hotWaterTemperature);
}); });
connect(connection, &StiebelEltronModbusConnection::storageTankTemperatureChanged, this, connect(connection, &StiebelEltronModbusConnection::storageTankTemperatureChanged, this,
[thing](float storageTankTemperature) { [thing](float storageTankTemperature) {
qCDebug(dcStiebelEltron()) << thing << "Storage tank temperature changed" qCDebug(dcStiebelEltron())
<< storageTankTemperature << "°C"; << thing << "Storage tank temperature changed" << storageTankTemperature << "°C";
thing->setStateValue(stiebelEltronStorageTankTemperatureStateTypeId, thing->setStateValue(stiebelEltronStorageTankTemperatureStateTypeId,
storageTankTemperature); storageTankTemperature);
}); });
@ -150,8 +144,7 @@ void IntegrationPluginStiebelEltron::setupThing(ThingSetupInfo *info) {
[thing](float returnTemperature) { [thing](float returnTemperature) {
qCDebug(dcStiebelEltron()) qCDebug(dcStiebelEltron())
<< thing << "return temperature changed" << returnTemperature << "°C"; << thing << "return temperature changed" << returnTemperature << "°C";
thing->setStateValue(stiebelEltronReturnTemperatureStateTypeId, thing->setStateValue(stiebelEltronReturnTemperatureStateTypeId, returnTemperature);
returnTemperature);
}); });
connect(connection, &StiebelEltronModbusConnection::heatingEnergyChanged, this, connect(connection, &StiebelEltronModbusConnection::heatingEnergyChanged, this,
@ -159,8 +152,7 @@ void IntegrationPluginStiebelEltron::setupThing(ThingSetupInfo *info) {
// kWh and MWh of energy are stored in two registers an read as // kWh and MWh of energy are stored in two registers an read as
// an uint32. The following arithmetic splits the uint32 into // an uint32. The following arithmetic splits the uint32 into
// two uint16 and sums up the MWh and kWh values. // two uint16 and sums up the MWh and kWh values.
quint32 correctedEnergy = quint32 correctedEnergy = (heatingEnergy >> 16) + (heatingEnergy & 0xFFFF) * 1000;
(heatingEnergy >> 16) + (heatingEnergy & 0xFFFF) * 1000;
qCDebug(dcStiebelEltron()) qCDebug(dcStiebelEltron())
<< thing << "Heating energy changed" << correctedEnergy << "kWh"; << thing << "Heating energy changed" << correctedEnergy << "kWh";
thing->setStateValue(stiebelEltronHeatingEnergyStateTypeId, correctedEnergy); thing->setStateValue(stiebelEltronHeatingEnergyStateTypeId, correctedEnergy);
@ -169,8 +161,7 @@ void IntegrationPluginStiebelEltron::setupThing(ThingSetupInfo *info) {
connect(connection, &StiebelEltronModbusConnection::hotWaterEnergyChanged, this, connect(connection, &StiebelEltronModbusConnection::hotWaterEnergyChanged, this,
[thing](quint32 hotWaterEnergy) { [thing](quint32 hotWaterEnergy) {
// see comment in heatingEnergyChanged // see comment in heatingEnergyChanged
quint32 correctedEnergy = quint32 correctedEnergy = (hotWaterEnergy >> 16) + (hotWaterEnergy & 0xFFFF) * 1000;
(hotWaterEnergy >> 16) + (hotWaterEnergy & 0xFFFF) * 1000;
qCDebug(dcStiebelEltron()) qCDebug(dcStiebelEltron())
<< thing << "Hot Water energy changed" << correctedEnergy << "kWh"; << thing << "Hot Water energy changed" << correctedEnergy << "kWh";
thing->setStateValue(stiebelEltronHotWaterEnergyStateTypeId, correctedEnergy); thing->setStateValue(stiebelEltronHotWaterEnergyStateTypeId, correctedEnergy);
@ -179,73 +170,68 @@ void IntegrationPluginStiebelEltron::setupThing(ThingSetupInfo *info) {
connect(connection, &StiebelEltronModbusConnection::consumedEnergyHeatingChanged, this, connect(connection, &StiebelEltronModbusConnection::consumedEnergyHeatingChanged, this,
[thing](quint32 consumedEnergyHeatingEnergy) { [thing](quint32 consumedEnergyHeatingEnergy) {
// see comment in heatingEnergyChanged // see comment in heatingEnergyChanged
quint32 correctedEnergy = (consumedEnergyHeatingEnergy >> 16) + quint32 correctedEnergy =
(consumedEnergyHeatingEnergy & 0xFFFF) * 1000; (consumedEnergyHeatingEnergy >> 16) + (consumedEnergyHeatingEnergy & 0xFFFF) * 1000;
qCDebug(dcStiebelEltron()) qCDebug(dcStiebelEltron())
<< thing << "Consumed energy Heating changed" << correctedEnergy << "kWh"; << thing << "Consumed energy Heating changed" << correctedEnergy << "kWh";
thing->setStateValue(stiebelEltronConsumedEnergyHeatingStateTypeId, thing->setStateValue(stiebelEltronConsumedEnergyHeatingStateTypeId, correctedEnergy);
correctedEnergy);
}); });
connect(connection, &StiebelEltronModbusConnection::consumedEnergyHotWaterChanged, this, connect(connection, &StiebelEltronModbusConnection::consumedEnergyHotWaterChanged, this,
[thing](quint32 consumedEnergyHotWaterEnergy) { [thing](quint32 consumedEnergyHotWaterEnergy) {
// see comment in heatingEnergyChanged // see comment in heatingEnergyChanged
quint32 correctedEnergy = (consumedEnergyHotWaterEnergy >> 16) + quint32 correctedEnergy =
(consumedEnergyHotWaterEnergy & 0xFFFF) * 1000; (consumedEnergyHotWaterEnergy >> 16) + (consumedEnergyHotWaterEnergy & 0xFFFF) * 1000;
qCDebug(dcStiebelEltron()) qCDebug(dcStiebelEltron())
<< thing << "Consumed energy hot water changed" << correctedEnergy << "kWh"; << thing << "Consumed energy hot water changed" << correctedEnergy << "kWh";
thing->setStateValue(stiebelEltronConsumedEnergyHotWaterStateTypeId, thing->setStateValue(stiebelEltronConsumedEnergyHotWaterStateTypeId, correctedEnergy);
correctedEnergy);
}); });
connect( connect(connection, &StiebelEltronModbusConnection::operatingModeChanged, this,
connection, &StiebelEltronModbusConnection::operatingModeChanged, this, [thing](StiebelEltronModbusConnection::OperatingMode operatingMode) {
[thing](StiebelEltronModbusConnection::OperatingMode operatingMode) { qCDebug(dcStiebelEltron()) << thing << "operating mode changed " << operatingMode;
qCDebug(dcStiebelEltron()) << thing << "operating mode changed " << operatingMode; switch (operatingMode) {
switch (operatingMode) { case StiebelEltronModbusConnection::OperatingModeEmergency:
case StiebelEltronModbusConnection::OperatingModeEmergency: thing->setStateValue(stiebelEltronOperatingModeStateTypeId, "Emergency");
thing->setStateValue(stiebelEltronOperatingModeStateTypeId, "Emergency"); break;
break; case StiebelEltronModbusConnection::OperatingModeStandby:
case StiebelEltronModbusConnection::OperatingModeStandby: thing->setStateValue(stiebelEltronOperatingModeStateTypeId, "Standby");
thing->setStateValue(stiebelEltronOperatingModeStateTypeId, "Standby"); break;
break; case StiebelEltronModbusConnection::OperatingModeProgram:
case StiebelEltronModbusConnection::OperatingModeProgram: thing->setStateValue(stiebelEltronOperatingModeStateTypeId, "Program");
thing->setStateValue(stiebelEltronOperatingModeStateTypeId, "Program"); break;
break; case StiebelEltronModbusConnection::OperatingModeComfort:
case StiebelEltronModbusConnection::OperatingModeComfort: thing->setStateValue(stiebelEltronOperatingModeStateTypeId, "Comfort");
thing->setStateValue(stiebelEltronOperatingModeStateTypeId, "Comfort"); break;
break; case StiebelEltronModbusConnection::OperatingModeEco:
case StiebelEltronModbusConnection::OperatingModeEco: thing->setStateValue(stiebelEltronOperatingModeStateTypeId, "Eco");
thing->setStateValue(stiebelEltronOperatingModeStateTypeId, "Eco"); break;
break; case StiebelEltronModbusConnection::OperatingModeHotWater:
case StiebelEltronModbusConnection::OperatingModeHotWater: thing->setStateValue(stiebelEltronOperatingModeStateTypeId, "Hot water");
thing->setStateValue(stiebelEltronOperatingModeStateTypeId, "Hot water"); break;
break; }
} });
});
connect( connect(connection, &StiebelEltronModbusConnection::systemStatusChanged, this,
connection, &StiebelEltronModbusConnection::systemStatusChanged, this, [thing](uint16_t systemStatus) {
[thing](uint16_t systemStatus) { qCDebug(dcStiebelEltron()) << thing << "System status changed " << systemStatus;
qCDebug(dcStiebelEltron()) << thing << "System status changed " << systemStatus; thing->setStateValue(stiebelEltronPumpOneStateTypeId, systemStatus & (1 << 0));
thing->setStateValue(stiebelEltronPumpOneStateTypeId, systemStatus & (1 << 0)); thing->setStateValue(stiebelEltronPumpTwoStateTypeId, systemStatus & (1 << 1));
thing->setStateValue(stiebelEltronPumpTwoStateTypeId, systemStatus & (1 << 1)); thing->setStateValue(stiebelEltronHeatingUpStateTypeId, systemStatus & (1 << 2));
thing->setStateValue(stiebelEltronHeatingUpStateTypeId, systemStatus & (1 << 2)); thing->setStateValue(stiebelEltronAuxHeatingStateTypeId, systemStatus & (1 << 3));
thing->setStateValue(stiebelEltronAuxHeatingStateTypeId, systemStatus & (1 << 3)); thing->setStateValue(stiebelEltronHeatingStateTypeId, systemStatus & (1 << 4));
thing->setStateValue(stiebelEltronHeatingStateTypeId, systemStatus & (1 << 4)); thing->setStateValue(stiebelEltronHotWaterStateTypeId, systemStatus & (1 << 5));
thing->setStateValue(stiebelEltronHotWaterStateTypeId, systemStatus & (1 << 5)); thing->setStateValue(stiebelEltronCompressorStateTypeId, systemStatus & (1 << 6));
thing->setStateValue(stiebelEltronCompressorStateTypeId, systemStatus & (1 << 6)); thing->setStateValue(stiebelEltronSummerModeStateTypeId, systemStatus & (1 << 7));
thing->setStateValue(stiebelEltronSummerModeStateTypeId, systemStatus & (1 << 7)); thing->setStateValue(stiebelEltronCoolingModeStateTypeId, systemStatus & (1 << 8));
thing->setStateValue(stiebelEltronCoolingModeStateTypeId, systemStatus & (1 << 8)); thing->setStateValue(stiebelEltronDefrostingStateTypeId, systemStatus & (1 << 9));
thing->setStateValue(stiebelEltronDefrostingStateTypeId, systemStatus & (1 << 9)); thing->setStateValue(stiebelEltronSilentModeStateTypeId, systemStatus & (1 << 10));
thing->setStateValue(stiebelEltronSilentModeStateTypeId, systemStatus & (1 << 10)); thing->setStateValue(stiebelEltronSilentMode2StateTypeId, systemStatus & (1 << 11));
thing->setStateValue(stiebelEltronSilentMode2StateTypeId, systemStatus & (1 << 11)); });
});
connect(connection, &StiebelEltronModbusConnection::sgReadyStateChanged, this, connect(connection, &StiebelEltronModbusConnection::sgReadyStateChanged, this,
[thing](StiebelEltronModbusConnection::SmartGridState smartGridState) { [thing](StiebelEltronModbusConnection::SmartGridState smartGridState) {
qCDebug(dcStiebelEltron()) qCDebug(dcStiebelEltron()) << thing << "SG Ready activation changed" << smartGridState;
<< thing << "SG Ready activation changed" << smartGridState;
switch (smartGridState) { switch (smartGridState) {
case StiebelEltronModbusConnection::SmartGridStateModeOne: case StiebelEltronModbusConnection::SmartGridStateModeOne:
thing->setStateValue(stiebelEltronSgReadyModeStateTypeId, "Mode 1"); thing->setStateValue(stiebelEltronSgReadyModeStateTypeId, "Mode 1");
@ -263,8 +249,7 @@ void IntegrationPluginStiebelEltron::setupThing(ThingSetupInfo *info) {
}); });
connect(connection, &StiebelEltronModbusConnection::sgReadyActiveChanged, this, connect(connection, &StiebelEltronModbusConnection::sgReadyActiveChanged, this,
[thing](bool smartGridActive) { [thing](bool smartGridActive) {
qCDebug(dcStiebelEltron()) qCDebug(dcStiebelEltron()) << thing << "SG Ready activation changed" << smartGridActive;
<< thing << "SG Ready activation changed" << smartGridActive;
thing->setStateValue(stiebelEltronSgReadyActiveStateTypeId, smartGridActive); thing->setStateValue(stiebelEltronSgReadyActiveStateTypeId, smartGridActive);
}); });
@ -309,9 +294,8 @@ void IntegrationPluginStiebelEltron::executeAction(ThingActionInfo *info) {
StiebelEltronModbusConnection *connection = m_connections.value(thing); StiebelEltronModbusConnection *connection = m_connections.value(thing);
if (!connection->connected()) { if (!connection->connected()) {
qCWarning(dcStiebelEltron()) qCWarning(dcStiebelEltron()) << "Could not execute action. The modbus connection is currently "
<< "Could not execute action. The modbus connection is currently " "not available.";
"not available.";
info->finish(Thing::ThingErrorHardwareNotAvailable); info->finish(Thing::ThingErrorHardwareNotAvailable);
return; return;
} }
@ -323,9 +307,7 @@ void IntegrationPluginStiebelEltron::executeAction(ThingActionInfo *info) {
if (info->action().actionTypeId() == stiebelEltronSgReadyActiveActionTypeId) { if (info->action().actionTypeId() == stiebelEltronSgReadyActiveActionTypeId) {
bool sgReadyActiveBool = bool sgReadyActiveBool =
info->action() info->action().paramValue(stiebelEltronSgReadyActiveActionSgReadyActiveParamTypeId).toBool();
.paramValue(stiebelEltronSgReadyActiveActionSgReadyActiveParamTypeId)
.toBool();
qCDebug(dcStiebelEltron()) << "Execute action" << info->action().actionTypeId().toString() qCDebug(dcStiebelEltron()) << "Execute action" << info->action().actionTypeId().toString()
<< info->action().params(); << info->action().params();
qCDebug(dcStiebelEltron()) << "Value: " << sgReadyActiveBool; qCDebug(dcStiebelEltron()) << "Value: " << sgReadyActiveBool;
@ -347,23 +329,20 @@ void IntegrationPluginStiebelEltron::executeAction(ThingActionInfo *info) {
return; return;
} }
qCDebug(dcStiebelEltron()) qCDebug(dcStiebelEltron()) << "Execute action finished successfully"
<< "Execute action finished successfully" << info->action().actionTypeId().toString() << info->action().params();
<< info->action().actionTypeId().toString() << info->action().params();
info->thing()->setStateValue(stiebelEltronSgReadyActiveStateTypeId, sgReadyActiveBool); info->thing()->setStateValue(stiebelEltronSgReadyActiveStateTypeId, sgReadyActiveBool);
info->finish(Thing::ThingErrorNoError); info->finish(Thing::ThingErrorNoError);
}); });
connect(reply, &QModbusReply::errorOccurred, this, [reply](QModbusDevice::Error error) { connect(reply, &QModbusReply::errorOccurred, this, [reply](QModbusDevice::Error error) {
qCWarning(dcStiebelEltron()) << "Modbus reply error occurred while execute action" qCWarning(dcStiebelEltron())
<< error << reply->errorString(); << "Modbus reply error occurred while execute action" << error << reply->errorString();
emit reply->finished(); // To make sure it will be deleted emit reply->finished(); // To make sure it will be deleted
}); });
} else if (info->action().actionTypeId() == stiebelEltronSgReadyModeActionTypeId) { } else if (info->action().actionTypeId() == stiebelEltronSgReadyModeActionTypeId) {
QString sgReadyModeString = QString sgReadyModeString =
info->action() info->action().paramValue(stiebelEltronSgReadyModeActionSgReadyModeParamTypeId).toString();
.paramValue(stiebelEltronSgReadyModeActionSgReadyModeParamTypeId)
.toString();
qCDebug(dcStiebelEltron()) << "Execute action" << info->action().actionTypeId().toString() qCDebug(dcStiebelEltron()) << "Execute action" << info->action().actionTypeId().toString()
<< info->action().params(); << info->action().params();
StiebelEltronModbusConnection::SmartGridState sgReadyState; StiebelEltronModbusConnection::SmartGridState sgReadyState;
@ -394,16 +373,15 @@ void IntegrationPluginStiebelEltron::executeAction(ThingActionInfo *info) {
return; return;
} }
qCDebug(dcStiebelEltron()) qCDebug(dcStiebelEltron()) << "Execute action finished successfully"
<< "Execute action finished successfully" << info->action().actionTypeId().toString() << info->action().params();
<< info->action().actionTypeId().toString() << info->action().params();
info->thing()->setStateValue(stiebelEltronSgReadyModeStateTypeId, sgReadyModeString); info->thing()->setStateValue(stiebelEltronSgReadyModeStateTypeId, sgReadyModeString);
info->finish(Thing::ThingErrorNoError); info->finish(Thing::ThingErrorNoError);
}); });
connect(reply, &QModbusReply::errorOccurred, this, [reply](QModbusDevice::Error error) { connect(reply, &QModbusReply::errorOccurred, this, [reply](QModbusDevice::Error error) {
qCWarning(dcStiebelEltron()) << "Modbus reply error occurred while execute action" qCWarning(dcStiebelEltron())
<< error << reply->errorString(); << "Modbus reply error occurred while execute action" << error << reply->errorString();
emit reply->finished(); // To make sure it will be deleted emit reply->finished(); // To make sure it will be deleted
}); });
} }