diff --git a/genericenergy/integrationplugingenericenergy.cpp b/genericenergy/integrationplugingenericenergy.cpp index a1c497a..f26d792 100644 --- a/genericenergy/integrationplugingenericenergy.cpp +++ b/genericenergy/integrationplugingenericenergy.cpp @@ -89,6 +89,19 @@ void IntegrationPluginGenericEnergy::executeAction(ThingActionInfo *info) } else { Q_ASSERT_X(false, "executeAction", QString("Unhandled actionTypeId: %1").arg(action.actionTypeId().toString()).toUtf8()); } + } else if (thing->thingClassId() == energyMeterThingClassId) { + if (action.actionTypeId() == energyMeterCurrentPowerActionTypeId) { + thing->setStateValue(energyMeterCurrentPowerStateTypeId, action.paramValue(energyMeterCurrentPowerActionCurrentPowerParamTypeId)); + } else if (action.actionTypeId() == energyMeterTotalEnergyConsumedActionTypeId) { + thing->setStateValue(energyMeterTotalEnergyConsumedStateTypeId, action.paramValue(energyMeterTotalEnergyConsumedActionTotalEnergyConsumedParamTypeId)); + } else if (action.actionTypeId() == energyMeterTotalEnergyProducedActionTypeId) { + thing->setStateValue(energyMeterTotalEnergyProducedStateTypeId, action.paramValue(energyMeterTotalEnergyProducedActionTotalEnergyProducedParamTypeId)); + } else if (action.actionTypeId() == energyMeterCurrentPhaseAActionTypeId) { + thing->setStateValue(energyMeterCurrentPhaseAStateTypeId, action.paramValue(energyMeterCurrentPhaseAActionCurrentPhaseAParamTypeId)); + } else if (action.actionTypeId() == energyMeterVoltagePhaseAActionTypeId) { + thing->setStateValue(energyMeterVoltagePhaseAStateTypeId, action.paramValue(energyMeterVoltagePhaseAActionVoltagePhaseAParamTypeId)); + } + info->finish(Thing::ThingErrorNoError); } else if (thing->thingClassId() == impulseSmartMeterThingClassId) { if (action.actionTypeId() == impulseSmartMeterImpulseInputActionTypeId) { bool value = info->action().param(impulseSmartMeterImpulseInputActionImpulseInputParamTypeId).value().toBool(); diff --git a/genericenergy/integrationplugingenericenergy.json b/genericenergy/integrationplugingenericenergy.json index 3767668..e394d3f 100644 --- a/genericenergy/integrationplugingenericenergy.json +++ b/genericenergy/integrationplugingenericenergy.json @@ -28,6 +28,65 @@ } ] }, + { + "id": "7bba50d7-e18a-41a8-8267-7aa4876ec475", + "name": "energyMeter", + "displayName": "Generic energy meter", + "createMethods": ["user"], + "interfaces": ["energymeter"], + "stateTypes": [ + { + "id": "d5f3fb79-3654-4aaf-ae30-3a761fe2dfd8", + "name": "currentPower", + "displayName": "Current Power usage", + "displayNameAction": "Set current Power usage", + "type": "double", + "defaultValue": 0.00, + "unit": "Watt", + "writable": true + }, + { + "id": "db36a37d-7c48-4208-8b6e-a1b93acb827f", + "name": "totalEnergyConsumed", + "displayName": "Total obtained energy", + "displayNameAction": "Set total obtained energy", + "type": "double", + "defaultValue": 0.00, + "unit": "KiloWattHour", + "writable": true + }, + { + "id": "e73d72f3-b172-4db0-9120-0f713e210bdf", + "name": "totalEnergyProduced", + "displayName": "Total returned energy", + "displayNameAction": "Set total returned energy", + "type": "double", + "defaultValue": 0.00, + "unit": "KiloWattHour", + "writable": true + }, + { + "id": "e493ec25-fb8a-4e36-84d9-4430418b3b6f", + "name": "currentPhaseA", + "displayName": "Current on phase A", + "displayNameAction": "Set current on phase A", + "type": "double", + "defaultValue": 0.00, + "unit": "Ampere", + "writable": true + }, + { + "id": "03deaf24-e515-4649-8979-ef8ae8ee7c02", + "name": "voltagePhaseA", + "displayName": "Voltage on phase A", + "displayNameAction": "Set voltage on phase A", + "type": "double", + "defaultValue": 0.00, + "unit": "Volt", + "writable": true + } + ] + }, { "id": "c3123967-f741-4fe1-a0d4-9a3e405d7e52", "name": "impulseSmartMeter",