Trigger scene over average power metering

Hello,

I’m prettynew with vera control, and I have a question that I hope might not be so complicated to solve.

I have an induction stove at home.
Since I installed vera, I noticed it consumes about 80W just by being iddle. Here the graph (vitro3).
So I installed a contactor controlled by vera so be able to shut it off when not in use.
The problem is sometimes we forget to turn it off, and I’d like to make it automatic.

As you can see on the other graph (bitro3b) the stove at its minimum power setting it’s pulsating and does not draw a contant amount of W, so I can’t just shut it off when power is below 80W for example.

The question is: Is there an easy way to know the average W consumption in the past lest’s say 5 minutes?
That way I could shout it off if below 100W for example.

I’d appreciate any help anyone can give me.

Thanks in advance

There’s no easy(built-in) way to do what you request. But, I see a few possibilities for getting it done.

This thread discusses and provides code for shutting down the relay when power consumption drops to a particular level.

I suspect that you could also use PLEG with the power level as an input device property to get it done.

Edit: 80 watts seems very high for an idled appliance. I would verify with the manufacturer if 80 watts at idle is actually normal.

However, what I really suspect is that the power measurement method is inaccurate. See this article about how some meters do not accurately account for power factor(PF) and give erroneous measurements on things like induction hobs(stoves).

Even with new computer controlled appliances, I don’t think that they should draw more than a few watts(1-10) when idle.

I do not know where you get your power from … But I assume it’s available in some device property.

You can do this in the following manner with PLEG.

Create a sampling interval to sample the power say 30 seconds. In PLEG create an Input Schedule … call it Sample with a start type of Interval and set the interval to 30.

Create an Input device Property called Power that is bound to the Vera Device Property that is monitoring your oven.

Now we build conditions that perform what is called an exponential filter, or weighted average. The bold part is the condition name:

TimeConstant Sample ? .5 : 1
FilteredPower (FilteredPower * TimeConstant) + ((1 - TimeConstant) * Power)
AutoOff FilteredPower < 80

Add any actions you want to the condition AutoOff
[hr]
Change the value of .5 (know as the time constant) to a smaller value to be a quick average and a larger value (but less than 1) to be a slower average.
[hr]
In the above example, if the expressions are triggered by something other than the Sample timer(i.e. the Power value changes), the time constant is set at 1 and the FilteredPower remains unchanged.

[quote=“RichardTSchaefer, post:3, topic:178023”]Create a sampling interval to sample the power say 30 seconds. In PLEG create an Input Schedule … call it Sample with a start type of Interval and set the interval to 30.

Create an Input device Property called Power that is bound to the Vera Device Property that is monitoring your oven.

Now we build conditions that perform what is called an exponential filter, or weighted average. The bold part is the condition name:[/quote]
Wow, Richard. It looks simple due to the brevity, but how does this work? I can’t wrap my mind around this.

[b]TimeConstant[/b] Sample ? .5 : 1 [i]-- IF interval is true THEN TimeConstant == .5 ELSE TimeConstant == 1[/i] [b]FilteredPower[/b] (FilteredPower * TimeConstant) + ((1 - TimeConstant) * Power) [i]-- FilteredPower == (null * .5) + ((1 - .5) * Power) [/i]
What? FilteredPower is null on first pass, no? So if Power == 80, FilterdPower == (null * .5) + ((1 - .5) * 80) Therefore FilteredPower == what 40?
[b]AutoOff[/b] FilteredPower < 80
QED?

Would it not be clearer or not work to use a progression?
AutoOff (Power > 80); (Power < 81); NOW > 5:00

Edit: I see, his power reading is pulsing. Hence the complex sampling. I still don’t fully understand your PLEG recipe. I’m also even more convinced that his power consumption reading is inaccurate.

Yes something like the following could also work:
PowerAbove Power > 80
PowerBelow Power < 80
AutoOff PowerAbove; PowerBelow;NOW > 5:00

