rebased to venetian blind branch
parent
b9b6c19b15
commit
863d6b6374
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,9 +32,10 @@
|
|||
#define INTEGRATIONPLUGINGENERICTHINGS_H
|
||||
|
||||
#include "integrations/integrationplugin.h"
|
||||
#include <QTimer>
|
||||
#include "plugintimer.h"
|
||||
|
||||
#include <QTimer>
|
||||
|
||||
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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue