Fix set version string for sunspec devices
parent
c49fd728dc
commit
0abc756a3d
|
|
@ -89,15 +89,6 @@ void IntegrationPluginSunSpec::init()
|
|||
m_connectedStateTypeIds.insert(sunspecSplitPhaseMeterThingClassId, sunspecSplitPhaseMeterConnectedStateTypeId);
|
||||
m_connectedStateTypeIds.insert(sunspecThreePhaseMeterThingClassId, sunspecThreePhaseMeterConnectedStateTypeId);
|
||||
|
||||
// Version states for all sunspec things
|
||||
m_versionStateTypeIds.insert(solarEdgeBatteryThingClassId, solarEdgeBatteryVersionStateTypeId);
|
||||
m_versionStateTypeIds.insert(sunspecSinglePhaseInverterThingClassId, sunspecSinglePhaseInverterVersionStateTypeId);
|
||||
m_versionStateTypeIds.insert(sunspecThreePhaseInverterThingClassId, sunspecThreePhaseInverterVersionStateTypeId);
|
||||
m_versionStateTypeIds.insert(sunspecStorageThingClassId, sunspecStorageVersionStateTypeId);
|
||||
m_versionStateTypeIds.insert(sunspecSinglePhaseMeterThingClassId, sunspecSinglePhaseMeterVersionStateTypeId);
|
||||
m_versionStateTypeIds.insert(sunspecSplitPhaseMeterThingClassId, sunspecSplitPhaseMeterVersionStateTypeId);
|
||||
m_versionStateTypeIds.insert(sunspecThreePhaseMeterThingClassId, sunspecThreePhaseMeterVersionStateTypeId);
|
||||
|
||||
// Params for sunspec things
|
||||
m_modelIdParamTypeIds.insert(sunspecSinglePhaseInverterThingClassId, sunspecSinglePhaseInverterThingModelIdParamTypeId);
|
||||
m_modelIdParamTypeIds.insert(sunspecSplitPhaseInverterThingClassId, sunspecSplitPhaseInverterThingModelIdParamTypeId);
|
||||
|
|
@ -287,9 +278,6 @@ void IntegrationPluginSunSpec::postSetupThing(Thing *thing)
|
|||
} else if (m_sunspecThings.contains(thing)) {
|
||||
SunSpecThing *sunSpecThing = m_sunspecThings.value(thing);
|
||||
sunSpecThing->readBlockData();
|
||||
|
||||
// Update the version state
|
||||
thing->setStateValue(m_versionStateTypeIds.value(thing->thingClassId()), sunSpecThing->model()->commonModelInfo().versionString);
|
||||
} else {
|
||||
Q_ASSERT_X(false, "postSetupThing", QString("Unhandled thingClassId: %1").arg(thing->thingClassId().toString()).toUtf8());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,9 +69,6 @@ private:
|
|||
QHash<ThingClassId, ParamTypeId> m_connectionMacAddressParamTypeIds;
|
||||
QHash<ThingClassId, ParamTypeId> m_connectionSlaveIdParamTypeIds;
|
||||
|
||||
// SunSpec thing common state map
|
||||
QHash<ThingClassId, StateTypeId> m_versionStateTypeIds;
|
||||
|
||||
// SunSpec thing params map
|
||||
QHash<ThingClassId, ParamTypeId> m_modelIdParamTypeIds;
|
||||
QHash<ThingClassId, ParamTypeId> m_modbusAddressParamTypeIds;
|
||||
|
|
|
|||
|
|
@ -56,74 +56,68 @@ void SunSpecInverter::onBlockDataUpdated()
|
|||
SunSpecInverterSinglePhaseModel *inverter = qobject_cast<SunSpecInverterSinglePhaseModel *>(m_model);
|
||||
qCDebug(dcSunSpec()) << m_thing->name() << "block data updated" << inverter;
|
||||
m_thing->setStateValue(sunspecSinglePhaseInverterConnectedStateTypeId, true);
|
||||
m_thing->setStateValue(sunspecSinglePhaseInverterVersionStateTypeId, m_model->commonModelInfo().versionString);
|
||||
|
||||
m_thing->setStateValue(sunspecSinglePhaseInverterTotalCurrentStateTypeId, inverter->amps());
|
||||
m_thing->setStateValue(sunspecSinglePhaseInverterCurrentPowerStateTypeId, inverter->watts());
|
||||
m_thing->setStateValue(sunspecSinglePhaseInverterTotalEnergyProducedStateTypeId, inverter->wattHours() / 1000.0);
|
||||
m_thing->setStateValue(sunspecSinglePhaseInverterFrequencyStateTypeId, inverter->hz());
|
||||
m_thing->setStateValue(sunspecSinglePhaseInverterCabinetTemperatureStateTypeId, inverter->cabinetTemperature());
|
||||
|
||||
m_thing->setStateValue(sunspecSinglePhaseInverterPhaseVoltageStateTypeId, inverter->phaseVoltageAn());
|
||||
|
||||
m_thing->setStateValue(sunspecSinglePhaseInverterOperatingStateStateTypeId, getStateString(inverter->operatingState()));
|
||||
m_thing->setStateValue(sunspecSinglePhaseInverterErrorStateTypeId, getErrorString(inverter->event1()));
|
||||
|
||||
break;
|
||||
}
|
||||
case SunSpecModelFactory::ModelIdInverterSinglePhaseFloat: {
|
||||
SunSpecInverterSinglePhaseFloatModel *inverter = qobject_cast<SunSpecInverterSinglePhaseFloatModel *>(m_model);
|
||||
qCDebug(dcSunSpec()) << m_thing->name() << "block data updated" << inverter;
|
||||
m_thing->setStateValue(sunspecSinglePhaseInverterConnectedStateTypeId, true);
|
||||
m_thing->setStateValue(sunspecSinglePhaseInverterVersionStateTypeId, m_model->commonModelInfo().versionString);
|
||||
|
||||
m_thing->setStateValue(sunspecSinglePhaseInverterTotalCurrentStateTypeId, inverter->amps());
|
||||
m_thing->setStateValue(sunspecSinglePhaseInverterCurrentPowerStateTypeId, inverter->watts());
|
||||
m_thing->setStateValue(sunspecSinglePhaseInverterTotalEnergyProducedStateTypeId, inverter->wattHours() / 1000.0);
|
||||
m_thing->setStateValue(sunspecSinglePhaseInverterFrequencyStateTypeId, inverter->hz());
|
||||
m_thing->setStateValue(sunspecSinglePhaseInverterCabinetTemperatureStateTypeId, inverter->cabinetTemperature());
|
||||
|
||||
m_thing->setStateValue(sunspecSinglePhaseInverterPhaseVoltageStateTypeId, inverter->phaseVoltageAn());
|
||||
|
||||
m_thing->setStateValue(sunspecSinglePhaseInverterOperatingStateStateTypeId, getStateString(inverter->operatingState()));
|
||||
|
||||
m_thing->setStateValue(sunspecSinglePhaseInverterErrorStateTypeId, getErrorString(inverter->event1()));
|
||||
|
||||
break;
|
||||
}
|
||||
case SunSpecModelFactory::ModelIdInverterSplitPhase: {
|
||||
SunSpecInverterSplitPhaseModel *inverter = qobject_cast<SunSpecInverterSplitPhaseModel *>(m_model);
|
||||
qCDebug(dcSunSpec()) << m_thing->name() << "block data updated" << inverter;
|
||||
m_thing->setStateValue(sunspecSplitPhaseInverterConnectedStateTypeId, true);
|
||||
m_thing->setStateValue(sunspecSplitPhaseInverterVersionStateTypeId, m_model->commonModelInfo().versionString);
|
||||
|
||||
m_thing->setStateValue(sunspecSplitPhaseInverterTotalCurrentStateTypeId, inverter->amps());
|
||||
m_thing->setStateValue(sunspecSplitPhaseInverterCurrentPowerStateTypeId, inverter->watts());
|
||||
m_thing->setStateValue(sunspecSplitPhaseInverterTotalEnergyProducedStateTypeId, inverter->wattHours() / 1000.0);
|
||||
m_thing->setStateValue(sunspecSplitPhaseInverterFrequencyStateTypeId, inverter->hz());
|
||||
m_thing->setStateValue(sunspecSplitPhaseInverterCabinetTemperatureStateTypeId, inverter->cabinetTemperature());
|
||||
|
||||
m_thing->setStateValue(sunspecSplitPhaseInverterPhaseANVoltageStateTypeId, inverter->phaseVoltageAn());
|
||||
m_thing->setStateValue(sunspecSplitPhaseInverterPhaseBNVoltageStateTypeId, inverter->phaseVoltageBn());
|
||||
|
||||
m_thing->setStateValue(sunspecSplitPhaseInverterPhaseACurrentStateTypeId, inverter->ampsPhaseA());
|
||||
m_thing->setStateValue(sunspecSplitPhaseInverterPhaseBCurrentStateTypeId, inverter->ampsPhaseB());
|
||||
|
||||
m_thing->setStateValue(sunspecSplitPhaseInverterOperatingStateStateTypeId, getStateString(inverter->operatingState()));
|
||||
m_thing->setStateValue(sunspecSplitPhaseInverterErrorStateTypeId, getErrorString(inverter->event1()));
|
||||
|
||||
break;
|
||||
}
|
||||
case SunSpecModelFactory::ModelIdInverterSplitPhaseFloat: {
|
||||
SunSpecInverterSplitPhaseFloatModel *inverter = qobject_cast<SunSpecInverterSplitPhaseFloatModel *>(m_model);
|
||||
qCDebug(dcSunSpec()) << m_thing->name() << "block data updated" << inverter;
|
||||
m_thing->setStateValue(sunspecSplitPhaseInverterConnectedStateTypeId, true);
|
||||
m_thing->setStateValue(sunspecSplitPhaseInverterVersionStateTypeId, m_model->commonModelInfo().versionString);
|
||||
|
||||
m_thing->setStateValue(sunspecSplitPhaseInverterTotalCurrentStateTypeId, inverter->amps());
|
||||
m_thing->setStateValue(sunspecSplitPhaseInverterCurrentPowerStateTypeId, inverter->watts());
|
||||
m_thing->setStateValue(sunspecSplitPhaseInverterTotalEnergyProducedStateTypeId, inverter->wattHours() / 1000.0);
|
||||
m_thing->setStateValue(sunspecSplitPhaseInverterFrequencyStateTypeId, inverter->hz());
|
||||
m_thing->setStateValue(sunspecSplitPhaseInverterCabinetTemperatureStateTypeId, inverter->cabinetTemperature());
|
||||
|
||||
m_thing->setStateValue(sunspecSplitPhaseInverterPhaseANVoltageStateTypeId, inverter->phaseVoltageAn());
|
||||
m_thing->setStateValue(sunspecSplitPhaseInverterPhaseBNVoltageStateTypeId, inverter->phaseVoltageBn());
|
||||
|
||||
m_thing->setStateValue(sunspecSplitPhaseInverterPhaseACurrentStateTypeId, inverter->ampsPhaseA());
|
||||
m_thing->setStateValue(sunspecSplitPhaseInverterPhaseBCurrentStateTypeId, inverter->ampsPhaseB());
|
||||
|
||||
m_thing->setStateValue(sunspecSplitPhaseInverterOperatingStateStateTypeId, getStateString(inverter->operatingState()));
|
||||
m_thing->setStateValue(sunspecSplitPhaseInverterErrorStateTypeId, getErrorString(inverter->event1()));
|
||||
break;
|
||||
|
|
@ -132,20 +126,19 @@ void SunSpecInverter::onBlockDataUpdated()
|
|||
SunSpecInverterThreePhaseModel *inverter = qobject_cast<SunSpecInverterThreePhaseModel *>(m_model);
|
||||
qCDebug(dcSunSpec()) << m_thing->name() << "block data updated" << inverter;
|
||||
m_thing->setStateValue(sunspecThreePhaseInverterConnectedStateTypeId, true);
|
||||
m_thing->setStateValue(sunspecThreePhaseInverterVersionStateTypeId, m_model->commonModelInfo().versionString);
|
||||
|
||||
m_thing->setStateValue(sunspecThreePhaseInverterTotalCurrentStateTypeId, inverter->amps());
|
||||
m_thing->setStateValue(sunspecThreePhaseInverterCurrentPowerStateTypeId, inverter->watts());
|
||||
m_thing->setStateValue(sunspecThreePhaseInverterTotalEnergyProducedStateTypeId, inverter->wattHours() / 1000.0);
|
||||
m_thing->setStateValue(sunspecThreePhaseInverterFrequencyStateTypeId, inverter->hz());
|
||||
m_thing->setStateValue(sunspecThreePhaseInverterCabinetTemperatureStateTypeId, inverter->cabinetTemperature());
|
||||
|
||||
m_thing->setStateValue(sunspecThreePhaseInverterPhaseANVoltageStateTypeId, inverter->phaseVoltageAn());
|
||||
m_thing->setStateValue(sunspecThreePhaseInverterPhaseBNVoltageStateTypeId, inverter->phaseVoltageBn());
|
||||
m_thing->setStateValue(sunspecThreePhaseInverterPhaseCNVoltageStateTypeId, inverter->phaseVoltageCn());
|
||||
|
||||
m_thing->setStateValue(sunspecThreePhaseInverterPhaseACurrentStateTypeId, inverter->ampsPhaseA());
|
||||
m_thing->setStateValue(sunspecThreePhaseInverterPhaseBCurrentStateTypeId, inverter->ampsPhaseB());
|
||||
m_thing->setStateValue(sunspecThreePhaseInverterPhaseCCurrentStateTypeId, inverter->ampsPhaseC());
|
||||
|
||||
m_thing->setStateValue(sunspecThreePhaseInverterOperatingStateStateTypeId, getStateString(inverter->operatingState()));
|
||||
m_thing->setStateValue(sunspecThreePhaseInverterErrorStateTypeId, getErrorString(inverter->event1()));
|
||||
break;
|
||||
|
|
@ -154,20 +147,19 @@ void SunSpecInverter::onBlockDataUpdated()
|
|||
SunSpecInverterThreePhaseFloatModel *inverter = qobject_cast<SunSpecInverterThreePhaseFloatModel *>(m_model);
|
||||
qCDebug(dcSunSpec()) << m_thing->name() << "block data updated" << inverter;
|
||||
m_thing->setStateValue(sunspecThreePhaseInverterConnectedStateTypeId, true);
|
||||
m_thing->setStateValue(sunspecThreePhaseInverterVersionStateTypeId, m_model->commonModelInfo().versionString);
|
||||
|
||||
m_thing->setStateValue(sunspecThreePhaseInverterTotalCurrentStateTypeId, inverter->amps());
|
||||
m_thing->setStateValue(sunspecThreePhaseInverterCurrentPowerStateTypeId, inverter->watts());
|
||||
m_thing->setStateValue(sunspecThreePhaseInverterTotalEnergyProducedStateTypeId, inverter->wattHours() / 1000.0);
|
||||
m_thing->setStateValue(sunspecThreePhaseInverterFrequencyStateTypeId, inverter->hz());
|
||||
m_thing->setStateValue(sunspecThreePhaseInverterCabinetTemperatureStateTypeId, inverter->cabinetTemperature());
|
||||
|
||||
m_thing->setStateValue(sunspecThreePhaseInverterPhaseANVoltageStateTypeId, inverter->phaseVoltageAn());
|
||||
m_thing->setStateValue(sunspecThreePhaseInverterPhaseBNVoltageStateTypeId, inverter->phaseVoltageBn());
|
||||
m_thing->setStateValue(sunspecThreePhaseInverterPhaseCNVoltageStateTypeId, inverter->phaseVoltageCn());
|
||||
|
||||
m_thing->setStateValue(sunspecThreePhaseInverterPhaseACurrentStateTypeId, inverter->ampsPhaseA());
|
||||
m_thing->setStateValue(sunspecThreePhaseInverterPhaseBCurrentStateTypeId, inverter->ampsPhaseB());
|
||||
m_thing->setStateValue(sunspecThreePhaseInverterPhaseCCurrentStateTypeId, inverter->ampsPhaseC());
|
||||
|
||||
m_thing->setStateValue(sunspecThreePhaseInverterOperatingStateStateTypeId, getStateString(inverter->operatingState()));
|
||||
m_thing->setStateValue(sunspecThreePhaseInverterErrorStateTypeId, getErrorString(inverter->event1()));
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -73,6 +73,8 @@ void SunSpecMeter::onBlockDataUpdated()
|
|||
SunSpecMeterSinglePhaseFloatModel *meter = qobject_cast<SunSpecMeterSinglePhaseFloatModel *>(m_model);
|
||||
qCDebug(dcSunSpec()) << m_thing->name() << "block data updated" << meter;
|
||||
m_thing->setStateValue(sunspecSinglePhaseMeterConnectedStateTypeId, true);
|
||||
m_thing->setStateValue(sunspecSinglePhaseMeterVersionStateTypeId, m_model->commonModelInfo().versionString);
|
||||
|
||||
m_thing->setStateValue(sunspecSinglePhaseMeterPhaseACurrentStateTypeId, meter->ampsPhaseA());
|
||||
m_thing->setStateValue(sunspecSinglePhaseMeterLnACVoltageStateTypeId, meter->voltageLn());
|
||||
m_thing->setStateValue(sunspecSinglePhaseMeterPhaseANVoltageStateTypeId, meter->phaseVoltageAn());
|
||||
|
|
@ -86,6 +88,8 @@ void SunSpecMeter::onBlockDataUpdated()
|
|||
SunSpecMeterSplitSinglePhaseAbnModel *meter = qobject_cast<SunSpecMeterSplitSinglePhaseAbnModel *>(m_model);
|
||||
qCDebug(dcSunSpec()) << m_thing->name() << "block data updated" << meter;
|
||||
m_thing->setStateValue(sunspecSplitPhaseMeterConnectedStateTypeId, true);
|
||||
m_thing->setStateValue(sunspecSplitPhaseMeterVersionStateTypeId, m_model->commonModelInfo().versionString);
|
||||
|
||||
m_thing->setStateValue(sunspecSplitPhaseMeterTotalCurrentStateTypeId, meter->amps());
|
||||
m_thing->setStateValue(sunspecSplitPhaseMeterPhaseACurrentStateTypeId, meter->ampsPhaseA());
|
||||
m_thing->setStateValue(sunspecSplitPhaseMeterPhaseBCurrentStateTypeId, meter->ampsPhaseB());
|
||||
|
|
@ -102,6 +106,8 @@ void SunSpecMeter::onBlockDataUpdated()
|
|||
SunSpecMeterSplitSinglePhaseFloatModel *meter = qobject_cast<SunSpecMeterSplitSinglePhaseFloatModel *>(m_model);
|
||||
qCDebug(dcSunSpec()) << m_thing->name() << "block data updated" << meter;
|
||||
m_thing->setStateValue(sunspecSplitPhaseMeterConnectedStateTypeId, true);
|
||||
m_thing->setStateValue(sunspecSplitPhaseMeterVersionStateTypeId, m_model->commonModelInfo().versionString);
|
||||
|
||||
m_thing->setStateValue(sunspecSplitPhaseMeterTotalCurrentStateTypeId, meter->amps());
|
||||
m_thing->setStateValue(sunspecSplitPhaseMeterPhaseACurrentStateTypeId, meter->ampsPhaseA());
|
||||
m_thing->setStateValue(sunspecSplitPhaseMeterPhaseBCurrentStateTypeId, meter->ampsPhaseB());
|
||||
|
|
@ -118,6 +124,8 @@ void SunSpecMeter::onBlockDataUpdated()
|
|||
SunSpecMeterThreePhaseModel *meter = qobject_cast<SunSpecMeterThreePhaseModel *>(m_model);
|
||||
qCDebug(dcSunSpec()) << m_thing->name() << "block data updated" << meter;
|
||||
m_thing->setStateValue(sunspecThreePhaseMeterConnectedStateTypeId, true);
|
||||
m_thing->setStateValue(sunspecThreePhaseMeterVersionStateTypeId, m_model->commonModelInfo().versionString);
|
||||
|
||||
m_thing->setStateValue(sunspecThreePhaseMeterTotalCurrentStateTypeId, meter->amps());
|
||||
m_thing->setStateValue(sunspecThreePhaseMeterPhaseACurrentStateTypeId, meter->ampsPhaseA());
|
||||
m_thing->setStateValue(sunspecThreePhaseMeterPhaseBCurrentStateTypeId, meter->ampsPhaseB());
|
||||
|
|
@ -136,6 +144,8 @@ void SunSpecMeter::onBlockDataUpdated()
|
|||
SunSpecDeltaConnectThreePhaseAbcMeterModel *meter = qobject_cast<SunSpecDeltaConnectThreePhaseAbcMeterModel *>(m_model);
|
||||
qCDebug(dcSunSpec()) << m_thing->name() << "block data updated" << meter;
|
||||
m_thing->setStateValue(sunspecThreePhaseMeterConnectedStateTypeId, true);
|
||||
m_thing->setStateValue(sunspecThreePhaseMeterVersionStateTypeId, m_model->commonModelInfo().versionString);
|
||||
|
||||
m_thing->setStateValue(sunspecThreePhaseMeterTotalCurrentStateTypeId, meter->amps());
|
||||
m_thing->setStateValue(sunspecThreePhaseMeterPhaseACurrentStateTypeId, meter->ampsPhaseA());
|
||||
m_thing->setStateValue(sunspecThreePhaseMeterPhaseBCurrentStateTypeId, meter->ampsPhaseB());
|
||||
|
|
@ -154,6 +164,8 @@ void SunSpecMeter::onBlockDataUpdated()
|
|||
SunSpecMeterThreePhaseWyeConnectModel *meter = qobject_cast<SunSpecMeterThreePhaseWyeConnectModel *>(m_model);
|
||||
qCDebug(dcSunSpec()) << m_thing->name() << "block data updated" << meter;
|
||||
m_thing->setStateValue(sunspecThreePhaseMeterConnectedStateTypeId, true);
|
||||
m_thing->setStateValue(sunspecThreePhaseMeterVersionStateTypeId, m_model->commonModelInfo().versionString);
|
||||
|
||||
m_thing->setStateValue(sunspecThreePhaseMeterTotalCurrentStateTypeId, meter->amps());
|
||||
m_thing->setStateValue(sunspecThreePhaseMeterPhaseACurrentStateTypeId, meter->ampsPhaseA());
|
||||
m_thing->setStateValue(sunspecThreePhaseMeterPhaseBCurrentStateTypeId, meter->ampsPhaseB());
|
||||
|
|
@ -172,6 +184,8 @@ void SunSpecMeter::onBlockDataUpdated()
|
|||
SunSpecMeterThreePhaseDeltaConnectModel *meter = qobject_cast<SunSpecMeterThreePhaseDeltaConnectModel *>(m_model);
|
||||
qCDebug(dcSunSpec()) << m_thing->name() << "block data updated" << meter;
|
||||
m_thing->setStateValue(sunspecThreePhaseMeterConnectedStateTypeId, true);
|
||||
m_thing->setStateValue(sunspecThreePhaseMeterVersionStateTypeId, m_model->commonModelInfo().versionString);
|
||||
|
||||
m_thing->setStateValue(sunspecThreePhaseMeterTotalCurrentStateTypeId, meter->amps());
|
||||
m_thing->setStateValue(sunspecThreePhaseMeterPhaseACurrentStateTypeId, meter->ampsPhaseA());
|
||||
m_thing->setStateValue(sunspecThreePhaseMeterPhaseBCurrentStateTypeId, meter->ampsPhaseB());
|
||||
|
|
|
|||
|
|
@ -126,6 +126,8 @@ void SunSpecStorage::onBlockDataUpdated()
|
|||
qCDebug(dcSunSpec()) << m_thing->name() << "block data updated" << storage;
|
||||
|
||||
m_thing->setStateValue(sunspecStorageConnectedStateTypeId, true);
|
||||
m_thing->setStateValue(sunspecStorageVersionStateTypeId, m_model->commonModelInfo().versionString);
|
||||
|
||||
m_thing->setStateValue(sunspecStorageBatteryCriticalStateTypeId, storage->chaState() < 5);
|
||||
m_thing->setStateValue(sunspecStorageBatteryLevelStateTypeId, qRound(storage->chaState()));
|
||||
m_thing->setStateValue(sunspecStorageGridChargingStateTypeId, storage->chaGriSet() == SunSpecStorageModel::ChagrisetGrid);
|
||||
|
|
|
|||
Loading…
Reference in New Issue