This would work if there are no noise spikes.
Lookup exponential filters or exponential smoothing for info about my recipe.

Hello,

I agree with you about not being true measurement. I use an Aeon clamp conected to vera, but I made some tests with with a probe plugged directly (in another house not mine) and it seams that the aeon estimates a power factor of 0.85 to be more acurate. Never the less, it’s not allowed for an apliance to have a much lower power factor (at least here in Spain) so I guess maybe is not 80W but if it is 40 or 50 is still too much to waste. Also when working at max, the reported W is pretty much what the manufacturer says.

This has 10 years or so, when all this green saving thinking was still not in place.

Even if it is as the article says, 12% is still too much.

Anyway, I’ll try Richard’s approach and see how it goes… the problem is that this stove, at lower settings, power is not continuous. It works kind of pulsating on-off (see the graph).

Thanks again both for your input.

I did what you suggested, but I get an error (look at the image).

Also I attached the pannels to see if I did correctly and also some logs:

[quote]gramLogicEG variable: Armed was: 0 now: 1 #hooks: 0 upnp: 0 v:0xde8d50/NONE duplicate:0 <0x305c0680>

06 11/30/13 17:16:48.189 Device_Variable::m_szValue_set device: 26 service: urn:micasaverde-com:serviceId:EnergyMetering1 variable: Watts was: 78 now: 78 #hooks: 2 upnp: 0 v:0xfec508/NONE duplicate:1 <0x2bf47680>

06 11/30/13 17:16:58.105 Device_Variable::m_szValue_set device: 42 service: urn:rts-services-com:serviceId:ProgramLogicC variable: ObjectStatusMap was: {{name = ‘sample’, state = false, seq = 1385828188.1003},{name = ‘TimeConstant’, state = nil, seq = 1385828058.3103},{name = ‘FilteredPower’, state = nil, seq = 0},{name = ‘AutoOff’, state = nil, seq = 1385828058.3164},{name = ‘power’, state = ‘78’, seq = 1385828088.1648},} now: {{name = ‘sample’, state = false, seq = 1385828218.1004},{name = ‘TimeConstant’, state = nil, seq = 1385828058.3103},{name = ‘FilteredPower’, state = nil, seq = 0},{name = ‘AutoOff’, state = nil, seq = 1385828058.3164},{name = ‘power’, state = ‘78’, seq = 1385828088.1648},} #hooks: 0 upnp: 0 v:0x1066c40/NONE duplicate:0 <0x2cf47680>

Here is the status of PLEG:

Program Logic Event Generator Device ID: 422013-11-30 17:36:17.126 PLC Version: 5.4 Schedules Name Type Time Days Random On Delay Off After Type Off Time Off Days Random Off Delay State Last Schedule sample Interval 0:0:30 None None None false 2013-11-30 16:35:34.100 Device Properties Name Device Name Device Variable Last Change Value power Power Meter (Vitrocer?mica) Watts 2013-11-30 16:35:48.484 78 Conditions Name Expression Last True State TimeConstant Sample ? .5 : 1 2013-11-30 16:14:18.310 null FilteredPower (FilteredPower * TimeConstant) + ((1 - TimeConstant) * Power) 0 null AutoOff FilteredPower < 80 2013-11-30 16:14:18.316 null Actions Actions for Condition: AutoOff Immediate Device Action Arguments Push Notification SendPushOverNotification Title=VITRO Message=encendida sin uso? Priority= URL= URLTitle= Sound= DeviceName=

Leave it to me to find my own bugs … Change the .5 to 0.5 (it does not like a nunber without a leading digit).

