From af59859a853ab8e79c6a31a98d55060ef96b1b4a Mon Sep 17 00:00:00 2001 From: "bernhard.trinnes" Date: Sun, 19 Jul 2020 16:33:05 +0200 Subject: [PATCH 1/8] added extended smart meter --- .../integrationplugingenericthings.cpp | 39 +++++++++++++++ .../integrationplugingenericthings.h | 4 ++ .../integrationplugingenericthings.json | 49 +++++++++++++++++++ 3 files changed, 92 insertions(+) diff --git a/genericthings/integrationplugingenericthings.cpp b/genericthings/integrationplugingenericthings.cpp index f224ee10..1c63477d 100644 --- a/genericthings/integrationplugingenericthings.cpp +++ b/genericthings/integrationplugingenericthings.cpp @@ -47,6 +47,19 @@ void IntegrationPluginGenericThings::init() void IntegrationPluginGenericThings::setupThing(ThingSetupInfo *info) { + Thing *thing = info->thing(); + if (thing->thingClassId() == extendedSmartMeterConsumerThingClassId) { + if (!m_smartMeterTimer) { + m_smartMeterTimer = hardwareManager()->pluginTimerManager()->registerTimer(10); + connect(m_smartMeterTimer, &PluginTimer::timeout, thing, [this, thing] { + + int impulsePerKwh = thing->setting(extendedSmartMeterConsumerSettingsImpulsePerKwhParamTypeId).toInt(); + double power = (m_pulsesPerTimeframe.value(thing)/impulsePerKwh)/(m_smartMeterTimer->interval()/3600.00); // Power = Energy/Time; Energy = Impulses/ImpPerkWh + thing->setStateValue(extendedSmartMeterConsumerCurrentPowerStateTypeId, power); + m_pulsesPerTimeframe.insert(thing, 0); + }); + } + } info->finish(Thing::ThingErrorNoError); Thing *thing = info->thing(); if (thing->thingClassId() == extendedBlindThingClassId) { @@ -475,6 +488,20 @@ void IntegrationPluginGenericThings::executeAction(ThingActionInfo *info) } else { Q_ASSERT_X(false, "executeAction", QString("Unhandled actionTypeId: %1").arg(action.actionTypeId().toString()).toUtf8()); } + } else if (thing->thingClassId() == extendedSmartMeterConsumerThingClassId) { + if (action.actionTypeId() == extendedSmartMeterConsumerS0InputActionTypeId) { + bool value = info->action().param(extendedSmartMeterConsumerS0InputActionS0InputParamTypeId).value().toBool(); + int impulsePerKwh = info->thing()->setting(extendedSmartMeterConsumerSettingsImpulsePerKwhParamTypeId).toInt(); + if (value) { + double currentEnergy = thing->stateValue(extendedSmartMeterConsumerTotalEnergyConsumedStateTypeId).toDouble(); + thing->setStateValue(extendedSmartMeterConsumerTotalEnergyConsumedStateTypeId ,currentEnergy + (1.00/impulsePerKwh)); + m_pulsesPerTimeframe.insert(thing, m_pulsesPerTimeframe.value(thing)+1); + } + info->finish(Thing::ThingErrorNoError); + return; + } else { + Q_ASSERT_X(false, "executeAction", QString("Unhandled actionTypeId: %1").arg(action.actionTypeId().toString()).toUtf8()); + } } else { Q_ASSERT_X(false, "executeAction", QString("Unhandled thingClassId: %1").arg(thing->thingClassId().toString()).toUtf8()); } @@ -493,6 +520,18 @@ void IntegrationPluginGenericThings::thingRemoved(Thing *thing) } } +void IntegrationPluginGenericThings::thingRemoved(Thing *thing) +{ + if (thing->thingClassId() == extendedSmartMeterConsumerThingClassId) { + m_pulsesPerTimeframe.remove(thing); + } + + if (myThings().isEmpty()) { + hardwareManager()->pluginTimerManager()->unregisterTimer(m_smartMeterTimer); + m_smartMeterTimer = nullptr; + } +} + double IntegrationPluginGenericThings::mapDoubleValue(double value, double fromMin, double fromMax, double toMin, double toMax) { double percent = (value - fromMin) / (fromMax - fromMin); diff --git a/genericthings/integrationplugingenericthings.h b/genericthings/integrationplugingenericthings.h index a98c466a..e8b53857 100644 --- a/genericthings/integrationplugingenericthings.h +++ b/genericthings/integrationplugingenericthings.h @@ -33,6 +33,7 @@ #include "integrations/integrationplugin.h" #include +#include "plugintimer.h" class IntegrationPluginGenericThings: public IntegrationPlugin { @@ -49,6 +50,9 @@ public: void thingRemoved(Thing *thing) override; private: + PluginTimer *m_smartMeterTimer = nullptr; + QHash m_pulsesPerTimeframe; + double mapDoubleValue(double value, double fromMin, double fromMax, double toMin, double toMax); QHash m_extendedBlindPercentageTimer; diff --git a/genericthings/integrationplugingenericthings.json b/genericthings/integrationplugingenericthings.json index fc4cfeca..6cffcfc0 100644 --- a/genericthings/integrationplugingenericthings.json +++ b/genericthings/integrationplugingenericthings.json @@ -693,6 +693,55 @@ "ioType": "analogOutput" } ] + }, + { + "id": "c3123967-f741-4fe1-a0d4-9a3e405d7e52", + "name": "extendedSmartMeterConsumer", + "displayName": "Extended smart meter consumer", + "createMethods": ["user"], + "interfaces": ["extendedsmartmeterconsumer"], + "settingsTypes": [ + { + "id": "c361732b-68eb-447e-a434-e84031231871", + "name": "impulsePerKwh", + "displayName": "Impulse/kWh", + "type": "int", + "minValue": 1, + "maxValue": 1000000, + "defaultValue": 1000 + } + ], + "stateTypes": [ + { + "id": "5983d714-5f80-42d8-bee2-9228b6382b3b", + "name": "currentPower", + "displayName": "Power", + "displayNameEvent": "Power changed", + "type": "double", + "defaultValue": 0.00, + "unit": "Watt" + }, + { + "id": "5821edb7-e6cb-4e5a-9d0b-3375126d3367", + "name": "totalEnergyConsumed", + "displayName": "Energy", + "displayNameEvent": "Energy changed", + "type": "double", + "defaultValue": 0.00, + "unit": "KiloWattHour" + }, + { + "id": "9cd7e5ca-f8f8-48d5-9785-911ae75158c3", + "name": "s0Input", + "displayName": "S0 input", + "displayNameEvent": "S0 impulse", + "displayNameAction": "S0 impulse", + "type": "bool", + "defaultValue": false, + "writable": true, + "ioType": "digitalInput" + } + ] } ] } From 5c5880ac62d95737469f768ec9646804d5ee9f7e Mon Sep 17 00:00:00 2001 From: "bernhard.trinnes" Date: Sun, 19 Jul 2020 16:37:11 +0200 Subject: [PATCH 2/8] updated translation --- ...b3188696-2585-4806-bf98-30ab576ce5c8-de.ts | 81 ++++++++++++++++++- ...88696-2585-4806-bf98-30ab576ce5c8-en_US.ts | 76 ++++++++++++++++- 2 files changed, 154 insertions(+), 3 deletions(-) diff --git a/genericthings/translations/b3188696-2585-4806-bf98-30ab576ce5c8-de.ts b/genericthings/translations/b3188696-2585-4806-bf98-30ab576ce5c8-de.ts index e2076c93..5dce4078 100644 --- a/genericthings/translations/b3188696-2585-4806-bf98-30ab576ce5c8-de.ts +++ b/genericthings/translations/b3188696-2585-4806-bf98-30ab576ce5c8-de.ts @@ -340,7 +340,15 @@ The name of the EventType ({181df603-d45f-4d3d-a358-97aa3e4ac0bd}) of ThingClass Power +<<<<<<< HEAD The name of the ParamType (ThingClass: ventilation, ActionType: power, ID: {846711b7-ea5a-4c66-a267-001c60406509}) +======= + The name of the ParamType (ThingClass: extendedSmartMeterConsumer, EventType: currentPower, ID: {5983d714-5f80-42d8-bee2-9228b6382b3b}) +---------- +The name of the StateType ({5983d714-5f80-42d8-bee2-9228b6382b3b}) of ThingClass extendedSmartMeterConsumer +---------- +The name of the ParamType (ThingClass: ventilation, ActionType: power, ID: {846711b7-ea5a-4c66-a267-001c60406509}) +>>>>>>> updated translation ---------- The name of the ParamType (ThingClass: ventilation, EventType: power, ID: {846711b7-ea5a-4c66-a267-001c60406509}) ---------- @@ -379,7 +387,9 @@ The name of the StateType ({018038d7-1d02-4b17-8fe3-babca044b087}) of ThingClass Power changed - The name of the EventType ({409b635e-a754-4b5c-b3f0-d1c5a0fb3f03}) of ThingClass heating + The name of the EventType ({5983d714-5f80-42d8-bee2-9228b6382b3b}) of ThingClass extendedSmartMeterConsumer +---------- +The name of the EventType ({409b635e-a754-4b5c-b3f0-d1c5a0fb3f03}) of ThingClass heating ---------- The name of the EventType ({8b6e4a67-6522-408b-b676-8d2f09ed2d54}) of ThingClass light ---------- @@ -529,6 +539,32 @@ The name of the StateType ({d0b6c4be-339e-4b0f-a234-0611b7565395}) of ThingClass Turn on or off The name of the ActionType ({846711b7-ea5a-4c66-a267-001c60406509}) of ThingClass ventilation ---------- +The name of the ActionType ({0212a287-c5ae-4644-8803-adfdd8caeb9a}) of ThingClass irrigation + Ein- oder ausschalten + + + Turned on or off + The name of the EventType ({846711b7-ea5a-4c66-a267-001c60406509}) of ThingClass ventilation +---------- +The name of the EventType ({0212a287-c5ae-4644-8803-adfdd8caeb9a}) of ThingClass irrigation + Ein- oder ausgeschaltet + + + Input value + The name of the ParamType (ThingClass: moistureSensor, ActionType: input, ID: {ce64a425-d990-4fc1-966b-be6de445792b}) +---------- +The name of the ParamType (ThingClass: moistureSensor, EventType: input, ID: {ce64a425-d990-4fc1-966b-be6de445792b}) +---------- +The name of the StateType ({ce64a425-d990-4fc1-966b-be6de445792b}) of ThingClass moistureSensor +---------- +The name of the ParamType (ThingClass: humiditySensor, ActionType: input, ID: {a8223e65-e704-4f84-9bbe-d8fc42597047}) +---------- +The name of the ParamType (ThingClass: humiditySensor, EventType: input, ID: {a8223e65-e704-4f84-9bbe-d8fc42597047}) +---------- +The name of the StateType ({a8223e65-e704-4f84-9bbe-d8fc42597047}) of ThingClass humiditySensor +---------- +The name of the ParamType (ThingClass: temperatureSensor, ActionType: input, ID: {fed37466-1264-4ac1-84fd-aff3a1f7ff04}) +---------- The name of the ActionType ({0212a287-c5ae-4644-8803-adfdd8caeb9a}) of ThingClass irrigation Schalte ein oder aus @@ -549,5 +585,48 @@ The name of the EventType ({0212a287-c5ae-4644-8803-adfdd8caeb9a}) of ThingClass The name of the vendor ({2062d64d-3232-433c-88bc-0d33c0ba2ba6}) nymea + + Energy + The name of the ParamType (ThingClass: extendedSmartMeterConsumer, EventType: totalEnergyConsumed, ID: {5821edb7-e6cb-4e5a-9d0b-3375126d3367}) +---------- +The name of the StateType ({5821edb7-e6cb-4e5a-9d0b-3375126d3367}) of ThingClass extendedSmartMeterConsumer + Energie + + + Energy changed + The name of the EventType ({5821edb7-e6cb-4e5a-9d0b-3375126d3367}) of ThingClass extendedSmartMeterConsumer + Energie geändert + + + Extended smart meter consumer + The name of the ThingClass ({c3123967-f741-4fe1-a0d4-9a3e405d7e52}) + Erweiterter Smart Meter Verbraucher + + + Generic ventilation + The name of the ThingClass ({24af8dd3-ddf0-47f0-bf09-70fdfd8dceab}) + Generische Lüftung + + + Impulse/kWh + The name of the ParamType (ThingClass: extendedSmartMeterConsumer, Type: settings, ID: {c361732b-68eb-447e-a434-e84031231871}) + Impulse/kWh + + + S0 impulse + The name of the ActionType ({9cd7e5ca-f8f8-48d5-9785-911ae75158c3}) of ThingClass extendedSmartMeterConsumer +---------- +The name of the EventType ({9cd7e5ca-f8f8-48d5-9785-911ae75158c3}) of ThingClass extendedSmartMeterConsumer + S0 Impulse + + + S0 input + The name of the ParamType (ThingClass: extendedSmartMeterConsumer, ActionType: s0Input, ID: {9cd7e5ca-f8f8-48d5-9785-911ae75158c3}) +---------- +The name of the ParamType (ThingClass: extendedSmartMeterConsumer, EventType: s0Input, ID: {9cd7e5ca-f8f8-48d5-9785-911ae75158c3}) +---------- +The name of the StateType ({9cd7e5ca-f8f8-48d5-9785-911ae75158c3}) of ThingClass extendedSmartMeterConsumer + S0 Eingang + diff --git a/genericthings/translations/b3188696-2585-4806-bf98-30ab576ce5c8-en_US.ts b/genericthings/translations/b3188696-2585-4806-bf98-30ab576ce5c8-en_US.ts index 0025225d..c431b5ea 100644 --- a/genericthings/translations/b3188696-2585-4806-bf98-30ab576ce5c8-en_US.ts +++ b/genericthings/translations/b3188696-2585-4806-bf98-30ab576ce5c8-en_US.ts @@ -340,7 +340,11 @@ The name of the EventType ({181df603-d45f-4d3d-a358-97aa3e4ac0bd}) of ThingClass Power - The name of the ParamType (ThingClass: ventilation, ActionType: power, ID: {846711b7-ea5a-4c66-a267-001c60406509}) + The name of the ParamType (ThingClass: extendedSmartMeterConsumer, EventType: currentPower, ID: {5983d714-5f80-42d8-bee2-9228b6382b3b}) +---------- +The name of the StateType ({5983d714-5f80-42d8-bee2-9228b6382b3b}) of ThingClass extendedSmartMeterConsumer +---------- +The name of the ParamType (ThingClass: ventilation, ActionType: power, ID: {846711b7-ea5a-4c66-a267-001c60406509}) ---------- The name of the ParamType (ThingClass: ventilation, EventType: power, ID: {846711b7-ea5a-4c66-a267-001c60406509}) ---------- @@ -379,7 +383,9 @@ The name of the StateType ({018038d7-1d02-4b17-8fe3-babca044b087}) of ThingClass Power changed - The name of the EventType ({409b635e-a754-4b5c-b3f0-d1c5a0fb3f03}) of ThingClass heating + The name of the EventType ({5983d714-5f80-42d8-bee2-9228b6382b3b}) of ThingClass extendedSmartMeterConsumer +---------- +The name of the EventType ({409b635e-a754-4b5c-b3f0-d1c5a0fb3f03}) of ThingClass heating ---------- The name of the EventType ({8b6e4a67-6522-408b-b676-8d2f09ed2d54}) of ThingClass light ---------- @@ -528,6 +534,29 @@ The name of the StateType ({d0b6c4be-339e-4b0f-a234-0611b7565395}) of ThingClass Turn on or off The name of the ActionType ({846711b7-ea5a-4c66-a267-001c60406509}) of ThingClass ventilation +<<<<<<< HEAD +======= +---------- +The name of the ActionType ({0212a287-c5ae-4644-8803-adfdd8caeb9a}) of ThingClass irrigation + + + + Turned on or off + The name of the EventType ({846711b7-ea5a-4c66-a267-001c60406509}) of ThingClass ventilation +---------- +The name of the EventType ({0212a287-c5ae-4644-8803-adfdd8caeb9a}) of ThingClass irrigation + + + + Input value + The name of the ParamType (ThingClass: moistureSensor, ActionType: input, ID: {ce64a425-d990-4fc1-966b-be6de445792b}) +---------- +The name of the ParamType (ThingClass: moistureSensor, EventType: input, ID: {ce64a425-d990-4fc1-966b-be6de445792b}) +---------- +The name of the StateType ({ce64a425-d990-4fc1-966b-be6de445792b}) of ThingClass moistureSensor +---------- +The name of the ParamType (ThingClass: humiditySensor, ActionType: input, ID: {a8223e65-e704-4f84-9bbe-d8fc42597047}) +>>>>>>> updated translation ---------- The name of the ActionType ({0212a287-c5ae-4644-8803-adfdd8caeb9a}) of ThingClass irrigation @@ -549,5 +578,48 @@ The name of the EventType ({0212a287-c5ae-4644-8803-adfdd8caeb9a}) of ThingClass The name of the vendor ({2062d64d-3232-433c-88bc-0d33c0ba2ba6}) + + Energy + The name of the ParamType (ThingClass: extendedSmartMeterConsumer, EventType: totalEnergyConsumed, ID: {5821edb7-e6cb-4e5a-9d0b-3375126d3367}) +---------- +The name of the StateType ({5821edb7-e6cb-4e5a-9d0b-3375126d3367}) of ThingClass extendedSmartMeterConsumer + + + + Energy changed + The name of the EventType ({5821edb7-e6cb-4e5a-9d0b-3375126d3367}) of ThingClass extendedSmartMeterConsumer + + + + Extended smart meter consumer + The name of the ThingClass ({c3123967-f741-4fe1-a0d4-9a3e405d7e52}) + + + + Generic ventilation + The name of the ThingClass ({24af8dd3-ddf0-47f0-bf09-70fdfd8dceab}) + + + + Impulse/kWh + The name of the ParamType (ThingClass: extendedSmartMeterConsumer, Type: settings, ID: {c361732b-68eb-447e-a434-e84031231871}) + + + + S0 impulse + The name of the ActionType ({9cd7e5ca-f8f8-48d5-9785-911ae75158c3}) of ThingClass extendedSmartMeterConsumer +---------- +The name of the EventType ({9cd7e5ca-f8f8-48d5-9785-911ae75158c3}) of ThingClass extendedSmartMeterConsumer + + + + S0 input + The name of the ParamType (ThingClass: extendedSmartMeterConsumer, ActionType: s0Input, ID: {9cd7e5ca-f8f8-48d5-9785-911ae75158c3}) +---------- +The name of the ParamType (ThingClass: extendedSmartMeterConsumer, EventType: s0Input, ID: {9cd7e5ca-f8f8-48d5-9785-911ae75158c3}) +---------- +The name of the StateType ({9cd7e5ca-f8f8-48d5-9785-911ae75158c3}) of ThingClass extendedSmartMeterConsumer + + From b9b6c19b1527bd1249a827ad6b9960e227c0419c Mon Sep 17 00:00:00 2001 From: "bernhard.trinnes" Date: Sun, 19 Jul 2020 16:56:10 +0200 Subject: [PATCH 3/8] fixed power calculation --- genericthings/integrationplugingenericthings.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/genericthings/integrationplugingenericthings.cpp b/genericthings/integrationplugingenericthings.cpp index 1c63477d..3244bb9e 100644 --- a/genericthings/integrationplugingenericthings.cpp +++ b/genericthings/integrationplugingenericthings.cpp @@ -51,14 +51,14 @@ void IntegrationPluginGenericThings::setupThing(ThingSetupInfo *info) if (thing->thingClassId() == extendedSmartMeterConsumerThingClassId) { if (!m_smartMeterTimer) { m_smartMeterTimer = hardwareManager()->pluginTimerManager()->registerTimer(10); - connect(m_smartMeterTimer, &PluginTimer::timeout, thing, [this, thing] { - - int impulsePerKwh = thing->setting(extendedSmartMeterConsumerSettingsImpulsePerKwhParamTypeId).toInt(); - double power = (m_pulsesPerTimeframe.value(thing)/impulsePerKwh)/(m_smartMeterTimer->interval()/3600.00); // Power = Energy/Time; Energy = Impulses/ImpPerkWh - thing->setStateValue(extendedSmartMeterConsumerCurrentPowerStateTypeId, power); - m_pulsesPerTimeframe.insert(thing, 0); - }); } + connect(m_smartMeterTimer, &PluginTimer::timeout, thing, [this, thing] { + + double impulsePerKwh = thing->setting(extendedSmartMeterConsumerSettingsImpulsePerKwhParamTypeId).toDouble(); + double power = (m_pulsesPerTimeframe.value(thing)/impulsePerKwh)/(m_smartMeterTimer->interval()/3600.00); // Power = Energy/Time; Energy = Impulses/ImpPerkWh + thing->setStateValue(extendedSmartMeterConsumerCurrentPowerStateTypeId, power*1000); + m_pulsesPerTimeframe.insert(thing, 0); + }); } info->finish(Thing::ThingErrorNoError); Thing *thing = info->thing(); @@ -491,6 +491,7 @@ void IntegrationPluginGenericThings::executeAction(ThingActionInfo *info) } else if (thing->thingClassId() == extendedSmartMeterConsumerThingClassId) { if (action.actionTypeId() == extendedSmartMeterConsumerS0InputActionTypeId) { bool value = info->action().param(extendedSmartMeterConsumerS0InputActionS0InputParamTypeId).value().toBool(); + thing->setStateValue(extendedSmartMeterConsumerS0InputStateTypeId, value); int impulsePerKwh = info->thing()->setting(extendedSmartMeterConsumerSettingsImpulsePerKwhParamTypeId).toInt(); if (value) { double currentEnergy = thing->stateValue(extendedSmartMeterConsumerTotalEnergyConsumedStateTypeId).toDouble(); From 863d6b63744bff2de28744e8de97c34dbf78f705 Mon Sep 17 00:00:00 2001 From: "bernhard.trinnes" Date: Mon, 20 Jul 2020 14:18:54 +0200 Subject: [PATCH 4/8] rebased to venetian blind branch --- .../integrationplugingenericthings.cpp | 37 +++++++------------ .../integrationplugingenericthings.h | 4 +- 2 files changed, 15 insertions(+), 26 deletions(-) diff --git a/genericthings/integrationplugingenericthings.cpp b/genericthings/integrationplugingenericthings.cpp index 3244bb9e..9aecf771 100644 --- a/genericthings/integrationplugingenericthings.cpp +++ b/genericthings/integrationplugingenericthings.cpp @@ -40,28 +40,10 @@ IntegrationPluginGenericThings::IntegrationPluginGenericThings() } -void IntegrationPluginGenericThings::init() -{ - -} - void IntegrationPluginGenericThings::setupThing(ThingSetupInfo *info) { Thing *thing = info->thing(); - if (thing->thingClassId() == extendedSmartMeterConsumerThingClassId) { - if (!m_smartMeterTimer) { - m_smartMeterTimer = hardwareManager()->pluginTimerManager()->registerTimer(10); - } - connect(m_smartMeterTimer, &PluginTimer::timeout, thing, [this, thing] { - double impulsePerKwh = thing->setting(extendedSmartMeterConsumerSettingsImpulsePerKwhParamTypeId).toDouble(); - double power = (m_pulsesPerTimeframe.value(thing)/impulsePerKwh)/(m_smartMeterTimer->interval()/3600.00); // Power = Energy/Time; Energy = Impulses/ImpPerkWh - thing->setStateValue(extendedSmartMeterConsumerCurrentPowerStateTypeId, power*1000); - m_pulsesPerTimeframe.insert(thing, 0); - }); - } - info->finish(Thing::ThingErrorNoError); - Thing *thing = info->thing(); if (thing->thingClassId() == extendedBlindThingClassId) { uint closingTime = thing->setting(extendedBlindSettingsClosingTimeParamTypeId).toUInt(); if (closingTime == 0) { @@ -202,7 +184,19 @@ void IntegrationPluginGenericThings::setupThing(ThingSetupInfo *info) } } }); + } else if (thing->thingClassId() == extendedSmartMeterConsumerThingClassId) { + if (!m_smartMeterTimer) { + m_smartMeterTimer = hardwareManager()->pluginTimerManager()->registerTimer(10); + } + connect(m_smartMeterTimer, &PluginTimer::timeout, thing, [this, thing] { + + double impulsePerKwh = thing->setting(extendedSmartMeterConsumerSettingsImpulsePerKwhParamTypeId).toDouble(); + double power = (m_pulsesPerTimeframe.value(thing)/impulsePerKwh)/(m_smartMeterTimer->interval()/3600.00); // Power = Energy/Time; Energy = Impulses/ImpPerkWh + thing->setStateValue(extendedSmartMeterConsumerCurrentPowerStateTypeId, power*1000); + m_pulsesPerTimeframe.insert(thing, 0); + }); } + info->finish(Thing::ThingErrorNoError); } void IntegrationPluginGenericThings::executeAction(ThingActionInfo *info) @@ -518,12 +512,7 @@ void IntegrationPluginGenericThings::thingRemoved(Thing *thing) m_extendedBlindTargetPercentage.remove(thing); m_venetianBlindAngleTimer.take(thing)->deleteLater(); m_venetianBlindTargetAngle.remove(thing); - } -} - -void IntegrationPluginGenericThings::thingRemoved(Thing *thing) -{ - if (thing->thingClassId() == extendedSmartMeterConsumerThingClassId) { + } else if (thing->thingClassId() == extendedSmartMeterConsumerThingClassId) { m_pulsesPerTimeframe.remove(thing); } diff --git a/genericthings/integrationplugingenericthings.h b/genericthings/integrationplugingenericthings.h index e8b53857..77fa0aeb 100644 --- a/genericthings/integrationplugingenericthings.h +++ b/genericthings/integrationplugingenericthings.h @@ -32,9 +32,10 @@ #define INTEGRATIONPLUGINGENERICTHINGS_H #include "integrations/integrationplugin.h" -#include #include "plugintimer.h" +#include + class IntegrationPluginGenericThings: public IntegrationPlugin { Q_OBJECT @@ -44,7 +45,6 @@ class IntegrationPluginGenericThings: public IntegrationPlugin public: explicit IntegrationPluginGenericThings(); - void init() override; void setupThing(ThingSetupInfo *info) override; void executeAction(ThingActionInfo *info) override; void thingRemoved(Thing *thing) override; From 5361cb4f62b93538c8cac34c42dbb0a2e489d005 Mon Sep 17 00:00:00 2001 From: "bernhard.trinnes" Date: Mon, 20 Jul 2020 14:38:26 +0200 Subject: [PATCH 5/8] updated translations --- ...b3188696-2585-4806-bf98-30ab576ce5c8-de.ts | 56 ++++++------------- ...88696-2585-4806-bf98-30ab576ce5c8-en_US.ts | 45 +++++---------- 2 files changed, 30 insertions(+), 71 deletions(-) diff --git a/genericthings/translations/b3188696-2585-4806-bf98-30ab576ce5c8-de.ts b/genericthings/translations/b3188696-2585-4806-bf98-30ab576ce5c8-de.ts index 5dce4078..14cc0694 100644 --- a/genericthings/translations/b3188696-2585-4806-bf98-30ab576ce5c8-de.ts +++ b/genericthings/translations/b3188696-2585-4806-bf98-30ab576ce5c8-de.ts @@ -28,7 +28,7 @@ The name of the StateType ({fcb700c4-5da8-4385-85b0-6616e807974e}) of ThingClass Angle end to end time [MilliSecond] - The name of the ParamType (ThingClass: venetianBlind, Type: thing, ID: {6c8340bf-7fd3-43e3-a75b-dfa2f6426e11}) + The name of the ParamType (ThingClass: venetianBlind, Type: settings, ID: {6c8340bf-7fd3-43e3-a75b-dfa2f6426e11}) End- zu Endwinkelzeit @@ -92,9 +92,9 @@ The name of the EventType ({59bfd575-709f-4e43-9726-de26e6d4ca8b}) of ThingClass Closing time [MilliSecond] - The name of the ParamType (ThingClass: venetianBlind, Type: thing, ID: {4c0bf07d-aaab-4f67-af65-00ceaefbaa84}) + The name of the ParamType (ThingClass: venetianBlind, Type: settings, ID: {4c0bf07d-aaab-4f67-af65-00ceaefbaa84}) ---------- -The name of the ParamType (ThingClass: extendedBlind, Type: thing, ID: {27a95b8d-7f97-441b-a3be-0646c517cb06}) +The name of the ParamType (ThingClass: extendedBlind, Type: settings, ID: {27a95b8d-7f97-441b-a3be-0646c517cb06}) Schließdauer [Millisekunden] @@ -340,15 +340,11 @@ The name of the EventType ({181df603-d45f-4d3d-a358-97aa3e4ac0bd}) of ThingClass Power -<<<<<<< HEAD - The name of the ParamType (ThingClass: ventilation, ActionType: power, ID: {846711b7-ea5a-4c66-a267-001c60406509}) -======= The name of the ParamType (ThingClass: extendedSmartMeterConsumer, EventType: currentPower, ID: {5983d714-5f80-42d8-bee2-9228b6382b3b}) ---------- The name of the StateType ({5983d714-5f80-42d8-bee2-9228b6382b3b}) of ThingClass extendedSmartMeterConsumer ---------- The name of the ParamType (ThingClass: ventilation, ActionType: power, ID: {846711b7-ea5a-4c66-a267-001c60406509}) ->>>>>>> updated translation ---------- The name of the ParamType (ThingClass: ventilation, EventType: power, ID: {846711b7-ea5a-4c66-a267-001c60406509}) ---------- @@ -539,32 +535,6 @@ The name of the StateType ({d0b6c4be-339e-4b0f-a234-0611b7565395}) of ThingClass Turn on or off The name of the ActionType ({846711b7-ea5a-4c66-a267-001c60406509}) of ThingClass ventilation ---------- -The name of the ActionType ({0212a287-c5ae-4644-8803-adfdd8caeb9a}) of ThingClass irrigation - Ein- oder ausschalten - - - Turned on or off - The name of the EventType ({846711b7-ea5a-4c66-a267-001c60406509}) of ThingClass ventilation ----------- -The name of the EventType ({0212a287-c5ae-4644-8803-adfdd8caeb9a}) of ThingClass irrigation - Ein- oder ausgeschaltet - - - Input value - The name of the ParamType (ThingClass: moistureSensor, ActionType: input, ID: {ce64a425-d990-4fc1-966b-be6de445792b}) ----------- -The name of the ParamType (ThingClass: moistureSensor, EventType: input, ID: {ce64a425-d990-4fc1-966b-be6de445792b}) ----------- -The name of the StateType ({ce64a425-d990-4fc1-966b-be6de445792b}) of ThingClass moistureSensor ----------- -The name of the ParamType (ThingClass: humiditySensor, ActionType: input, ID: {a8223e65-e704-4f84-9bbe-d8fc42597047}) ----------- -The name of the ParamType (ThingClass: humiditySensor, EventType: input, ID: {a8223e65-e704-4f84-9bbe-d8fc42597047}) ----------- -The name of the StateType ({a8223e65-e704-4f84-9bbe-d8fc42597047}) of ThingClass humiditySensor ----------- -The name of the ParamType (ThingClass: temperatureSensor, ActionType: input, ID: {fed37466-1264-4ac1-84fd-aff3a1f7ff04}) ----------- The name of the ActionType ({0212a287-c5ae-4644-8803-adfdd8caeb9a}) of ThingClass irrigation Schalte ein oder aus @@ -600,12 +570,7 @@ The name of the StateType ({5821edb7-e6cb-4e5a-9d0b-3375126d3367}) of ThingClass Extended smart meter consumer The name of the ThingClass ({c3123967-f741-4fe1-a0d4-9a3e405d7e52}) - Erweiterter Smart Meter Verbraucher - - - Generic ventilation - The name of the ThingClass ({24af8dd3-ddf0-47f0-bf09-70fdfd8dceab}) - Generische Lüftung + Erweiterter Smart-Meter Verbraucher Impulse/kWh @@ -626,7 +591,18 @@ The name of the EventType ({9cd7e5ca-f8f8-48d5-9785-911ae75158c3}) of ThingClass The name of the ParamType (ThingClass: extendedSmartMeterConsumer, EventType: s0Input, ID: {9cd7e5ca-f8f8-48d5-9785-911ae75158c3}) ---------- The name of the StateType ({9cd7e5ca-f8f8-48d5-9785-911ae75158c3}) of ThingClass extendedSmartMeterConsumer - S0 Eingang + S0 Input + + + + IntegrationPluginGenericThings + + Invalid closing time + Ungültige Schließzeit + + + Invalid closing or angle time + Ungültige Schließ- oder Winkelstellzeit diff --git a/genericthings/translations/b3188696-2585-4806-bf98-30ab576ce5c8-en_US.ts b/genericthings/translations/b3188696-2585-4806-bf98-30ab576ce5c8-en_US.ts index c431b5ea..edb544fb 100644 --- a/genericthings/translations/b3188696-2585-4806-bf98-30ab576ce5c8-en_US.ts +++ b/genericthings/translations/b3188696-2585-4806-bf98-30ab576ce5c8-en_US.ts @@ -28,7 +28,7 @@ The name of the StateType ({fcb700c4-5da8-4385-85b0-6616e807974e}) of ThingClass Angle end to end time [MilliSecond] - The name of the ParamType (ThingClass: venetianBlind, Type: thing, ID: {6c8340bf-7fd3-43e3-a75b-dfa2f6426e11}) + The name of the ParamType (ThingClass: venetianBlind, Type: settings, ID: {6c8340bf-7fd3-43e3-a75b-dfa2f6426e11}) @@ -92,9 +92,9 @@ The name of the EventType ({59bfd575-709f-4e43-9726-de26e6d4ca8b}) of ThingClass Closing time [MilliSecond] - The name of the ParamType (ThingClass: venetianBlind, Type: thing, ID: {4c0bf07d-aaab-4f67-af65-00ceaefbaa84}) + The name of the ParamType (ThingClass: venetianBlind, Type: settings, ID: {4c0bf07d-aaab-4f67-af65-00ceaefbaa84}) ---------- -The name of the ParamType (ThingClass: extendedBlind, Type: thing, ID: {27a95b8d-7f97-441b-a3be-0646c517cb06}) +The name of the ParamType (ThingClass: extendedBlind, Type: settings, ID: {27a95b8d-7f97-441b-a3be-0646c517cb06}) @@ -534,29 +534,6 @@ The name of the StateType ({d0b6c4be-339e-4b0f-a234-0611b7565395}) of ThingClass Turn on or off The name of the ActionType ({846711b7-ea5a-4c66-a267-001c60406509}) of ThingClass ventilation -<<<<<<< HEAD -======= ----------- -The name of the ActionType ({0212a287-c5ae-4644-8803-adfdd8caeb9a}) of ThingClass irrigation - - - - Turned on or off - The name of the EventType ({846711b7-ea5a-4c66-a267-001c60406509}) of ThingClass ventilation ----------- -The name of the EventType ({0212a287-c5ae-4644-8803-adfdd8caeb9a}) of ThingClass irrigation - - - - Input value - The name of the ParamType (ThingClass: moistureSensor, ActionType: input, ID: {ce64a425-d990-4fc1-966b-be6de445792b}) ----------- -The name of the ParamType (ThingClass: moistureSensor, EventType: input, ID: {ce64a425-d990-4fc1-966b-be6de445792b}) ----------- -The name of the StateType ({ce64a425-d990-4fc1-966b-be6de445792b}) of ThingClass moistureSensor ----------- -The name of the ParamType (ThingClass: humiditySensor, ActionType: input, ID: {a8223e65-e704-4f84-9bbe-d8fc42597047}) ->>>>>>> updated translation ---------- The name of the ActionType ({0212a287-c5ae-4644-8803-adfdd8caeb9a}) of ThingClass irrigation @@ -595,11 +572,6 @@ The name of the StateType ({5821edb7-e6cb-4e5a-9d0b-3375126d3367}) of ThingClass The name of the ThingClass ({c3123967-f741-4fe1-a0d4-9a3e405d7e52}) - - Generic ventilation - The name of the ThingClass ({24af8dd3-ddf0-47f0-bf09-70fdfd8dceab}) - - Impulse/kWh The name of the ParamType (ThingClass: extendedSmartMeterConsumer, Type: settings, ID: {c361732b-68eb-447e-a434-e84031231871}) @@ -622,4 +594,15 @@ The name of the StateType ({9cd7e5ca-f8f8-48d5-9785-911ae75158c3}) of ThingClass + + IntegrationPluginGenericThings + + Invalid closing time + + + + Invalid closing or angle time + + + From cb7f20d168c0fcfca1b1fa9716dc742079364858 Mon Sep 17 00:00:00 2001 From: "bernhard.trinnes" Date: Wed, 29 Jul 2020 14:49:41 +0200 Subject: [PATCH 6/8] changed remarks from reviewer --- .../integrationplugingenericthings.cpp | 33 ++++++++------- .../integrationplugingenericthings.h | 2 +- .../integrationplugingenericthings.json | 20 +++++++--- ...b3188696-2585-4806-bf98-30ab576ce5c8-de.ts | 40 +++++++++++-------- ...88696-2585-4806-bf98-30ab576ce5c8-en_US.ts | 36 ++++++++++------- 5 files changed, 81 insertions(+), 50 deletions(-) diff --git a/genericthings/integrationplugingenericthings.cpp b/genericthings/integrationplugingenericthings.cpp index 9aecf771..26a46542 100644 --- a/genericthings/integrationplugingenericthings.cpp +++ b/genericthings/integrationplugingenericthings.cpp @@ -185,13 +185,20 @@ void IntegrationPluginGenericThings::setupThing(ThingSetupInfo *info) } }); } else if (thing->thingClassId() == extendedSmartMeterConsumerThingClassId) { - if (!m_smartMeterTimer) { - m_smartMeterTimer = hardwareManager()->pluginTimerManager()->registerTimer(10); - } - connect(m_smartMeterTimer, &PluginTimer::timeout, thing, [this, thing] { + QTimer* smartMeterTimer = new QTimer(this); + int timeframe = thing->setting(extendedSmartMeterConsumerSettingsImpulseTimeframeParamTypeId).toInt(); + smartMeterTimer->setInterval(timeframe * 1000); + m_smartMeterTimer.insert(thing, smartMeterTimer); + connect(thing, &Thing::settingChanged, smartMeterTimer, [smartMeterTimer] (const ParamTypeId ¶mTypeId, const QVariant &value) { + if (paramTypeId == extendedSmartMeterConsumerSettingsImpulseTimeframeParamTypeId) { + smartMeterTimer->setInterval(value.toInt() * 1000); + } + }); + + connect(smartMeterTimer, &QTimer::timeout, thing, [this, smartMeterTimer, thing] { double impulsePerKwh = thing->setting(extendedSmartMeterConsumerSettingsImpulsePerKwhParamTypeId).toDouble(); - double power = (m_pulsesPerTimeframe.value(thing)/impulsePerKwh)/(m_smartMeterTimer->interval()/3600.00); // Power = Energy/Time; Energy = Impulses/ImpPerkWh + double power = (m_pulsesPerTimeframe.value(thing)/impulsePerKwh)/(smartMeterTimer->interval()/3600.00); // Power = Energy/Time; Energy = Impulses/ImpPerkWh thing->setStateValue(extendedSmartMeterConsumerCurrentPowerStateTypeId, power*1000); m_pulsesPerTimeframe.insert(thing, 0); }); @@ -483,14 +490,14 @@ void IntegrationPluginGenericThings::executeAction(ThingActionInfo *info) Q_ASSERT_X(false, "executeAction", QString("Unhandled actionTypeId: %1").arg(action.actionTypeId().toString()).toUtf8()); } } else if (thing->thingClassId() == extendedSmartMeterConsumerThingClassId) { - if (action.actionTypeId() == extendedSmartMeterConsumerS0InputActionTypeId) { - bool value = info->action().param(extendedSmartMeterConsumerS0InputActionS0InputParamTypeId).value().toBool(); - thing->setStateValue(extendedSmartMeterConsumerS0InputStateTypeId, value); + if (action.actionTypeId() == extendedSmartMeterConsumerImpulseInputActionTypeId) { + bool value = info->action().param(extendedSmartMeterConsumerImpulseInputActionImpulseInputParamTypeId).value().toBool(); + thing->setStateValue(extendedSmartMeterConsumerImpulseInputStateTypeId, value); int impulsePerKwh = info->thing()->setting(extendedSmartMeterConsumerSettingsImpulsePerKwhParamTypeId).toInt(); if (value) { double currentEnergy = thing->stateValue(extendedSmartMeterConsumerTotalEnergyConsumedStateTypeId).toDouble(); thing->setStateValue(extendedSmartMeterConsumerTotalEnergyConsumedStateTypeId ,currentEnergy + (1.00/impulsePerKwh)); - m_pulsesPerTimeframe.insert(thing, m_pulsesPerTimeframe.value(thing)+1); + m_pulsesPerTimeframe[thing]++; } info->finish(Thing::ThingErrorNoError); return; @@ -514,11 +521,9 @@ void IntegrationPluginGenericThings::thingRemoved(Thing *thing) m_venetianBlindTargetAngle.remove(thing); } else if (thing->thingClassId() == extendedSmartMeterConsumerThingClassId) { m_pulsesPerTimeframe.remove(thing); - } - - if (myThings().isEmpty()) { - hardwareManager()->pluginTimerManager()->unregisterTimer(m_smartMeterTimer); - m_smartMeterTimer = nullptr; + } else if (thing->thingClassId() == extendedSmartMeterConsumerThingClassId) { + m_smartMeterTimer.take(thing)->deleteLater(); + m_pulsesPerTimeframe.remove(thing); } } diff --git a/genericthings/integrationplugingenericthings.h b/genericthings/integrationplugingenericthings.h index 77fa0aeb..bba4e8ff 100644 --- a/genericthings/integrationplugingenericthings.h +++ b/genericthings/integrationplugingenericthings.h @@ -50,13 +50,13 @@ public: void thingRemoved(Thing *thing) override; private: - PluginTimer *m_smartMeterTimer = nullptr; QHash m_pulsesPerTimeframe; double mapDoubleValue(double value, double fromMin, double fromMax, double toMin, double toMax); QHash m_extendedBlindPercentageTimer; QHash m_venetianBlindAngleTimer; + QHash m_smartMeterTimer; QHash m_extendedBlindTargetPercentage; QHash m_venetianBlindTargetAngle; diff --git a/genericthings/integrationplugingenericthings.json b/genericthings/integrationplugingenericthings.json index 6cffcfc0..70d378d9 100644 --- a/genericthings/integrationplugingenericthings.json +++ b/genericthings/integrationplugingenericthings.json @@ -697,7 +697,7 @@ { "id": "c3123967-f741-4fe1-a0d4-9a3e405d7e52", "name": "extendedSmartMeterConsumer", - "displayName": "Extended smart meter consumer", + "displayName": "Impulse based energy meter", "createMethods": ["user"], "interfaces": ["extendedsmartmeterconsumer"], "settingsTypes": [ @@ -709,6 +709,16 @@ "minValue": 1, "maxValue": 1000000, "defaultValue": 1000 + }, + { + "id": "73c9acc3-8f76-40d7-a79b-a1f08bb308d4", + "name": "impulseTimeframe", + "displayName": "Timeframe for power calculation", + "type": "int", + "unit": "Seconds", + "minValue": 1, + "maxValue": 600, + "defaultValue": 10 } ], "stateTypes": [ @@ -732,10 +742,10 @@ }, { "id": "9cd7e5ca-f8f8-48d5-9785-911ae75158c3", - "name": "s0Input", - "displayName": "S0 input", - "displayNameEvent": "S0 impulse", - "displayNameAction": "S0 impulse", + "name": "impulseInput", + "displayName": "Impulse input", + "displayNameEvent": "Impulse input changed", + "displayNameAction": "Set impulse input", "type": "bool", "defaultValue": false, "writable": true, diff --git a/genericthings/translations/b3188696-2585-4806-bf98-30ab576ce5c8-de.ts b/genericthings/translations/b3188696-2585-4806-bf98-30ab576ce5c8-de.ts index 14cc0694..25a6b0d5 100644 --- a/genericthings/translations/b3188696-2585-4806-bf98-30ab576ce5c8-de.ts +++ b/genericthings/translations/b3188696-2585-4806-bf98-30ab576ce5c8-de.ts @@ -567,31 +567,39 @@ The name of the StateType ({5821edb7-e6cb-4e5a-9d0b-3375126d3367}) of ThingClass The name of the EventType ({5821edb7-e6cb-4e5a-9d0b-3375126d3367}) of ThingClass extendedSmartMeterConsumer Energie geändert - - Extended smart meter consumer - The name of the ThingClass ({c3123967-f741-4fe1-a0d4-9a3e405d7e52}) - Erweiterter Smart-Meter Verbraucher - Impulse/kWh The name of the ParamType (ThingClass: extendedSmartMeterConsumer, Type: settings, ID: {c361732b-68eb-447e-a434-e84031231871}) Impulse/kWh - S0 impulse - The name of the ActionType ({9cd7e5ca-f8f8-48d5-9785-911ae75158c3}) of ThingClass extendedSmartMeterConsumer + Impulse input + The name of the ParamType (ThingClass: extendedSmartMeterConsumer, ActionType: impulseInput, ID: {9cd7e5ca-f8f8-48d5-9785-911ae75158c3}) ---------- -The name of the EventType ({9cd7e5ca-f8f8-48d5-9785-911ae75158c3}) of ThingClass extendedSmartMeterConsumer - S0 Impulse - - - S0 input - The name of the ParamType (ThingClass: extendedSmartMeterConsumer, ActionType: s0Input, ID: {9cd7e5ca-f8f8-48d5-9785-911ae75158c3}) ----------- -The name of the ParamType (ThingClass: extendedSmartMeterConsumer, EventType: s0Input, ID: {9cd7e5ca-f8f8-48d5-9785-911ae75158c3}) +The name of the ParamType (ThingClass: extendedSmartMeterConsumer, EventType: impulseInput, ID: {9cd7e5ca-f8f8-48d5-9785-911ae75158c3}) ---------- The name of the StateType ({9cd7e5ca-f8f8-48d5-9785-911ae75158c3}) of ThingClass extendedSmartMeterConsumer - S0 Input + Impulseingang + + + Impulse input changed + The name of the EventType ({9cd7e5ca-f8f8-48d5-9785-911ae75158c3}) of ThingClass extendedSmartMeterConsumer + Impulseingang geändert + + + Set impulse input + The name of the ActionType ({9cd7e5ca-f8f8-48d5-9785-911ae75158c3}) of ThingClass extendedSmartMeterConsumer + Setze Impulseingang + + + Timeframe for power calculation + The name of the ParamType (ThingClass: extendedSmartMeterConsumer, Type: settings, ID: {73c9acc3-8f76-40d7-a79b-a1f08bb308d4}) + Zeitfenster für Leistungsberechnung + + + Impulse based energy meter + The name of the ThingClass ({c3123967-f741-4fe1-a0d4-9a3e405d7e52}) + Impulsbasierter Energiezähler diff --git a/genericthings/translations/b3188696-2585-4806-bf98-30ab576ce5c8-en_US.ts b/genericthings/translations/b3188696-2585-4806-bf98-30ab576ce5c8-en_US.ts index edb544fb..fd67c5f9 100644 --- a/genericthings/translations/b3188696-2585-4806-bf98-30ab576ce5c8-en_US.ts +++ b/genericthings/translations/b3188696-2585-4806-bf98-30ab576ce5c8-en_US.ts @@ -567,30 +567,38 @@ The name of the StateType ({5821edb7-e6cb-4e5a-9d0b-3375126d3367}) of ThingClass The name of the EventType ({5821edb7-e6cb-4e5a-9d0b-3375126d3367}) of ThingClass extendedSmartMeterConsumer - - Extended smart meter consumer - The name of the ThingClass ({c3123967-f741-4fe1-a0d4-9a3e405d7e52}) - - Impulse/kWh The name of the ParamType (ThingClass: extendedSmartMeterConsumer, Type: settings, ID: {c361732b-68eb-447e-a434-e84031231871}) - S0 impulse - The name of the ActionType ({9cd7e5ca-f8f8-48d5-9785-911ae75158c3}) of ThingClass extendedSmartMeterConsumer + Impulse input + The name of the ParamType (ThingClass: extendedSmartMeterConsumer, ActionType: impulseInput, ID: {9cd7e5ca-f8f8-48d5-9785-911ae75158c3}) ---------- -The name of the EventType ({9cd7e5ca-f8f8-48d5-9785-911ae75158c3}) of ThingClass extendedSmartMeterConsumer +The name of the ParamType (ThingClass: extendedSmartMeterConsumer, EventType: impulseInput, ID: {9cd7e5ca-f8f8-48d5-9785-911ae75158c3}) +---------- +The name of the StateType ({9cd7e5ca-f8f8-48d5-9785-911ae75158c3}) of ThingClass extendedSmartMeterConsumer - S0 input - The name of the ParamType (ThingClass: extendedSmartMeterConsumer, ActionType: s0Input, ID: {9cd7e5ca-f8f8-48d5-9785-911ae75158c3}) ----------- -The name of the ParamType (ThingClass: extendedSmartMeterConsumer, EventType: s0Input, ID: {9cd7e5ca-f8f8-48d5-9785-911ae75158c3}) ----------- -The name of the StateType ({9cd7e5ca-f8f8-48d5-9785-911ae75158c3}) of ThingClass extendedSmartMeterConsumer + Impulse input changed + The name of the EventType ({9cd7e5ca-f8f8-48d5-9785-911ae75158c3}) of ThingClass extendedSmartMeterConsumer + + + + Set impulse input + The name of the ActionType ({9cd7e5ca-f8f8-48d5-9785-911ae75158c3}) of ThingClass extendedSmartMeterConsumer + + + + Timeframe for power calculation + The name of the ParamType (ThingClass: extendedSmartMeterConsumer, Type: settings, ID: {73c9acc3-8f76-40d7-a79b-a1f08bb308d4}) + + + + Impulse based energy meter + The name of the ThingClass ({c3123967-f741-4fe1-a0d4-9a3e405d7e52}) From db677101857733518b4589abca167a88e02d5daf Mon Sep 17 00:00:00 2001 From: "bernhard.trinnes" Date: Wed, 29 Jul 2020 15:00:49 +0200 Subject: [PATCH 7/8] fixed power calculation --- genericthings/integrationplugingenericthings.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/genericthings/integrationplugingenericthings.cpp b/genericthings/integrationplugingenericthings.cpp index 26a46542..10ae19be 100644 --- a/genericthings/integrationplugingenericthings.cpp +++ b/genericthings/integrationplugingenericthings.cpp @@ -190,6 +190,7 @@ void IntegrationPluginGenericThings::setupThing(ThingSetupInfo *info) int timeframe = thing->setting(extendedSmartMeterConsumerSettingsImpulseTimeframeParamTypeId).toInt(); smartMeterTimer->setInterval(timeframe * 1000); m_smartMeterTimer.insert(thing, smartMeterTimer); + smartMeterTimer->start(); connect(thing, &Thing::settingChanged, smartMeterTimer, [smartMeterTimer] (const ParamTypeId ¶mTypeId, const QVariant &value) { if (paramTypeId == extendedSmartMeterConsumerSettingsImpulseTimeframeParamTypeId) { smartMeterTimer->setInterval(value.toInt() * 1000); @@ -198,7 +199,8 @@ void IntegrationPluginGenericThings::setupThing(ThingSetupInfo *info) connect(smartMeterTimer, &QTimer::timeout, thing, [this, smartMeterTimer, thing] { double impulsePerKwh = thing->setting(extendedSmartMeterConsumerSettingsImpulsePerKwhParamTypeId).toDouble(); - double power = (m_pulsesPerTimeframe.value(thing)/impulsePerKwh)/(smartMeterTimer->interval()/3600.00); // Power = Energy/Time; Energy = Impulses/ImpPerkWh + int interval = smartMeterTimer->interval()/1000; + double power = (m_pulsesPerTimeframe.value(thing)/impulsePerKwh)/(interval/3600.00); // Power = Energy/Time; Energy = Impulses/ImpPerkWh thing->setStateValue(extendedSmartMeterConsumerCurrentPowerStateTypeId, power*1000); m_pulsesPerTimeframe.insert(thing, 0); }); From 90f9aec2c75fc0bf1c4b71548c4d5e9b85c29629 Mon Sep 17 00:00:00 2001 From: "bernhard.trinnes" Date: Mon, 17 Aug 2020 13:38:39 +0200 Subject: [PATCH 8/8] fixed smart meter gpio connection --- genericthings/integrationplugingenericthings.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/genericthings/integrationplugingenericthings.json b/genericthings/integrationplugingenericthings.json index 70d378d9..049fa0eb 100644 --- a/genericthings/integrationplugingenericthings.json +++ b/genericthings/integrationplugingenericthings.json @@ -749,7 +749,7 @@ "type": "bool", "defaultValue": false, "writable": true, - "ioType": "digitalInput" + "ioType": "digitalOutput" } ] }