rebased to venetian blind branch
This commit is contained in:
parent
b9b6c19b15
commit
863d6b6374
@ -40,28 +40,10 @@ IntegrationPluginGenericThings::IntegrationPluginGenericThings()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void IntegrationPluginGenericThings::init()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void IntegrationPluginGenericThings::setupThing(ThingSetupInfo *info)
|
void IntegrationPluginGenericThings::setupThing(ThingSetupInfo *info)
|
||||||
{
|
{
|
||||||
Thing *thing = info->thing();
|
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) {
|
if (thing->thingClassId() == extendedBlindThingClassId) {
|
||||||
uint closingTime = thing->setting(extendedBlindSettingsClosingTimeParamTypeId).toUInt();
|
uint closingTime = thing->setting(extendedBlindSettingsClosingTimeParamTypeId).toUInt();
|
||||||
if (closingTime == 0) {
|
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)
|
void IntegrationPluginGenericThings::executeAction(ThingActionInfo *info)
|
||||||
@ -518,12 +512,7 @@ void IntegrationPluginGenericThings::thingRemoved(Thing *thing)
|
|||||||
m_extendedBlindTargetPercentage.remove(thing);
|
m_extendedBlindTargetPercentage.remove(thing);
|
||||||
m_venetianBlindAngleTimer.take(thing)->deleteLater();
|
m_venetianBlindAngleTimer.take(thing)->deleteLater();
|
||||||
m_venetianBlindTargetAngle.remove(thing);
|
m_venetianBlindTargetAngle.remove(thing);
|
||||||
}
|
} else if (thing->thingClassId() == extendedSmartMeterConsumerThingClassId) {
|
||||||
}
|
|
||||||
|
|
||||||
void IntegrationPluginGenericThings::thingRemoved(Thing *thing)
|
|
||||||
{
|
|
||||||
if (thing->thingClassId() == extendedSmartMeterConsumerThingClassId) {
|
|
||||||
m_pulsesPerTimeframe.remove(thing);
|
m_pulsesPerTimeframe.remove(thing);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -32,9 +32,10 @@
|
|||||||
#define INTEGRATIONPLUGINGENERICTHINGS_H
|
#define INTEGRATIONPLUGINGENERICTHINGS_H
|
||||||
|
|
||||||
#include "integrations/integrationplugin.h"
|
#include "integrations/integrationplugin.h"
|
||||||
#include <QTimer>
|
|
||||||
#include "plugintimer.h"
|
#include "plugintimer.h"
|
||||||
|
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
class IntegrationPluginGenericThings: public IntegrationPlugin
|
class IntegrationPluginGenericThings: public IntegrationPlugin
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -44,7 +45,6 @@ class IntegrationPluginGenericThings: public IntegrationPlugin
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
explicit IntegrationPluginGenericThings();
|
explicit IntegrationPluginGenericThings();
|
||||||
void init() override;
|
|
||||||
void setupThing(ThingSetupInfo *info) override;
|
void setupThing(ThingSetupInfo *info) override;
|
||||||
void executeAction(ThingActionInfo *info) override;
|
void executeAction(ThingActionInfo *info) override;
|
||||||
void thingRemoved(Thing *thing) override;
|
void thingRemoved(Thing *thing) override;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user