I tested this by binding my input to the LoadLevel Status of a dimmer (That’s the setting and it’s between 0 and 100. Then I watched how fast the Filtered value changed after I changed the dimmer setting.

Sorry, no luck. Still same error.

Conditions Name Expression Last True State TimeConstant sample ? 0.5 : 1 2013-11-30 18:13:22.102 0.5 FilteredPower (FilteredPower * TimeConstant) + ((1 - TimeConstant) * power) 0 null AutoOff FilteredPower < 80 2013-11-30 16:14:18.316 null

Now Timeconstant is not null, but the rest are.

I used Richard’s example for my washing machine energy meter and it works well.

I noticed you are using lower case power in device properties and title case Power in the condition statement. Try using a consistent case.

Yes I noticed that too after posing the first report.
I changed it to all lower case but still same error.
As you can see, all variables are known.

Thanks anyway

For troubleshooting purposes, consider adding a new condition as below. Also keep your original condition FilteredPower. Save PLEG and let it run. See if cFilteredPower is also null or has a value.

Condition name
cFilteredPower

Condition expression
(cFilteredPower * TimeConstant) + ((1-TimeConstant) * power)

Here’s the result…

Device Properties Name Device Name Device Variable Last Change Value power Power Meter (Vitrocer?mica) Watts 2013-11-30 22:29:20.072 76 Conditions Name Expression Last True State TimeConstant sample ? 0.5 : 1 2013-11-30 18:13:22.102 0.5 FilteredPower (FilteredPower * TimeConstant) + ((1 - TimeConstant) * power) 0 null AutoOff FilteredPower < 80 2013-11-30 16:14:18.316 null cFilteredPower (cFilteredPower * TimeConstant) + ((1-TimeConstant) * power) 0 63.312150001526

Delete your condition:
cFilteredPower

The strategy was to rename the existing condition … this will remove the weird state it’s in because of the .5 bug.

In the conditions editor change FilteredPower to Filtered
This will fix up existing references.

Ok, now it seems to work

Conditions Name Expression Last True State TimeConstant sample ? 0.5 : 1 2013-11-30 18:13:22.102 0.5 Filtered (Filtered * TimeConstant) + ((1 - TimeConstant) * power) 0 38.5 AutoOff Filtered < 80 2013-11-30 22:50:38.107 true

but the action is triggered even if there is 0W.

How would I add a condition to not fire if under 50W for example?
Could it be: Filtered < 80 & sample >50
or do I need to add another condition.

The rest works pretty well… just to get this straight, we get a sample every 30 seconds and average with stored data until below 80, right?

How heavy is this kind of sampling/calculation on the vera processor?
Is it worth to bypass the PLEG when not needed?

Thanks!

Could it be: Filtered < 80 & sample >50

Close! it should be:
Filtered < 80 AND power >50

How heavy is this kind of sampling/calculation on the vera processor? Is it worth to bypass the PLEG when not needed?
This eats up a few ms of CPU every 30 seconds ... or when the power changes. Probably equivalent to the overhead the Plugin that is reading the power in the first place.

That’s perfect, thank you.

Just by turning on the system, triggers almost instantly…
I created a scene to delay arming PLEG for a minute or so, and disarming when turning off.
Is there a way to do this inside PLEG without new scenes?

Also I’d like to know if it’d be possible to reset AutoOff to false before/when arming PLEG.

Thanks again for sharing your knowledge

Do the following … and it will only trigger on the falling side:

BelowSetPoint Filtered < 80
AboveSetPoint Not BelowSetPoint
AboveLowSetPoint power > 50
AutoOff BelowSetPoint AND AboveLowSetPoint AND (AboveLowSetPoint; AboveSetPoint; BelowSetPoint)

This breaks the condition down into parts … The reason is to get a time stamp for the different events. The last part (AboveLowSetPoint; AboveSetPoint; BelowSetPoint) is a sequence expression and is true when the time stamps are in the specified order. In English this means that the AutoOff will trigger when the filtered power is below 80 AND the instantaneous power is above 50, but only if the AveragePower was above 80 in the first place.

That works ok.
Thank you.

Is it possible to execute some lua code as an action?
Can’t seem to find the place to put the code in the actions tab